[antlr-interest] Labels with multiple alternatives

Joan Pujol joanpujol at gmail.com
Thu Jul 29 15:18:44 PDT 2004


Hi,

I'm doing a compiler for a catalan pseudocode. In catalan "or" is 'o'
and "and" is "i".

I don't defined "i" and "o" as tokens in the Lexer because then I
can't use it as variables.
Instead I use two rules in the Parser:

ilogic:		{LT(1).getText().equals("i")}? {LT(1).setType(OPILOGIC);} IDENT ;
ologic:	       {LT(1).getText().equals("o")}? {LT(1).setType(OPOLOGIC);} IDENT;


Then when I use it in the expression rule I have:

exp1:		exp2 ( (ilogic|ologic) exp2)*

And the question is, what is the better method to make the operator
(ilogic or ologic) the root.

I have seen that you can't use the same label for the two rules, and
you can't use the ^ because there are not tokens but rules.


-- 
Joan Jesús Pujol Espinar


 
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