[antlr-interest] Re: Creating fake tokens

Brad Schick schick at robotbattle.com
Wed May 5 10:54:30 PDT 2004


> I'm not sure what the goal is, but I bet it could be handled in an 
> easier way in the parser:

Thanks both for the info. It does look like building a custom tree 
in the parser is easier. I had thought there might be a simple way 
to do "injectTokens(new array(ELSE, IF));" in the lexer.

Below is what I am using now. Basically the same as your solution 
Mark but with the tree building fixed a bit to make every if contain 
2 SLIST blocks.

else_clause
: ELSE! statement_list
| ELSEIF! LPAREN! expression RPAREN! statement_list else_clause 
    { ## = #(#[SLIST, "SLIST"], #(#[IF, "if"], ##) );}  
| empty 
    { ## = #[SLIST, "SLIST"]; };

Thanks,
-Brad



 
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