[antlr-interest] How to handle rewrite of multiple nodes

John B. Brodie jbb at acm.org
Tue Mar 29 19:27:04 PDT 2011


Greetings!

On Wed, 2011-03-30 at 12:43 +1100, Simon wrote:
> Hello all,
> 
> I have a grammar that does a rewrite like so:
> 
>   bracketedBlock
>       : '{' stmts=statement* '}' -> ^(Block $stmts)
>       ;
> 
you are not properly handling the cardinality of the * meta-operator.

try:

bracketedBlock : '{' statement* '}' -> ^(Block statement*) ;

or:

bracketedBlock : '{' stmts+=statement* '}' -> ^(Block $stmts} :



Hope this helps...
   -jbb




More information about the antlr-interest mailing list