Closed m99coder closed 6 years ago
1- Install JISON globally:
npm -g install jison
Above command will publish JISON as a CLI tool.
2- Write the grammar and the lexer, both could be in the same fils or separated by %%
symbol, then run:
// if grammax and parser are in separated files
jison ./path/to/grammar.y ./path/to/lexer.l -o parser.js -m commonjs
// if grammar and lexer are in the same file
jison ./path/to/grammar.y -o parser.js -m commonjs
Above commands will generate the parser to parser.js
file with commonjs
module format.
You can use the generated file by doing var myParser = require('parser.js')
I already installed jison
globally. But I modified src/jison.js
and want to test this version inside of the current project. Would it help if I would dismiss the -g
flag?
Try node path/to/jison/lib/cli.js ...
I tried to export as AngularJS module and therefore added this commit to my own fork of jison: https://github.com/m99coder/jison/commit/66756fdf500d137f7d9e9df04b216c27647ed571. I used the following command line:
$ node lib/cli.js examples/calculator.jison -o ./calculator.js -m angular
The output isn’t an AngularJS module.
There still is an open pull request for this repository https://github.com/zaach/jison/pull/286. But it probably will never be merged :/
In a first glance at that commit I think the problem is the fallthroug in the line 940. Actually if angular
is specified the generated module is in amd
format, right? So, you should insert a break;
statement just after the line number 940.
🙈 Oh man. You are so right. Now it works as expected. Thanks a lot.
@m99coder close issue if solved
But I couldn’t figure out how to build such a binary artefact. Neither the
Makefile
nor any npm script (or build target mentioned inpackage.json
) probably do the trick.Could you please explain how to get a binary artefact?