[antlr-interest] Article against TreeWalkers
Andy Tripp
antlr at jazillian.com
Wed Mar 8 10:58:51 PST 2006
Jeff Barnes wrote:
>A couple of questions, Andy...
>
>Would it be fair to say that one big switch statement is not as good as an interface?
>
>
I don't think so. I'm not sure how an interface could even replace a big
switch statement in the case I show there, where we're
saying "I'm processing a particular AST node, and here's a huge switch
statement on the node type". I suppose we could
have a bunch interfaces (e.g. "ImABinaryOperatorNode"), and have the AST
node implement one of them, but that
doesn't seem to make things any cleaner to me.
>
>Does the tree grammar "mix languages" anywhere else besides actions and semantic preds? Would a solution that defines constraint and action languages be palatable to you? Or am I being too much of an "Insightful Linguist"?
>
>Andy sez:
>I realized that tree parsing is identical to text parsing, albeit in two dimensions instead of one.
>
>Go ahead and take an few minutes, a few hours, or a full PhD program to really absorb that. I'll wait right here....
>
>Jeff sez:
>
>LOL! I never got that either. To me, a tree seems multi-dimensional; a table is two-dimensional. Terrence??
>
>
>
I see how a tree is 2D, and I can even see how it might be nice to use
the same language to parse the 2D tree that you
used to parse the 1D token stream. But then in practice, I think the two
tasks are different enough that it doesn't help
to use the same language. And this despite the fact that I love that the
one ANTLR language does both lexing and parsing.
>Andy, your disenfranchisement lends credibility to the Tree Grammar.
>
>Regards,
>
>Jeff
>
>
>
>
>
>
More information about the antlr-interest
mailing list