}
while (!stream.look().eof) {
- console.log(tokens);
if (this.read_mlcomment(stream, tokens)) continue;
if (this.read_slcomment(stream, tokens)) continue;
if (this.read_dbquote(stream, tokens)) continue;
if (this.collapseWhite) {
found = "\n";
}
- if (this.keepWhite) {
- var last = tokens.pop();
+ if (this.keepWhite) {
+ var last = tokens ? tokens.pop() : false;
if (last && last.name != "WHIT") {
tokens.push(last);
}
)
) {
var regex = stream.next();
-
+ var in_brace = false;
while (!stream.look().eof) {
+
+ if (stream.look() == "[") { // escape sequence
+ in_brace = true;
+
+ }
+
+ if (stream.look() == "]") { // escape sequence
+ in_brace = false;
+ }
+
if (stream.look() == "\\") { // escape sequence
regex += stream.next(2);
+ continue;
}
- else if (stream.look() == "/") {
+
+ if (!in_brace && stream.look() == "/") {
regex += stream.next();
while (/[gmi]/.test(stream.look())) {
tokens.push(new Token(regex, "REGX", "REGX", this.line));
return true;
}
- else {
- regex += stream.next();
- }
+
+ regex += stream.next();
+
}
// error: unterminated regex
}