diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/parse.js | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/parse.js b/lib/parse.js index 27351b53..40528df1 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -111,7 +111,7 @@ var WHITESPACE_CHARS = makePredicate(characters(" \u00a0\n\r\t\f\u000b\u200b\u20 var NEWLINE_CHARS = makePredicate(characters("\n\r\u2028\u2029")); -var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,.;:")); +var PUNC_BEFORE_EXPRESSION = makePredicate(characters("[{(,;:")); var PUNC_CHARS = makePredicate(characters("[]{}(),;:")); @@ -1353,14 +1353,15 @@ function parse($TEXT, options) { function as_property_name() { var tmp = S.token; - next(); switch (tmp.type) { + case "operator": + if (!KEYWORDS(tmp.value)) unexpected(); case "num": case "string": case "name": - case "operator": case "keyword": case "atom": + next(); return tmp.value; default: unexpected(); @@ -1369,16 +1370,9 @@ function parse($TEXT, options) { function as_name() { var tmp = S.token; + if (tmp.type != "name") unexpected(); next(); - switch (tmp.type) { - case "name": - case "operator": - case "keyword": - case "atom": - return tmp.value; - default: - unexpected(); - } + return tmp.value; }; function _make_symbol(type) { @@ -1439,14 +1433,14 @@ function parse($TEXT, options) { if (is("operator") && UNARY_PREFIX(start.value)) { next(); handle_regexp(); - var ex = make_unary(AST_UnaryPrefix, start.value, maybe_unary(allow_calls)); + var ex = make_unary(AST_UnaryPrefix, start, maybe_unary(allow_calls)); ex.start = start; ex.end = prev(); return ex; } var val = expr_atom(allow_calls); while (is("operator") && UNARY_POSTFIX(S.token.value) && !S.token.nlb) { - val = make_unary(AST_UnaryPostfix, S.token.value, val); + val = make_unary(AST_UnaryPostfix, S.token, val); val.start = start; val.end = S.token; next(); @@ -1454,9 +1448,10 @@ function parse($TEXT, options) { return val; }; - function make_unary(ctor, op, expr) { + function make_unary(ctor, token, expr) { + var op = token.value; if ((op == "++" || op == "--") && !is_assignable(expr)) - croak("Invalid use of " + op + " operator", null, ctor === AST_UnaryPrefix ? expr.start.col - 1 : null); + croak("Invalid use of " + op + " operator", token.line, token.col, token.pos); return new ctor({ operator: op, expression: expr }); }; |