[antlr-interest] parse error because of AST rewrite rules?
Stefan Oestreicher
so at deluxe-design.at
Mon Sep 21 11:51:05 PDT 2009
Hi,
Jim Idle schrieb:
> Do you really mean that, or do you mean:
>
> (type (ASSIGN expression)?) ( COMMA type (ASSIGN expression)?)*
>
Well that's even more fancy but I settle for the simpler variant for now :)
> However, it looks like your simpleVariable and listVariable need left
> factoring (bring all the common things in to one rule and branch alts
> where they differ.
>
Yes you're right. Somehow I didn't see the wood for the trees, thank you
for pointing me into the right direction, the solution is actually quite
simple:
variableDeclaration
: type ID ( ASSIGN expression )?
-> ^(VAR_DEF ID type)
^(ASSIGN ID expression)?
| type first=ID ( COMMA other+=ID )+ ( ASSIGN expression )?
-> ^(VAR_DEF ID type)+
^(ASSIGN $first expression)?
^(ASSIGN $other $first)*
;
Thanks,
Stefan
More information about the antlr-interest
mailing list