From b7d6e0de7d2c2c1bde5451b8e99813843a473315 Mon Sep 17 00:00:00 2001 From: Erin Dachtler Date: Sat, 8 Apr 2017 12:34:04 -0700 Subject: [PATCH] Always remove the token stack label _token_stack label was only removed when `token-stack` option was present. --- lib/jison.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/jison.js b/lib/jison.js index d078056ee..866a51e8d 100755 --- a/lib/jison.js +++ b/lib/jison.js @@ -1092,12 +1092,16 @@ function addTokenStack (fn) { labeled[0].body = stackAst; - return escodegen.generate(ast).replace(/_token_stack:\s?/,"").replace(/\\\\n/g,"\\n"); + return escodegen.generate(ast); } catch (e) { return parseFn; } } +function removeTokenStackLabel(code) { + return code.replace(/_token_stack:\s?/,"").replace(/\\\\n/g,"\\n"); +} + // lex function that supports token stacks function tokenStackLex() { var token; @@ -1143,6 +1147,8 @@ lrGeneratorMixin.generateModule_ = function generateModule_ () { if (this.options['token-stack']) { parseFn = addTokenStack(parseFn); } + + parseFn = removeTokenStackLabel(parseFn); // Generate code with fresh variable names nextVariableId = 0;