Skip to content

Commit 5672a19

Browse files
committed
add another test/example grammar which fails in vanilla jison. Copied from BNFC/bnfc#132. Related to zaach#205: reduce/reduce conflict in jison, not in bison...
1 parent 09bf2d1 commit 5672a19

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

examples/issue-bnfc-132.jison

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// see https://github.com/BNFC/bnfc/pull/132
2+
// related to https://github.com/zaach/jison/issues/205
3+
//
4+
// reduce/reduce conflict in jison, not in bison...
5+
6+
%lex
7+
8+
%%
9+
\s+ /* skip whitespace */
10+
foo return 'foo';
11+
bar return 'bar';
12+
13+
/lex
14+
15+
%start BAR
16+
17+
%%
18+
19+
BAR : FOO "bar" | ;
20+
FOO : | "foo" ;
21+
22+
%%
23+
24+
25+
26+
27+
// feature of the GH fork: specify your own main.
28+
//
29+
// compile with
30+
//
31+
// jison -o test.js --main that/will/be/me.jison
32+
//
33+
// then run
34+
//
35+
// node ./test.js
36+
//
37+
// to see the output.
38+
39+
var assert = require("assert");
40+
41+
parser.main = function () {
42+
var rv = parser.parse("a(b, c)");
43+
console.log("a(b, c) ==> ", rv);
44+
assert.equal(rv, "a:([\"b\",[[\",\",\"c\"]]])");
45+
46+
var rv = parser.parse("a(b)");
47+
console.log("a(b) ==> ", rv);
48+
assert.equal(rv, "a:([\"b\",[]])");
49+
50+
51+
// if you get past the assert(), you're good.
52+
console.log("tested OK");
53+
};
54+

0 commit comments

Comments
 (0)