[antlr-interest] Question concerning writing a TreeParser rule

Loring Craymer craymer at warpiv.com
Wed Apr 26 15:47:32 PDT 2006


The corresponding tree rule is

batchExprTree
	:
	#( SEP batchExprTree batchExpr )
	|	batchExpr
	;

Note that the tree annotation essentially inverts the batchExprs (the first
batchExpr encountered when parsing is at the lowest level of the tree)--if
you want to maintain the original order when processing, put actions to the
right of batchExpr in the above rule.

--Loring

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Stritzel.Nils at infineon.com
> Sent: Wednesday, April 26, 2006 2:55 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Question concerning writing a TreeParser rule
> 
> Hi,
> 
> In my parser I have the following rule:
> 
> batchExprList
> 	:
> 	batchExpr (SEP^ batchExpr)*
> 	;
> 
> Which describes a list of expressions separated by "\".
> 
> 
> I could need some advice or pointer to the right place in the
> documentation to figure out, how to implement a TreeParser rule that
> returns an Array or a ArrayList containing the evaluated batchExpr (i.e.
> batchExprList returns [ArrayList r] ).
> Thanks,
> 
> Nils



More information about the antlr-interest mailing list