[antlr-interest] Problem with rewrite rules with optional non-terminals
David Jameson
dhjdhj at gmail.com
Thu Mar 26 10:46:34 PDT 2009
I have the following grammar fragment
refTag :
LSQUARE a=expression (COMMA b=expression)? RSQUARE
{
//stuff
} -> ^(REFTAG $a $b)
;
However, if I feed in source that does NOT have the optional comma
expression clause, the parser crashes because it blindly tries to
dereference the stream_b object.
How can I test whether there was an optional expression and control
the rewrite rule accordingly to include the $b or not?
Thanks,
D
More information about the antlr-interest
mailing list