Fixes some gotchas.
authorMihai Bazon <mihai@bazon.net>
Sun, 27 May 2012 11:36:44 +0000 (14:36 +0300)
committerMihai Bazon <mihai@bazon.net>
Sun, 27 May 2012 11:36:44 +0000 (14:36 +0300)
DynarchLIB (660K) now passes parsing in 440ms (about 30% slower than the
parser in UglifyJS v1).

lib/parse.js

index 468e348..7164f3e 100644 (file)
@@ -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,