diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-12-22 18:16:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-23 02:16:04 +0800 |
commit | f85a206b9ed5b39726a2da39680056c09d3f9687 (patch) | |
tree | ccd570d6abb0d3e25b44f53b9db4ca137feb586c /lib | |
parent | bba7cd0a70551617a243a9c78ec18eef42f89ad6 (diff) | |
download | tracifyjs-f85a206b9ed5b39726a2da39680056c09d3f9687.tar.gz tracifyjs-f85a206b9ed5b39726a2da39680056c09d3f9687.zip |
fix corner case when parsing expression (#4435)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/parse.js b/lib/parse.js index 111be3b5..87293cab 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -737,7 +737,7 @@ function parse($TEXT, options) { function semicolon(optional) { if (is("punc", ";")) next(); - else if (!optional && !can_insert_semicolon()) expect_token("punc", ";"); + else if (!optional && !can_insert_semicolon()) expect(";"); } function parenthesised() { @@ -1166,7 +1166,7 @@ function parse($TEXT, options) { expect("{"); var a = []; while (!is("punc", "}")) { - if (is("eof")) expect_token("punc", "}"); + if (is("eof")) expect("}"); a.push(statement()); } next(); @@ -1177,7 +1177,7 @@ function parse($TEXT, options) { expect("{"); var a = [], branch, cur, default_branch, tmp; while (!is("punc", "}")) { - if (is("eof")) expect_token("punc", "}"); + if (is("eof")) expect("}"); if (is("keyword", "case")) { if (branch) branch.end = prev(); cur = []; @@ -1561,9 +1561,8 @@ function parse($TEXT, options) { } function as_name() { - if (!is("name")) expect_token("name"); var name = S.token.value; - next(); + expect_token("name"); return name; } @@ -1861,7 +1860,9 @@ function parse($TEXT, options) { if (options.expression) { handle_regexp(); - return expression(); + var exp = expression(); + expect_token("eof"); + return exp; } return function() { |