=?gb2312?q?Re=A3=BA=20Re:=20[antlr-interest]=20Could=20anyone=20give=20an?= =?gb2312?q?=20example=20fo=20making=20a=20linked=20list=20using=20antlr=3F?=

=?gb2312?q?=CB=EF=BC=CD=B8=D5=20Jigang=20(Robert)=20Sun?= sunjigang1965 at yahoo.com.cn
Mon Feb 20 17:07:41 PST 2006


Thank you Bryan.

Your solution works. But I could not find explanation
for ## in Tree Construction section of Antlr 2.7.6
manual. Could anyone tell me the reference address?

Jigang 

--- Bryan Ewbank <ewbank at gmail.com>Wrote:

> I'm guessing here that what you mean is a single
> node with all the
> "exp" nodes under it, rather than a tree of COMMA
> nodes, each with two
> children.
> 
> > Could anyone give an example for making a linked
> list using antlr?
> >
> > My grammar is
> >	explist: exp (COMMA^<AST=ExpList> exp)* ;
> 
> This will, as you probably know, produce a
> left-to-right tree.
> 
> To produce a single-level tree, use this instead:
> 
> 	explist: exp (COMMA! exp)* { ## = #( #[EXPLIST], ##
> ); }
> 
> To produce a right-to-left tree (for exponentiation,
> e.g.):
> 
> 	explist : exp ( POWER^ explist )? ;
> 



	

	
		
___________________________________________________________ 
ÑÅ»¢1GÃâ·ÑÓÊÏä°Ù·Ö°Ù·ÀÀ¬»øÐÅ 
http://cn.mail.yahoo.com/


More information about the antlr-interest mailing list