[antlr-interest] help on rewritting the tree

antlr_bill antlr_bill at yeah.net
Sun Oct 4 10:06:43 PDT 2009


Hi Jim, thanks for you quick reply !

do you mean i should break them into pieces ?
cause the tree structure only can have two children in maximum

if so ,so how about this one? break them too ? 

javaSource
    :   (packageDeclaration)? (importDeclaration)* (typeDeclaration)*
    ->^(V packageDeclaration? importDeclaration* typeDeclaration*)
    ;

here means the java source file can contain  package and import and type ,three kinds of element 
but i wrote that tree like that , is it right ?

any article about this ? i read the book of antlr many times on the tree grammer ,but still didnt get all of it 

thanks again!


BILL


在2009-10-05,"Jim Idle" <jimi at temporal-wave.com> 写道: -----原始邮件-----
发件人:"Jim Idle" <jimi at temporal-wave.com>
发送时间:2009年10月5日 星期一
收件人:"antlr-interest at antlr.org" <antlr-interest at antlr.org>
主题:Re: [antlr-interest] help on rewritting the tree



a: b -> ^(V b) ;

 

b : part (DOT^ part )* ;

 

part:  ID( ABC )? ;

 

Jim

 

From:antlr-interest-bounces at antlr.org[mailto:antlr-interest-bounces at antlr.org]On Behalf Ofantlr_bill
Sent:Sunday, October 04, 2009 8:56 AM
To:antlr-interest at antlr.org
Subject:[antlr-interest] help on rewritting the tree

 

can someone please help on this ?
i have an rule like this :

a:
 :   ID( ABC )? (DOT ID (ABC)? )*
;
how to rewrite it into a tree grammer ?

 

 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091005/0f5a29bc/attachment.html 


More information about the antlr-interest mailing list