don't emit tokens when doing a lookahead
This commit is contained in:
parent
1e398e45ff
commit
c9e7c306cc
@ -18,17 +18,19 @@ var STATE_KEYS = [
|
||||
];
|
||||
|
||||
pp.getState = function () {
|
||||
var state = {};
|
||||
var state = {}
|
||||
for (var i = 0; i < STATE_KEYS.length; i++) {
|
||||
var key = STATE_KEYS[i];
|
||||
state[key] = this[key];
|
||||
var key = STATE_KEYS[i]
|
||||
state[key] = this[key]
|
||||
}
|
||||
return state;
|
||||
return state
|
||||
};
|
||||
|
||||
pp.lookahead = function() {
|
||||
var old = this.getState();
|
||||
this.next();
|
||||
this.isLookahead = true
|
||||
this.next()
|
||||
this.isLookahead = false
|
||||
var curr = this.getState();
|
||||
for (var key in old) this[key] = old[key];
|
||||
return curr;
|
||||
|
||||
@ -28,7 +28,7 @@ const pp = Parser.prototype
|
||||
// Move to the next token
|
||||
|
||||
pp.next = function() {
|
||||
if (this.options.onToken)
|
||||
if (this.options.onToken && !this.isLookahead)
|
||||
this.options.onToken(new Token(this))
|
||||
|
||||
this.lastTokEnd = this.end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user