From: Mihai Bazon Date: Mon, 2 Sep 2013 06:56:27 +0000 (+0300) Subject: Fix parsing regexp after unary-prefix operator X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=78a217b94c7648c88c46e0f5e9c15c747bef35dd;p=UglifyJS.git Fix parsing regexp after unary-prefix operator ++/x/.y Fix #284 --- diff --git a/lib/parse.js b/lib/parse.js index 48ab2167..cc80a935 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -688,12 +688,16 @@ function parse($TEXT, options) { }; }; - var statement = embed_tokens(function() { - var tmp; + function handle_regexp() { if (is("operator", "/") || is("operator", "/=")) { S.peeked = null; S.token = S.input(S.token.value.substr(1)); // force regexp } + }; + + var statement = embed_tokens(function() { + var tmp; + handle_regexp(); switch (S.token.type) { case "string": var dir = S.in_directives, stat = simple_statement(); @@ -1279,6 +1283,7 @@ function parse($TEXT, options) { var start = S.token; if (is("operator") && UNARY_PREFIX(start.value)) { next(); + handle_regexp(); var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls)); ex.start = start; ex.end = prev();