diff --git a/acorn.js b/acorn.js index 9808f43da6..e0e8b63510 100644 --- a/acorn.js +++ b/acorn.js @@ -1717,6 +1717,7 @@ function parseIdent(liberal) { var node = startNode(); node.name = tokType === _name ? tokVal : (liberal && !options.forbidReserved && tokType.keyword) || unexpected(); + tokRegexpAllowed = false; next(); return finishNode(node, "Identifier"); } diff --git a/index.html b/index.html index fac2e0328d..2c52cf1987 100644 --- a/index.html +++ b/index.html @@ -14,11 +14,11 @@ https://github.com/marijnh/acorn.git
This file defines the main parser interface. The library also comes with a error-tolerant parser and an -abstract syntax tree walker, defined in other files.
(function(mod) {
+abstract syntax tree walker, defined in other files. (function(root, mod) {
if (typeof exports == "object" && typeof module == "object") return mod(exports); // CommonJS
if (typeof define == "function" && define.amd) return define(["exports"], mod); // AMD
- mod(this.acorn || (this.acorn = {})); // Plain browser env
-})(function(exports) {
+ mod(root.acorn || (root.acorn = {})); // Plain browser env
+})(this, function(exports) {
"use strict";
exports.version = "0.3.2";The main exported interface (under self.acorn when in the
@@ -103,7 +103,8 @@ reset the internal state, and invalidate existing tokenizers.
+=. Start the precedence parser.
function parseExprOps(noIn) {
- return parseExprOp(parseMaybeUnary(noIn), -1, noIn);
+ return parseExprOp(parseMaybeUnary(), -1, noIn);
}Parse binary operators with the operator precedence parsing
algorithm. left is the left-hand side of the operator.
minPrec provides context that allows the function to stop and
@@ -1070,19 +1071,19 @@ operator that has a lower precedence than the set it is parsing.
Parse unary operators, both prefix and postfix.
function parseMaybeUnary(noIn) {
+ }Parse unary operators, both prefix and postfix.
function parseMaybeUnary() {
if (tokType.prefix) {
var node = startNode(), update = tokType.isUpdate;
node.operator = tokVal;
node.prefix = true;
next();
- node.argument = parseMaybeUnary(noIn);
+ node.argument = parseMaybeUnary();
if (update) checkLVal(node.argument);
else if (strict && node.operator === "delete" &&
node.argument.type === "Identifier")
@@ -1284,6 +1285,7 @@ when parsing properties), it will also convert keywords into
identifiers. function parseIdent(liberal) {
var node = startNode();
node.name = tokType === _name ? tokVal : (liberal && !options.forbidReserved && tokType.keyword) || unexpected();
+ tokRegexpAllowed = false;
next();
return finishNode(node, "Identifier");
}
diff --git a/test/tests.js b/test/tests.js
index 87a6707016..8c427868b2 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -26235,7 +26235,36 @@ test("var a = 1;", {
}, {
locations: true,
sourceFile: "test.js"
-})
+});
+
+test("a.in / b", {
+ type: "Program",
+ body: [
+ {
+ type: "ExpressionStatement",
+ expression: {
+ type: "BinaryExpression",
+ left: {
+ type: "MemberExpression",
+ object: {
+ type: "Identifier",
+ name: "a"
+ },
+ property: {
+ type: "Identifier",
+ name: "in"
+ },
+ computed: false
+ },
+ operator: "/",
+ right: {
+ type: "Identifier",
+ name: "b"
+ }
+ }
+ }
+ ]
+});
// Failure tests