[antlr-interest] TreeParser rule specification efficiency

micheal_jor open.zone at virgin.net
Tue May 18 09:37:07 PDT 2004


Consider the following rule that matches the AST [sub]tree for a
dotted string:

dottedString
    :    ( IDENT
         | DOT IDENT dottedString
         )
    ;

This is a concise and elegant specification but it employs recursion
and the generated code would be similarly recursive.

Is there a way to specify the same rule such that it would use
iteration rather than recursion to recognize ASTs for a dotted string.
Sample ASTs are:

    #( IDENT )
    #( DOT IDENT IDENT )
    #( DOT IDENT #( DOT IDENT #( DOT IDENT IDENT ) ) )

Cheers,

Micheal



 
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