Hi Jim,

 

The weird thing is if I use the $rule1.tree directly, the generated code
would try to convert the rule1_return structure to common token type
first, but if I assign the rule to a variable, say P: r1=Rule1 Rule2;
then using $r1.tree would be completely fine, as the generated  code
would just keep the rule1_return structure, not trying to convert it at
all.

 

Can you see why it works this way? Thanks a lot.

Linlin

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Xie, Linlin
Sent: 11 May 2009 10:19
To: Jim Idle
Cc: [email protected]; Fitt, Andrew; Hamid, Nusrat
Subject: Re: [antlr-interest] How to pass the current node to the
action?

 

Hi Jim,

 

Thank you very much for your reply. I tried with the .tree solution you
suggested, but got errors like "error C2440: 'type cast' :  cannot
convert from 'p_return' to 'pANTLR3_COMMON_TOKEN'." I can see that you
are trying to use the common token structure, but the way to get the
common token of current node doesn't seem to work. 

 

Is there anything I did wrong? Do you have any idea why it's not
working? Thanks again.

Linlin

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Jim Idle
Sent: 09 May 2009 17:49
Cc: [email protected]
Subject: Re: [antlr-interest] How to pass the current node to the
action?

 

Xie, Linlin wrote: 

Sorry, I didn't give a subject to my last question. Below is the
details, can anybody help me out?

 

I presume that you mean:

p: r1 r2

In which case you need to use one of:
$tree
$p.tree
$p
$r1.tree
$r2.tree

But I can't tell you which from the code you show, but you should be
able to work that out. Also, don't forget the search on the ANTLR home
page, or the Wiki

Jim


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to