[antlr-interest] ANTLR 3.0ea3 released

Gerald B. Rosenberg gbr at newtechlaw.com
Fri Jun 24 11:12:28 PDT 2005


At 09:33 AM 6/24/2005, Terence Parr wrote:


>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.

Interesting.  That is effectively a getParent.

>Remember
>that when you want to look up, you mean you want to know your
>context.  To me context means what rules led to this rule and what
>input did they start with.

Yes, and in most nicely structured cases just the one above.

>For recursive stuff, you need a stack of
>these pointers...

Now we are back to custom data structures to hold what the tree already 
holds.  Further, context may need to be determined not by the entire set of 
prior rules/nodes -- some could be irrelevant or, worse, misleading as to 
the correct context.  So, either I work through this custom stack and with 
a bunch of custom code to worry out the details of the context or I define 
a tree-walker that automatically recognizes the relevant nodes and, in a 
nicely structured manner, identifies context.  Seems like the latter would 
be the best use of the strengths of ANTLR.

Your node pointer idea may provide a workable alternative.  If, from a 
current node, I can adequately guess which is the applicable context 
defining start node, I can just start the context-recognition tree-walker 
there, terminating on the current node.  Still, the only certainty as to 
current context logically requires starting the context-recognition 
tree-walker in reverse from the current node.
----
Gerald B. Rosenberg, Esq.
NewTechLaw
285 Hamilton Avenue, Suite 520
Palo Alto, CA  94301-2576

650.325.2100  (office)  /  650.703.1724  (cell)
650.325.2107  (fax)

www.newtechlaw.com




More information about the antlr-interest mailing list