From 3c2bd590da34fd309154c7d1731d8f88985746ce Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 15 Jan 2013 15:58:16 +0100 Subject: [PATCH] Fix regexp detection after void/typeof/instanceof/delete --- acorn.js | 12 +++++------- index.html | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/acorn.js b/acorn.js index 0c3cc45d7d..6046858e55 100644 --- a/acorn.js +++ b/acorn.js @@ -231,10 +231,10 @@ "function": _function, "if": _if, "return": _return, "switch": _switch, "throw": _throw, "try": _try, "var": _var, "while": _while, "with": _with, "null": _null, "true": _true, "false": _false, "new": _new, "in": _in, - "instanceof": {keyword: "instanceof", binop: 7}, "this": _this, - "typeof": {keyword: "typeof", prefix: true}, - "void": {keyword: "void", prefix: true}, - "delete": {keyword: "delete", prefix: true}}; + "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this, + "typeof": {keyword: "typeof", prefix: true, beforeExpr: true}, + "void": {keyword: "void", prefix: true, beforeExpr: true}, + "delete": {keyword: "delete", prefix: true, beforeExpr: true}}; // Punctuation token types. Again, the `type` property is purely for debugging. @@ -467,9 +467,7 @@ } else if (next === 47) { // '/' skipLineComment(); } else break; - } else if (ch < 14 && ch > 8) { - ++tokPos; - } else if (ch === 32 || ch === 160) { // ' ', '\xa0' + } else if ((ch < 14 && ch > 8) || ch === 32 || ch === 160) { // ' ', '\xa0' ++tokPos; } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { ++tokPos; diff --git a/index.html b/index.html index 90b9709a7c..69d3e1c7c4 100644 --- a/index.html +++ b/index.html @@ -130,10 +130,10 @@ we assign a variable name to it for quick comparing.

"function": _function, "if": _if, "return": _return, "switch": _switch, "throw": _throw, "try": _try, "var": _var, "while": _while, "with": _with, "null": _null, "true": _true, "false": _false, "new": _new, "in": _in, - "instanceof": {keyword: "instanceof", binop: 7}, "this": _this, - "typeof": {keyword: "typeof", prefix: true}, - "void": {keyword: "void", prefix: true}, - "delete": {keyword: "delete", prefix: true}};

Punctuation token types. Again, the type property is purely for debugging.

  var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
+                      "instanceof": {keyword: "instanceof", binop: 7, beforeExpr: true}, "this": _this,
+                      "typeof": {keyword: "typeof", prefix: true, beforeExpr: true},
+                      "void": {keyword: "void", prefix: true, beforeExpr: true},
+                      "delete": {keyword: "delete", prefix: true, beforeExpr: true}};

Punctuation token types. Again, the type property is purely for debugging.

  var _bracketL = {type: "[", beforeExpr: true}, _bracketR = {type: "]"}, _braceL = {type: "{", beforeExpr: true};
   var _braceR = {type: "}"}, _parenL = {type: "(", beforeExpr: true}, _parenR = {type: ")"};
   var _comma = {type: ",", beforeExpr: true}, _semi = {type: ";", beforeExpr: true};
   var _colon = {type: ":", beforeExpr: true}, _dot = {type: "."}, _question = {type: "?", beforeExpr: true};

Operators. These carry several kinds of properties to help the @@ -286,9 +286,7 @@ whitespace and comments, and.

} else if (next === 47) { // '/' skipLineComment(); } else break; - } else if (ch < 14 && ch > 8) { - ++tokPos; - } else if (ch === 32 || ch === 160) { // ' ', '\xa0' + } else if ((ch < 14 && ch > 8) || ch === 32 || ch === 160) { // ' ', '\xa0' ++tokPos; } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { ++tokPos;