[antlr-interest] ANTLR 3.0ea3 released

Alex Sedow alex at csharpparser.com
Thu Jun 23 22:05:17 PDT 2005


>> ANTLR 2.7.5/2.7.6
>>
>> One thing that I continue to have problems with is the need to walk  up 
>> trees.  Cannot seem to find a getParent() method or a working  example of 
>> how (best) to add this functionality to an ASTNode  override?  Without an 
>> existing getParent, I cannot see a clean way  to provide backlinks in 
>> newly created ASTNodes overrides.  Have I  missed something?
>
> One way to handle this (at least I've tried it years ago) is to call  a 
> method to link everything up doubly *after* the tree has been  built.  I 
> found that the integrity/validity of double-linked trees is  very 
> complicated to keep together. :(
>
> I also found that the need to "look up" is the same as needing to  obtain 
> context information, which usually can be provided via the  grammar and a 
> few variables.

Yes, but what do if you need multiple context informations?
For C# partial types is needed use mutiple AST-contexts depend on placement 
of part declarations in source files. Example:

// file1
using I = I1;
partial class C : I {} // point1
// file2
using I = I2;
partial class C : I {} // point2

Note: all parts of partial type (on type-lookup) must be processed together 
in point1 or in point2.
I think for this case the best way is generate and use pointer to 
AST-parent.

--
Alex



More information about the antlr-interest mailing list