zaach/jison — Issue #70: json2jison utility fails parsing examples/calculator.json
Author: jiaweihli
Created: 2011-11-06 19:46:27+00:00
State: open

json2jison examples/calculator.json
jison calculator.jison

throws this error:

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Parse error on line 54:
... {$$ = -$2} %prec UMINUS | '
----------------------^
Expecting ';', '|'
at Object.parseError (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/util/bnf-parser.js:96:11)
at Object.parse (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/util/bnf-parser.js:172:22)
at Object.parse (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/bnf.js:4:54)
at processGrammar (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/cli-wrapper.js:69:36)
at Object.main (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/cli-wrapper.js:48:46)
at Object. (/home/administrator/.node_libraries/.npm/jison/0.2.11/package/lib/jison/cli-wrapper.js:81:13)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)

It seems like '%prec UMINUS' is in the wrong place. It is currently translated as:

| '-' e
{$$ = -$2;} %prec UMINUS

however, the examples/calculator.jison page is written as:

| '-' e %prec UMINUS
{$$ = -$2;}

which works fine.