Skip to content
This repository has been archived by the owner on Jun 15, 2019. It is now read-only.

Commit

Permalink
defensive coding: fix situations like zaach/jison#358 / handlebars-la…
Browse files Browse the repository at this point in the history
…ng/handlebars.js#1368 in the spurious case where the lexer `parseError()` API is invoked *before* the `setInput()` API is invoked (which would *always* set up a non-NULL (though possibly *empty*) `this.yy` lexer context. (Original jison (https://github.com/zaach/jison) doesn't do the latter either, BTW)
  • Loading branch information
GerHobbelt committed Aug 21, 2017
1 parent 5134fd4 commit 88eecff
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions regexp-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,13 +1338,14 @@ function getRegExpLexerPrototype() {
if (!ExceptionClass) {
ExceptionClass = this.JisonLexerError;
}
if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
return this.yy.parser.parseError(str, hash, ExceptionClass) || this.ERROR;
} else if (typeof this.yy.parseError === 'function') {
return this.yy.parseError(str, hash, ExceptionClass) || this.ERROR;
} else {
throw new ExceptionClass(str, hash);
}
if (this.yy) {
if (this.yy.parser && typeof this.yy.parser.parseError === 'function') {
return this.yy.parser.parseError(str, hash, ExceptionClass) || this.ERROR;
} else if (typeof this.yy.parseError === 'function') {
return this.yy.parseError(str, hash, ExceptionClass) || this.ERROR;
}
}
throw new ExceptionClass(str, hash);
},

/**
Expand Down

0 comments on commit 88eecff

Please sign in to comment.