diff options
Diffstat (limited to 'lib/parse.js')
-rw-r--r-- | lib/parse.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/parse.js b/lib/parse.js index 97dd6d4b..c960b493 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -477,31 +477,33 @@ function tokenizer($TEXT, filename, html5_comments, shebang) { return name; }; - var read_regexp = with_eof_error("Unterminated regular expression", function(regexp){ + var read_regexp = with_eof_error("Unterminated regular expression", function(source) { var prev_backslash = false, ch, in_class = false; while ((ch = next(true))) if (NEWLINE_CHARS(ch)) { parse_error("Unexpected line terminator"); } else if (prev_backslash) { - regexp += "\\" + ch; + source += "\\" + ch; prev_backslash = false; } else if (ch == "[") { in_class = true; - regexp += ch; + source += ch; } else if (ch == "]" && in_class) { in_class = false; - regexp += ch; + source += ch; } else if (ch == "/" && !in_class) { break; } else if (ch == "\\") { prev_backslash = true; } else { - regexp += ch; + source += ch; } var mods = read_name(); try { - return token("regexp", new RegExp(regexp, mods)); + var regexp = new RegExp(source, mods); + regexp.raw_source = source; + return token("regexp", regexp); } catch(e) { - parse_error(e.message); + parse_error(e.message); } }); |