[antlr-interest] A postmortem of my use of antler

Andy Tripp antlr at jazillian.com
Tue Mar 11 12:02:02 PDT 2008


Richard Clark wrote:
> 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.
>   
IMO, "evaulate-and-do" has no reasonable uses. You may call it a "design 
pattern", but
that doesn't make it a good one.

The goal is never to "master ANTLR", but to use ANTLR to get some other 
job done.
> Instructionally, evaluate-and-do is much better than evaluate->AST->do
> (though the latter is preferred by the compiler cognoscenti.)
>   
"Instructionally"? What does that mean? It's better to teach it, so that 
the student learns something
that they didn't know before? That's not a good reason to teach something.
> 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.
>   
Yes, ASTs are great for lots of things. But what is 
"evaluate-as-you-parse" good for, other
than teaching you how to "evaluate-as-you-parse"?
>  ...Richard
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080311/cf58f02f/attachment.html 


More information about the antlr-interest mailing list