zaach/jison — Issue #73: Empty String in Rule causes Error
Author: Searle
Created: 2011-11-17 18:38:00+00:00
State: open

I'm absolutely new to the world of [bj]ison, so I maybe this issue is bogus. I found the following in the PHP yacc file and it fails. I don't know what the authors wanted to happen but it seems to be ok for bison and not ok for jison. So here's the failing grammar:

````
%%

start:
''
| 'for' '(' for_expr ';' for_expr ';' for_expr ')' for_statement.
;

for_expr:
'123'
;

for_statement:
'123'
;

%%
````

The empty string on line 4 causes this error message for me:

````
/WORK/nodejs/lib/node_modules/jison/lib/jison/util/bnf-parser.js:96
throw new Error(str);
^
Error: Parse error on line 6:
...for' '(' for_expr ';' for_expr ';' for_e
-----------------------^
Expecting '%%', 'EOF', 'ID'
at Object.parseError (/WORK/nodejs/lib/node_modules/jison/lib/jison/util/bnf-parser.js:96:11)
at Object.parse (/WORK/nodejs/lib/node_modules/jison/lib/jison/util/bnf-parser.js:172:22)
at Object.parse (/WORK/nodejs/lib/node_modules/jison/lib/jison/bnf.js:4:54)
at processGrammar (/WORK/nodejs/lib/node_modules/jison/lib/jison/cli-wrapper.js:69:36)
at /WORK/nodejs/lib/node_modules/jison/lib/jison/cli-wrapper.js:51:23
at [object Object]. (/WORK/nodejs/lib/node_modules/jison/lib/jison/util/io.js:33:9)
at [object Object].emit (events.js:64:17)
at afterRead (fs.js:1074:12)
at Object.wrapper [as oncomplete] (fs.js:246:17)
````

So there may be a bug here...