[antlr-interest] advice for grammar modification
Bryan Ewbank
ewbank at gmail.com
Thu Aug 11 11:38:44 PDT 2005
> > rulename : ( ( rules... )+
> > { actions; } )?
> > ;
>
> This is correct, but to me the next approach sounds better:
>
> > rulename : { boolean doit = false; }
> > ( rules {doit=true;} )*
> > { if(doit) {actions;} }
> Thanks for your answer!
> You're right, the readability is better in the variant with the boolean.
> I'll take that in account for my future work.
Readability is subjective, certainly, but it seems that the ANTLR-only
version is clearer because it's using ANTLR to control flow, rather
than requiring action blocks to do something that is built into the
ANTLR language - something that you must already know if using
ANTLR....
But that's just me :-)
More information about the antlr-interest
mailing list