IMHO, if 'manipulation' means mutating some nodes
(text, type, etc), either one is fine. Our code base
is now over 40k+ lines and we had to write just around
25% of it by hand thanks to tree parser. Writing a
tree walker by hand introduces huge pains later if
you're dealing with a rather painful language (like
we're doing right now) and you need to modify the
grammar file mid way into project.
Now the real problem is when there's a need to
add/remove nodes. The language we're dealing with
allows forward references, functionally same code
written in two styles and other stinky stuff and so
during the multiple passes, we change the tree a LOT.
The real handcap that we have right now is that there
is no easy way in treewalker or anything else that
permits easily adding/removing nodes from a tree.
After even months of pondering I've failed to come up
with a design that can reduce stress on my small team.
Here are somethings that I can recall at 5AM now:
Doubly linked siblings: Must take GREAT care while
removing anything. Also need specialized factory code,
and at loss if the node to be added/removed is first
Vectors etc for children: Increses memory consumption
and every node or something else must keep track of
parent of node being processed.
PS: memory consumption *is* an issue... we expect to
have 100M-1B nodes while processing advertised
capacity inputs!! No, I'm not kidding.
--- Andy Tripp <atripp@...
> >lex/yacc). Writing this code has got me thinking
> about what exactly
> >ANTLR is buying me.
> After all that, you know my opinion: if you've
> already got an AST, just
> write a little code
> to walk it. Embedding your actions in an ANTLR
> treewalker won't buy you
> anything, IMO.
Stay connected, organized, and protected. Take the tour: