[antlr-interest] Re: thoughts on source-to-source workshop at oopsla 2004

atripp54321 atripp at comcast.net
Wed Oct 27 11:23:40 PDT 2004



--- In antlr-interest at yahoogroups.com, Anakreon <anakreonmejdi at y...>
wrote:
> > like a nightmare. So after several months work, I gave up on
> > AST-to-AST translation and came up with my own system
> > (described briefly here: http://jazillian.com/design.html)
> Really interesting approach. I have two problems similar with those
> you point to the web page. The goto (for vb) which PHP does not support
> and the comments reassignment. I used a system similar with the code
> snippets you mention. I use XML because I need to describe classes.
> 
> I wonder though, is the Token stream approach powerful enough?
> For example if you have the code snippet:
> someMethod(x) -> translation
> and there are two overloaded version of someMethod say:
> someMethod(char c) and someMethod(uint c)
> how can you provide a different translation for those cases?

I would just write two rules, one that matches:
v1(char v2) {
...and the other that matches:
v1(uint v2) {

The first would match any method that takes a single "char" arg
The "v1" and "v2" are placeholders. And this pattern:
v1(x) {
...would match any method declaration at all.

> 
> My approach uses AST to AST translation.
> Why did you refuse this approach? What was the main drawback
> of this approach?

I just found AST to AST too cumbersome.
To oversimplify, I'd rather just write:
int main(int argc, char *argv[]) --> public static void main(String[]
args)

Writing that line is far easier than figuring out what each of
those two ASTs look like and how to convert from one to the
other.

I also found that examples like the "main" one above
seemed to be about the
most complicated examples shown for AST translation languages
like TXL. When in fact, that "main" example is one of the
simplest rules, and I have many hundreds of rules, most more
complicated than that.

I found that I was just getting bogged down trying to keep ASTs
in my head. I felt it was much easier to write translation rules
in simple text as shown with the "-->" separator above. That way,
you never even have to think about ASTs much.

Do you have any documentation on your AST-to-AST mechanism?

Andy

> 
> Anakreon.





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list