[antlr-interest] Philosophical: How to collect data in AST traversal

Bryan Ewbank ewbank at gmail.com
Fri Apr 29 02:38:04 PDT 2005


Hi Oliver,

After some exploration, I ended up adding a hash table to my AST node
type; since I'm in C++, I used string as a key and return a "void*"
which I can cast to whatever I need.  This allows arbitrary
information anywhere in the tree.

Another way is - as you say:
- Return values for inherited attributes (up the tree), and
- Parameters for synthesized attributes (going down the tree)

I did this in some places where the information is more local.

There was a discussion on the list a while back about keeping track of
information - might be some good data there for you as well.

- B

On 4/29/05, Oliver Zeigermann <oliver.zeigermann at gmail.com> wrote:
> So I was wondering why not just
> modifying class memebers from all rules that contain wanted data. I
> know this may end up in the "global variables are evil" argument, but
> I was just wondering how others are dealing with this.
> 
> Thanks for any comments
> 
>   Oliver
>


More information about the antlr-interest mailing list