[antlr-interest] Can TokenRewriteStream be applied to rules?

YINGAnnie yimm8369 at hotmail.com
Tue Mar 24 20:08:34 PDT 2009


 

 

Well, I tried it ,but this time the error is : java.lang.NullPointerException.

 

Did I do something wrong?

 

Thanks,

 

 

Annie

 


 


 
> Date: Wed, 25 Mar 2009 08:22:04 +0530
> From: indhu.b at s7software.com
> To: yimm8369 at hotmail.com
> CC: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Can TokenRewriteStream be applied to rules?
> 
> This will work:
> 
> variableStatement
> : VAR? variableDeclaration ( COMMA m=variableDeclaration )* semic
> {tokens.replace($m.start, $m.end, "something else");} &n bsp;
> ;
> 
> $m will be of type variableDeclaration_return which will be subclass of
> 'ParserRuleReturnScope'. $m is not Token.
> 
> 
> - Indhu
> 
> 
> YINGAnnie wrote:
> > Hi again,
> >
> > TokenRewriteStream can only replace the declared token, not the rule.
> > right?
> >
> > for example,If I want to replace VAR, it works fine, But if I want to
> > replace variableDeclaration , the error said $a can not be resolved.
> >
> > variableStatement
> > : m= VAR? variableDeclaration ( COMMA variableDeclaration )* semic
> > {tokens.replace($m, "something else");}
> > ;
> >
> >
> > variableStatement
> > : VAR? variableDeclaration ( COMMA m=variableDeclaration )* semic
> > {tokens.replace($m, "something else");} &n bsp;
> > ;
> >
> > So how can I replace variableDeclaration ?
> >
> > Thanks in advance.
> >
> > Annie
> > ------------------------------------------------------------------------
> > 更多热辣资讯尽在新版MSN首页! 立刻访问! <http://cn.msn.com/>
> > ------------------------------------------------------------------------
> >
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> > 
> 

_________________________________________________________________
上Windows Live 中国首页,下载最新版 MSN!
http://im.live.cn/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090325/e51477d6/attachment.html 


More information about the antlr-interest mailing list