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.
added example/test code for issue zaach#387
- Loading branch information
1 parent
26f84ca
commit d8153dc
Showing
2 changed files
with
55 additions
and
1 deletion.
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
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,48 @@ | ||
/* lexical grammar */ | ||
%lex | ||
%% | ||
|
||
\s+ /* skip whitespace */ | ||
"constructor" return 'constructor' | ||
<<EOF>> return 'EOF' | ||
. return 'INVALID' | ||
|
||
/lex | ||
|
||
/* operator associations and precedence */ | ||
|
||
%start expressions | ||
|
||
%% /* language grammar */ | ||
|
||
expressions | ||
: "constructor" EOF | ||
{return "constructor";} | ||
; | ||
|
||
|
||
%% | ||
// 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('constructor'); | ||
console.log("test #1: 'constructor' ==> ", rv, parser.yy); | ||
assert.equal(rv, 'constructor'); | ||
// if you get past the assert(), you're good. | ||
console.log("tested OK"); | ||
}; | ||