[antlr-interest] how to write this rule's tree gramer
antlr_bill
antlr_bill at yeah.net
Thu Oct 15 09:20:02 PDT 2009
Hi ,
I not sure whether I wrote the tree grammer are right , so please take look and give some comments please, that will help a lot.
here is a grammer to parse the java source .
fileDeclaration
: ( (annotations)? packageDeclaration )? (importDeclaration)* (typeDeclaration)*
;
so i defined an imaginary token named FILEDEC and rewrite the tree grammer as
->^( FILEDEC ( (annotations)? packageDeclaration )? (importDeclaration)* (typeDeclaration)* )
because all in the grammer are rules too. so I used an imaginary token here.
but this one below, there is a ',' can be the root of the subtree
expressionList
: expression (',' expression)*
;
so I rewrote the tree as this ,EXP is an imaginary token also
->^(EXP expression (','^ expression)* )
right ? or any better way ? I am really need you help
Thanks a lot
waitting online :)
BILL YUAN
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091016/f5ab16ae/attachment.html
More information about the antlr-interest
mailing list