[antlr-interest] A postmortem of my use of antler
Richard Clark
rdclark at gmail.com
Tue Mar 11 11:35:30 PDT 2008
On Tue, Mar 11, 2008 at 11:18 AM, Andy Tripp <antlr at jazillian.com> wrote:
> I really don't like the book example of evaluating an expression with
> ANTLR. Better to build an AST as one step, and then evaluate the
> expression by walking the AST as a distinct step.
Except that evaluate-and-do is a common (and powerful) design pattern
with ANTLR. Working via an AST is other powerful design pattern. They
both have their uses; knowing when to use which is a key skill for
mastering ANTLR.
Instructionally, evaluate-and-do is much better than evaluate->AST->do
(though the latter is preferred by the compiler cognoscenti.)
Folks who have taken a compiler class tend to prefer ASTs because they
fit what a compiler does (parse, transform, emit.) Emitting an AST is
also great for taking multiple variations on a phrase and reducing it
into a standard expression before emitting a value or performing an
action.
...Richard
More information about the antlr-interest
mailing list