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

Commit

Permalink
Check whether a *sane* condition has been pushed before: this makes t…
Browse files Browse the repository at this point in the history
…he lexer robust against user-programmer bugs such as zaach#19
  • Loading branch information
GerHobbelt committed Feb 10, 2017
1 parent 9e93392 commit 57dd804
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions regexp-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,13 @@ var __objdef__ = {
// invoke the `lex()` token-producing API and related APIs, hence caching the set for direct access helps
// speed up those activities a tiny bit.
spec = this.__currentRuleSet__ = this._currentRules();
// Check whether a *sane* condition has been pushed before: this makes the lexer robust against
// user-programmer bugs such as https://github.com/zaach/jison-lex/issues/19
if (!spec || !spec.rules) {
var p = this.constructLexErrorInfo('Internal lexer engine error on line ' + (this.yylineno + 1) + '. The lex grammar programmer pushed a non-existing condition name "' + this.topState() + '"; this is a fatal error and should be reported to the application programmer team!\n', false);
// produce one 'error' token until this situation has been resolved, most probably by parse termination!
return (this.parseError(p.errStr, p) || this.ERROR);
}
}

var rule_ids = spec.rules;
Expand Down

0 comments on commit 57dd804

Please sign in to comment.