[antlr-interest] philosophy about translation
Andy Tripp
antlr at jazillian.com
Wed Oct 11 11:11:48 PDT 2006
Loring Craymer wrote:
> I have off and on put a fair amount of thought into rule-based pattern
> match-and-replace systems and how they might relate to ANTLR. ANTLR
> trees with transformations are like a surgeon's scalpel: you can
> locate precisely which parts of a tree need to be changed and change
> them in situ.
What is the in situ Java replacement for "memcpy(a, b, c);"?
How about "char *p"? Is the replacement a String, an array of chars, a
LinkedList of Character,
or maybe an integer index into an array?
How about replacing 10 lines of C code that clearly can be replaced by a
single call to Collections.sort()?
If you're going to have a translation that "works" - has identical
functionality as the original, the
answers may be straightforward. But if you are going to produce code
that looks "hand-written"
(whether identical functionality or not), you're
going to have to take a good look around at the code in order to decide
what should be produced.
If someone's covered these issues in the literature and I just missed
it, let me know.
Andy
More information about the antlr-interest
mailing list