diff --git a/Makefile b/Makefile index 4787d4b8a..2aef795b6 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ -all: build test examples/issue-293 -# examples/issue-254 +all: build test examples/issue-293 examples/issue-254 prep: npm-install diff --git a/examples/issue-254.jison b/examples/issue-254.jison index caccae077..26d12f623 100644 --- a/examples/issue-254.jison +++ b/examples/issue-254.jison @@ -14,28 +14,44 @@ /lex -%start function_call +%start test %% +test + : function_call + { + //console.log("result: ", $function_call); + return $function_call; + } + ; + + function_call : IDENTIFIER ("(" (expression[e1] ("," expression[e2])* )? ")") { console.log($1); console.log($3); - console.log($e1); - $$ = $IDENTIFIER + ':' + $e1; - try { - if ($5) { - console.log($5); - } - if ($e2) { - console.log($e2); - } - $$ += ':' + $e2; - } catch (e) { - console.log("exception"); - } + // unreachable; injected a dot to prevent the action inspector from still seeing this one: + //console.log($.e1); + //$$ = $IDENTIFIER + ':' + $.e1; + //try { + // if ($.5) { + // console.log($.5); + // } + // if ($.e2) { + // console.log($.e2); + // } + // $$ += ':' + $.e2; + //} catch (e) { + // console.log("exception"); + //} + + // new code: + // + // IDENTIFIER "(" q_container ")" + // 1 2 3 4 + $$ = $IDENTIFIER + ':' + $2 + JSON.stringify($3) + $4; } ; @@ -63,10 +79,12 @@ var assert = require("assert"); parser.main = function () { var rv = parser.parse("a(b, c)"); console.log("a(b, c) ==> ", rv); + assert.equal(rv, "a:([\"b\",[[\",\",\"c\"]]])"); + var rv = parser.parse("a(b)"); console.log("a(b) ==> ", rv); + assert.equal(rv, "a:([\"b\",[]])"); - assert.equal(rv, "a(a(a))"); // if you get past the assert(), you're good. console.log("tested OK");