[antlr-interest] leafnode value

ManimuthuLakshmi Pitchaikani antlr_lakshmi at yahoo.com
Sun Oct 10 16:34:11 PDT 2004


direct usage of #procid in 
#stop_stmt = #([STOP,"./killproc"], #procId); //result is not "Hello"

doesn't result in "Hello". 

Also, 

#stop_stmt = #([STOP,"./killproc"], #procId.setText("Hello"));

result in compilation error:

The method add(AST) in the type ASTArray is not applicable for the arguments (void) 
Do we need to define separate subrule for procId?

Monty Zukowski <monty at codetransform.com> wrote:You should use #procid instead of just procid.

Also, why don't you just set the text of the node directly? 
#procid.setText("Hello");

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 Oct 10, 2004, at 1:20 PM, ManimuthuLakshmi Pitchaikani wrote:

> Hi,
>  
> I want to change the value of the leafnode in the result tree.
>  
> The code goes here:
>
> stop_stmt!
>
> {
>
> String strText = "";
>
>
> CommonAST ast;
>
> AST[] ast1 = new AST[2]; // ast1[2];
>
>
> }
>
> : #(stp:STOP procId:PROCID
>
> {
>
> ast1[0] = (CommonAST) procId;
>
> System.out.println("stop procid="+ast1[0]);
>
>
> ast1[0].setText("Hello");
>
>
> procId = (CommonAST) ast1[0];
>
> System.out.println("changed procid="+procId.getText());
>
>
> }
>
> )
>
> {
>
> #stop_stmt = #([STOP,"./killproc"], procId);
>
>
> System.out.println("stop_stmt procId="+procId.getText());
>
>
> }
>
> ;
>
> Am getting the value of procId as "Hello" only in System output.  But 
> in the tree, the value is not getting changed.  Why?
>
> Thanks.
>
> Best Regards,
>
> Lakshmi
>
>  
>  
>  
>  
>
> Do you Yahoo!?
> vote.yahoo.com - Register online to vote today!
>
> 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 the Yahoo! Terms of 
> Service.
>
> 

		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20041010/1fd9b327/attachment.html


More information about the antlr-interest mailing list