Permalink
Browse files

Fix for tokenizing and regex

When running tokenize on code with regular expression literals
the order of tokens would sometimes be off and extra tokens inserted.
This was due to peek being called before scanRegExp finished adding
the literal to extra.tokens.

http://code.google.com/p/esprima/issues/detail?id=446
  • Loading branch information...
1 parent 7a9e9db commit 599d96cb6a93adaa867fadbbd4bb69bb068933a2 @disnet disnet committed Oct 31, 2013
Showing with 1 addition and 37 deletions.
  1. +1 −1 esprima.js
  2. +0 −36 test/test.js
View
@@ -1118,7 +1118,6 @@ parseStatement: true, parseSourceElement: true */
throwError({}, Messages.InvalidRegExp);
}
- peek();
if (extra.tokenize) {
@@ -2179,6 +2178,7 @@ parseStatement: true, parseSourceElement: true */
} else {
expr = delegate.createLiteral(scanRegExp());
}
+ peek();
}
if (expr) {
View
@@ -19832,24 +19832,6 @@ var testFixture = {
}
}
},
- {
- "type": "Punctuator",
- "value": ")",
- "range": [
- 13,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 13
- },
- "end": {
- "line": 1,
- "column": 14
- }
- }
- },
{
"type": "RegularExpression",
"value": "/42/",
@@ -19979,24 +19961,6 @@ var testFixture = {
}
}
},
- {
- "type": "Punctuator",
- "value": "}",
- "range": [
- 18,
- 19
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 18
- },
- "end": {
- "line": 1,
- "column": 19
- }
- }
- },
{
"type": "RegularExpression",
"value": "/42/",

0 comments on commit 599d96c

Please sign in to comment.