forked from zaach/jison
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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...
- Loading branch information
1 parent
09bf2d1
commit 5672a19
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}; | ||