[antlr-interest] How to define multi and div?
=?GB2312?B?0MLC8g==?=
inshua at gmail.com
Sat Dec 10 20:04:56 PST 2005
I 'd found this way in samples ,it did not define MULTI and DIV but define
MULTI_DIV : * | /
but in this way , the multi expr and div expr cannot be recognized in the
parser, in the following step, I should test the text of the AST node to
decide how to run the whole expression.
A same rule cannot be split ?
ÔÚ05-12-11£¬Scott Stanchfield <scott at javadude.com> дµÀ£º
>
> Because they have the same precedence, they should really be the same
> rule. For a really good treatment of expressions (if I do say so myself),
> including this exact case , see my ANTLR Tutorial at
>
> http://javadude.com/articles/antlrtut
>
> -- Scott
>
> ------------------------------
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *??
> *Sent:* Saturday, December 10, 2005 10:33 AM
> *To:* antlr-interest at antlr.org
> *Subject:* [antlr-interest] How to define multi and div?
>
>
> I'm studing the expression parsing.
> here I define the multi expr and div expr.
>
> multiExpr
> : (parenExpr | divExpr) (MULTI^ parenExpr)+
> ;
> divExpr
> : (parenExpr | multiExpr) (DIV^ parenExpr)+
> ;
>
>
> this define raised recurse error. thoe in fact, the left of multi expr
> can be div expr.and each other.
>
> can you give me some suggest ?
> thanks~
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20051211/7f659300/attachment.html
More information about the antlr-interest
mailing list