From 46e7507b44c93cb1d9e141e583dc58600bbc037f Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Sun, 27 May 2012 14:36:44 +0300 Subject: [PATCH] Fixes some gotchas. DynarchLIB (660K) now passes parsing in 440ms (about 30% slower than the parser in UglifyJS v1). --- lib/parse.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/parse.js b/lib/parse.js index 468e348a..7164f3ee 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -203,6 +203,8 @@ JS_Parse_Error.prototype.toString = function() { }; function js_error(message, line, col, pos) { + console.log("***", message); + console.log("*** LINE:", line, "COL:", col, "POS:", pos); throw new JS_Parse_Error(message, line, col, pos); }; @@ -676,7 +678,7 @@ function parse($TEXT, exigent_mode) { if (is(type, val)) { return next(); } - token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type); + token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»"); }; function expect(punc) { return expect_token("punc", punc); }; @@ -762,7 +764,7 @@ function parse($TEXT, exigent_mode) { case "do": return new AST_Do({ body : in_loop(statement), - condition : (expect_token("while"), prog1(parenthesised, semicolon)) + condition : (expect_token("keyword", "while"), prog1(parenthesised, semicolon)) }); case "while": @@ -988,7 +990,6 @@ function parse($TEXT, exigent_mode) { next(); expect("("); var name = as_symbol(); - next(); expect(")"); bcatch = new AST_Catch({ argname : name, -- 2.34.1