[antlr-interest] customize the AST

Mr Torsten Curdt tcurdt at yahoo.com
Sun Jun 20 07:39:12 PDT 2004


> I have the following rule and want to create
> a customized AST
> 
> instruction!
>   : k:LITERAL COLON! v:(LITERAL|QLITERAL) NEWLINE!
>   | kk:LITERAL COLON! k1:(LITERAL|QLITERAL) ASSIGN!
> v1:(LITERAL|QLITERAL) (SEMICOLON!
> k2:(LITERAL|QLITERAL) (ASSIGN!
> v2:(LITERAL|QLITERAL))?)* NEWLINE!  

I know figured out that the #([..]) syntax can
also be nested. So customizing the AST tree is
no longer a problem.

But I found that "v:(LITERAL|QLITERAL)" is
not working. I had to split this into

 (l:LITERAL|q:QLITERAL)

and then check with code

 if (l!=null) {
   ...
 }
 if (q!=null) {
   ...
 }

Is there a more elegant way of doing this?
The null-check really bloats the code section.
Especially if you have to do it more than just
once.

cheers
--
Torsten


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list