[antlr-interest] how to deal with optional parameters in ast
Gavin Lambert
antlr at mirality.co.nz
Tue Mar 27 12:36:34 PDT 2007
At 02:56 28/03/2007, Dave Cramer wrote:
>I have a rule which is
>
>WAKEUP expr*NEWLINE-> ^(WAKEUP expr*)
>
>if the input is
>
>WAKEUP NEWLINE
>
>the ast will just be ^ WAKEUP
>
>What's the right way to deal with this ?
That seems correct to me. What were you wanting it to do instead?
If WAKEUP is always supposed to have a parameter, then you should
change * to + in both places. If it's allowed to have no
parameters, then what you have already seems like the best option
(assuming your description is correct).
More information about the antlr-interest
mailing list