diff --git a/lib/jison.js b/lib/jison.js index 2efb018d1..798c40412 100644 --- a/lib/jison.js +++ b/lib/jison.js @@ -1087,7 +1087,7 @@ parser.parse = function parse (input) { shifts++; stack.push(symbol); - vstack.push(null); // semantic values or junk only, no terminals + vstack.push(this.lexer.yytext); // semantic values or junk only, no terminals stack.push(a[1]); // push state if (!preErrorSymbol) { // normal execution/no error yyleng = this.lexer.yyleng; diff --git a/tests/parser/actions.js b/tests/parser/actions.js index f6997e58c..e671f02b7 100644 --- a/tests/parser/actions.js +++ b/tests/parser/actions.js @@ -43,7 +43,7 @@ exports["test return null"] = function() { assert.equal(parser.parse('x'), null, "semantic action"); }; -exports["test terminal semantic values are null"] = function() { +exports["test terminal semantic values are not null"] = function() { var lexData = { rules: [ ["x", "return 'x';"], @@ -52,7 +52,7 @@ exports["test terminal semantic values are null"] = function() { }; var grammar = { bnf: { - "E" :[ ["E x", "return [$2 === null]"], + "E" :[ ["E x", "return [$2 === 'x']"], ["E y", "return [$2]"], "" ] } @@ -62,7 +62,7 @@ exports["test terminal semantic values are null"] = function() { parser.lexer = new RegExpLexer(lexData); assert.deepEqual(parser.parse('x'), [true], "semantic action"); - assert.deepEqual(parser.parse('y'), [null], "semantic action"); + assert.deepEqual(parser.parse('y'), ['y'], "semantic action"); }; exports["test Semantic action stack lookup"] = function() {