Closed suntong closed 2 years ago
From here:
Grouping is very useful to eliminate alternatives. Whereas in BNF the possibility of addition or subtraction might be represented by: <expr> ::= <expr> + <term> | <expr> - <term> EBNF would write: <expr> ::= <expr> (+|-) <expr>
Grouping is very useful to eliminate alternatives. Whereas in BNF the possibility of addition or subtraction might be represented by:
<expr> ::= <expr> + <term> | <expr> - <term> EBNF would write:
<expr> ::= <expr> + <term> | <expr> - <term>
<expr> ::= <expr> (+|-) <expr>
So I tried,
plus : '+' ; minus : '-' ; plus_minus : (plus|minus) ;
But got:
expected one of: . char_lit regDefId [ { (
why is that?
Oh, I should use regular definitions as building blocks, not token definitions, right?
From here:
So I tried,
But got:
expected one of: . char_lit regDefId [ { (
why is that?