found = "\n";
}
if (this.keepWhite) {
- //console.log(typeof(token));
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
}