[antlr-interest] philosophy about translation

Andy Tripp antlr at jazillian.com
Fri Oct 27 10:44:58 PDT 2006


Johnicholas Hines wrote:

> You know,
>
> v + x --> v.add(x)
>
> could be parsed into trees, recognizing v and x as metasyntactic
> variables, with enough tool support.

Right, I'm building a simple tool to do that right now.
But what I'm doing will probably be specific to Java/C/C++ expressions only.

So my main recommendation to Terence is to think about how one could 
build a tool
that does this for any grammar and in a very flexible way (with more 
than just
'v' and 'x' types of placeholders, hooks into code (i.e. "actions"), 
constraints
("only apply this rule at certain points in the AST), etc.

Basically, an alternative to the treewalker approach, for those of us 
who want to
frame the problem as a series of these kinds of rules, as opposed to a 
series of
actions that fire at various points during a tree walk.

>
> If we have a formal notion of "tree transducer" (I'm sure there are
> several definitions, not sure which one Antlr uses), then several of
> these rules could be composed to create one tree transducer. Running a
> single tree transducer over a tree is likely to be faster than the
> "lots and lots of linear searches" that Andy Tripp seems to be
> recommending.

Yes, but I think in general that "faster" at runtime is not a big issue for
high-level-language to high-level-language translators (as opposed to
compilers).

>
> Johnicholas
>



More information about the antlr-interest mailing list