[antlr-interest] LPG WAS Retaining comments
Olivier Lefevre
lefevrol at yahoo.com
Tue Mar 18 16:02:19 PDT 2008
Olivier Lefevre wrote:
> I still think it useful to think of the parse tree as something the tool will
> build for you automatically (if you ask it to) whereas the AST is
> something _you_ must build, making _all_ the decisions.
To elaborate just a tiny bit, you might say this is a superficial
difference but if you ask a tree from the tool it will of necessity return
a parse tree because that's the only thing it can return (it can't possibly
know what kind of AST you want) whereas if you build the tree you will,
well, not "of necessity" but almost certainly build an AST of sorts,
reflecting your post-processing needs and thus the semantics of the
language. Thus in practice the parse tree vs. AST divide tends to overlap
neatly with the by-default vs. explicitly built divide.
-- O.L.
More information about the antlr-interest
mailing list