Here's a simplification of my working EBNF grammar:
%token NEWLINE BLOCK_MARK A
%start file
file: block+ NEWLINE*;
block: BLOCK_MARK line;
line: A+;
Both \n and EOF spit out NEWLINE as a token (so that a single ending NEWLINE isn't required before EOF). It works with a stream like this:
BLOCK_MARK A A BLOCK_MARK A NEWLINE[actually EOF]
Now I want to have several line
in a block
, at least one being mandatory and the rest separated with NEWLINE
. E.g.:
BLOCK_MARK A A NEWLINE A A BLOCK_MARK A A A EOF
I tried doing this:
file: block+ NEWLINE*;
block: BLOCK_MARK line moreline*;
line: A+;
moreline: NEWLINE line;
But Jison complains about a S/R conflict when lookahead is NEWLINE
. I guess the state machine is confused deciding if the NEWLINE
is part of a new block line
or the final NEWLINE*
in file
(which is needed because the file can end with NEWLINE/EOF).
How can I fix this?