Empty production alternative error
suntong opened this issue · comments
Hi,
I'm trying to understand the error of
Parse error: Error: $(0) @ xx:yy empty production alternative: Maybe you are missing the "empty" keyword in ...
This is not OK:
Term
: _digit { _digit }
| ident
//| empty
;
Even if I unquote and get that | empty
rule in.
However, the following two cases are all OK:
Term
: digits
| ident
//| empty
;
// without the "empty" keyword in Term is still OK
Term
: _digit { _digit }
: digits
| ident
//| empty
;
// without the "empty" keyword in Term is still OK
I.e., why the first case fails and why the 3rd case even works doesn't make much sense to me, and I had been having a hard time trying to come up with answers myself. please help. thx!
Figured out why the first case is not allowed as
"regular definitions are used as building blocks for other regular definitions, token definitions and ignored token definitions.", i.e., not for building Syntax production identifiers, right?
But still don't understand why the 3rd case even works.
I think the _
indicates that you can only use it in other lower case (syntactic) rules.
But it has been a while, so this is only a guess.
Ok, thanks for helping!