Open murphyke opened 3 years ago
Tried to reproduce with jison-gho 0.6.1-216, but cannot reproduce this issue.
Test code:
examples/issue-58-gho.make.js :
var jison = require('../');
var fs = require('fs');
var path = require('path');
const input = fs.readFileSync('./issue-58-gho.json', 'utf8');
//console.log('load:', input);
const grammar = JSON.parse(input);
const parser = new jison.Parser(grammar);
const source = parser.generate();
fs.mkdirSync('./output/issue-58-gho/', { recursive: true });
fs.writeFileSync('./output/issue-58-gho/code.output.js', source, 'utf8');
and the relevant section in the examples/Makefile:
issue-58-gho:
$(NODE) ./$@.make.js
$(JISON) -n parser --json ./$@.json
$(NODE) ./output/$@/$@.js
diff -u -E ./output/$@/$@.js ./output/$@/code.output.js
result is an *empty diff hence no difference between invoking the jison CLI and the generator code listed above.
Note: the -n
parameter is to override the CLI's auto-naming of the parser object. Without it a few lines differ, but nothing in the parser core, like, say, a damaged rule.
No idea how this could be happening at your place. 🤔
When I use the CLI to create a parser from my grammar, the resulting parser doesn't work properly, but if I use the API and the
generate
method myself to generate a parser, the parser works.I'm posting this for posterity in case it's a real issue, but I'm moving forward with the working parser. Still, if there's something dumb I'm doing with the CLI, I'd like to know. I did verify that the JSON file read by the CLI, when parsed to an object, is identical to the grammar object being used by the "generate" approach.
"Generated" method (good):
CLI (bad):
Here is the diff between "generated" and CLI:
Grammar: