Make onToken only fire for actual final tokens

Issue #189
This commit is contained in:
Marijn Haverbeke 2015-01-04 22:13:18 +01:00
parent 431a44bc74
commit e271168cf6
2 changed files with 5 additions and 7 deletions

View File

@ -634,9 +634,6 @@
if (shouldSkipSpace !== false) skipSpace();
tokVal = val;
tokRegexpAllowed = type.beforeExpr;
if (options.onToken) {
options.onToken(new Token());
}
}
function skipBlockComment() {
@ -1232,6 +1229,9 @@
// Continue to the next token.
function next() {
if (options.onToken)
options.onToken(new Token());
lastStart = tokStart;
lastEnd = tokEnd;
lastEndLoc = tokEndLoc;
@ -1542,9 +1542,7 @@
first = false;
}
lastStart = tokStart;
lastEnd = tokEnd;
lastEndLoc = tokEndLoc;
next();
return finishNode(node, "Program");
}
@ -2664,5 +2662,4 @@
node.generator = isGenerator;
return finishNode(node, "ComprehensionExpression");
}
});

View File

@ -28757,6 +28757,7 @@ var tokTypes = acorn.tokTypes;
test('var x = (1 + 2)', {}, {
locations: true,
loose: false,
onToken: [
{
type: tokTypes._var,