Skip to content

Commit

Permalink
add another test/example grammar which fails in vanilla jison. Copied…
Browse files Browse the repository at this point in the history
… from BNFC/bnfc#132. Related to zaach#205: reduce/reduce conflict in jison, not in bison...
  • Loading branch information
GerHobbelt committed Jun 15, 2018
1 parent 09bf2d1 commit 5672a19
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/issue-bnfc-132.jison
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// see https://github.com/BNFC/bnfc/pull/132
// related to https://github.com/zaach/jison/issues/205
//
// reduce/reduce conflict in jison, not in bison...

%lex

%%
\s+ /* skip whitespace */
foo return 'foo';
bar return 'bar';

/lex

%start BAR

%%

BAR : FOO "bar" | ;
FOO : | "foo" ;

%%
// feature of the GH fork: specify your own main.
//
// compile with
//
// jison -o test.js --main that/will/be/me.jison
//
// then run
//
// node ./test.js
//
// to see the output.
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\",[]])");
// if you get past the assert(), you're good.
console.log("tested OK");
};

0 comments on commit 5672a19

Please sign in to comment.