From fc06f35f9d5d862e2d801e531a05543a7cc1995a Mon Sep 17 00:00:00 2001 From: Erin Dachtler Date: Sat, 8 Apr 2017 01:05:48 -0700 Subject: [PATCH 1/2] compiled-grammar.js is strict mode compatible --- lib/route/compiled-grammar.js | 3 +-- scripts/compile_parser.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/route/compiled-grammar.js b/lib/route/compiled-grammar.js index 58e6c01..50aa823 100644 --- a/lib/route/compiled-grammar.js +++ b/lib/route/compiled-grammar.js @@ -159,8 +159,7 @@ parse: function parse(input) { vstack.length = vstack.length - n; lstack.length = lstack.length - n; } - _token_stack: - var lex = function () { + var lex = function () { var token; token = lexer.lex() || EOF; if (typeof token !== 'number') { diff --git a/scripts/compile_parser.js b/scripts/compile_parser.js index 909bdf6..c40a03e 100755 --- a/scripts/compile_parser.js +++ b/scripts/compile_parser.js @@ -10,7 +10,7 @@ var parser = new jison.Parser(grammar); // eslint-disable-next-line no-underscore-dangle parser.lexer = new Lexer(grammar.lex, null, grammar.terminals_); -var compiledGrammar = parser.generate({ moduleType: 'js' }); +var compiledGrammar = parser.generate({ moduleType: 'js' }).replace(/_token_stack:\s?/, ''); fs.writeFileSync( From ce9e713e4846f86673577a9e9057b480682a1787 Mon Sep 17 00:00:00 2001 From: Erin Dachtler Date: Mon, 17 Apr 2017 11:20:24 -0700 Subject: [PATCH 2/2] Added comments about compile_parser.js changes --- scripts/compile_parser.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/compile_parser.js b/scripts/compile_parser.js index c40a03e..6676421 100755 --- a/scripts/compile_parser.js +++ b/scripts/compile_parser.js @@ -10,6 +10,9 @@ var parser = new jison.Parser(grammar); // eslint-disable-next-line no-underscore-dangle parser.lexer = new Lexer(grammar.lex, null, grammar.terminals_); +// Remove _token_stack label manually until fixed in jison: +// https://github.com/zaach/jison/issues/351 +// https://github.com/zaach/jison/pull/352 var compiledGrammar = parser.generate({ moduleType: 'js' }).replace(/_token_stack:\s?/, '');