Skip to content

Commit

Permalink
Always remove the token stack label
Browse files Browse the repository at this point in the history
_token_stack label was only removed when `token-stack` option was present.
  • Loading branch information
download13 authored Apr 8, 2017
1 parent 7653842 commit b7d6e0d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/jison.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b7d6e0d

Please sign in to comment.