[antlr-interest] partial tree rewrites

Gavin Lambert antlr at mirality.co.nz
Thu Jul 16 12:53:14 PDT 2009


At 02:10 17/07/2009, Benoit Fouletier wrote:
>(VAR ID -> VAR ID)
>(
>ASSIGN INT
>->COLON TYPE["int"] ASSIGN INT
>|ASSIGN StringValue
>->COLON TYPE["string"] ASSIGN StringValue
>)
>
>Do I have the syntax wrong, or are partial rewrites simply not 
>possible?

A rewrite always sets the output of the entire rule.  You cannot 
use it for only part of the rule.  This is important for iterative 
rules which need to build up a nested chain of nodes.

(A workaround is to move the bit that you want to do a partial 
rewrite for into a subrule.)



More information about the antlr-interest mailing list