[antlr-interest] Labels with multiple alternatives
Monty Zukowski
monty at codetransform.com
Thu Jul 29 15:34:59 PDT 2004
Do something like this:
a:alias1! {##=#(#a,##);}
Note that this will overwrite a's firstChild parameter, so if your rule
had actually returned a tree you will loose everything except the root
node.
Monty
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
On Jul 29, 2004, at 3:18 PM, Joan Pujol wrote:
> 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