[antlr-interest] philosophy about translation

Monty Zukowski monty at codetransform.com
Fri Oct 6 12:28:09 PDT 2006


>
> Here's my alternative:
> I have hundreds of "transformation rules" where each rule can either be
> a simple mapping like this:
> ADD v1 TO v2. --> v2 += v1;
> ADD v1 v2 TO v3 v4. --> v3 += v1 + v2; v4 += v1 + v2
> ADD v1 TO v2 GIVING v3.  --> v3 = v1 + v2;
>
> ...or actual Java code that operates on sequences of tokens, not trees.
> I find it easier to think of the source and target languages as
> sequences of tokens
> ("ADD" followed by a variable followed by "TO"...) rather than trees (an
> "ADD" node
> with the first child being a variable and the second child being "TO"...)
>

Interesting.  So do you actually work directly with tokens, or do you
write grammars to parse your token streams and emit yet another token
stream, or do you have your own token matching language you write your
rules in?

Monty


More information about the antlr-interest mailing list