[antlr-interest] Reduction in code base after yanking AST stuff

Terence Parr parrt at cs.usfca.edu
Tue Jan 3 16:35:41 PST 2012


On Jan 3, 2012, at 5:25 AM, Eric wrote:

> Ter,
> 
>> From my personal perspective I commend the decision. While I know that AST
> rewrites have been a personal work of yours for years, I am sure it took a
> lot to make the move.

It's important to admit when you've been going in the wrong direction, no matter how painful. I'm just embarrassed I didn't see this point earlier. most (but not all) of the applications I've built over the last decade or two would have been easier with listeners

> When looking at the pipeline as Lexer -> Parser -> Tree manipulation (v3,
> AST rewrite vs v4 SAX, DOM, visitor) -> Output (String Template),
> I have had the most trouble with AST rewrite, and routinely resorted to
> doing tree manipulation via calls to the API.  I even notice mention in v4
> of outputting the tree in LISP format using toStringTree(), though I
> haven't tested it yet. While I have tinkered with converting the
> s-expressions to LISP or PROLOG in v3 and then manipulating, that is a
> route I plan to explore more with v4. Also of note here would be
> http://strategoxt.org/

Yeah, those guys are very smart and it's a cool tool.

> As a hint to Sam Harwell, I have considered creating an F# library for the
> tree manipulation phase for the C# target for v4.
> 
> I hope that once users see how to make effective use of the new ways of
> doing tree manipulations, more ideas will come out on how to effectively
> apply the new mechanisms.

Yep, I'm interested to know what people think about rewriting parse trees. certainly that's what most of the European tools do.

Ter


More information about the antlr-interest mailing list