[antlr-interest] ANTLR 3.0ea3 released

Andy Tripp atripp at jazillian.com
Fri Jun 24 14:01:55 PDT 2005


>
>
>On Jun 24, 2005, at 8:18 AM, Gerald B. Rosenberg wrote:
>> Even where carry forward would work, look-back may simply be a  
>> cleaner conceptual model in some situations.
>
>hi.  My experience is that if you need to look back, it's just as  
>easy to keep a ptr in each rule of interest you enter so you can  
>simply ask for the tree location for the rule above you. 
>
Doesn't that mean that in general, you have to keep a ptr for 
essentially all rules?
In other words, if I want to know if the current statement is somewhere 
within a
"for" block, I need to keep a ptr at each rule in which I might end up 
with an AST
that has a "statement" somewhere under a "for".

That seems a lot more difficult than just overriding CommonAST to 
provide a parent and
being done with it.

> Remember  
>that when you want to look up, you mean you want to know your  
>context.  
>
Not always. I often had to look at other places in the AST, and a stack 
with the current
context wouldn't have done it. For example, when manipulating C code, I 
see a "%d"
somewhere, look up the tree for the "printf" node, and then look down 
for the appropriate
child to get the "printf" argument that matches my "%d". Context is not 
enough.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050624/9f3d712d/attachment.html


More information about the antlr-interest mailing list