[antlr-interest] How can I use 3 predicates in one rule?
YINGAnnie
yimm8369 at hotmail.com
Thu Mar 19 16:17:09 PDT 2009
you mean something like this?
callExpression
: ^(CALL_EXPRESSION memberExpression indexSuffix * propertyReferenceSuffix* argumentSuffix*)
({$memberExpression.text.equals("Math.ceil")}? ->mathceil(x={"int"},y={$argumentSuffix.text}))
({$memberExpression.text.equals("Math.abs")}? ->mathabs(x={$argumentSuffix.text},y={"<0?"},z={"* -1 :"}))
->mathfloor(x={"int"},y={$argumentSuffix.text})
;
It seems does not work.
if I use input like this:
var v1:Number=Math.ceil(1.5);
var v2:Number=Math.floor(1.5);
var v3:Number=Math.abs(1.5);
the output is:
var v1:Number=int(1.5);
var v2:Number=Math.floor(1.5);
var v3:Number=Math.abs(1.5);
So it seems only the first predicate works.
By the way , there is a warning.
(153): with rewrite=true, alt 1 not simple node or obvious tree element; text attribute for rule not guaranteed to be correct
Thanks
Annie
> CC: antlr-interest at antlr.org
> From: parrt at cs.usfca.edu
> To: yimm8369 at hotmail.com
> Subject: Re: [antlr-interest] How can I use 3 predicates in one rule?
> Date: Thu, 19 Mar 2009 14:37:57 -0700
>
> last one must not have predicate
> Ter
> On Mar 19, 2009, at 2:30 PM, YINGAnnie wrote:
>
> >
> > Hi ,
> >
> > What I want todo is to change Math.ceil(1.5),Math.floor(1.5) and
> > Math.abs(1.5) to int(1.5), int(1.5) +1 and nn<0?nn*-1:n.
> >
> > Why I can not use 3 predicates together? What is the right format to
> > do this?
> >
> >
> > callExpression
> > : ^(CALL_EXPRESSION memberExpression indexSuffix *
> > propertyReferenceSuffix* argumentSuffix*)
> > ({$memberExpression.text.equals("Math.ceil")}? -
> > >mathceil(x={"int"},y={$argumentSuffix.text}))
> > ({$memberExpression.text.equals("Math.abs")}? -
> > >mathabs(x={$argumentSuffix.text},y={"<0?"},z={"* -1 :"}))
> > ({$memberExpression.text.equals("Math.floor")}? -
> > >mathfloor(x={"int"},y={$argumentSuffix.text})
> > ;
> >
> > Thanks.
> >
> > Annie
> >
> > 使用新一代 Windows Live Messenger 轻松交流和共享! 立刻下载!
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
_________________________________________________________________
MSN 表情魔法书,改变你的对话时代!
http://im.live.cn/emoticons/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090320/7d6eec3d/attachment.html
More information about the antlr-interest
mailing list