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

atripp54321 atripp at comcast.net
Sun Oct 31 08:07:34 PST 2004



--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> 
> On Oct 27, 2004, at 11:23 AM, atripp54321 wrote:
> >> 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'm working on a "blog" entry that describes this right this second.  
> Often concrete syntax level (rather than tree level) specs are easier.  
> My only question will be, for the general case, is it powerful enough 
> with a simple to understand "engine".

Yes. The whole key (which you alluded to) is that the more
complicated rules are just written in Java, so you are not
really limited by any artificial "translation language".
You write Java using a large library of token-stream
manipulation functions. I also have a few rules that manipulate
ASTs (mostly for expression processing).

> 
> > 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.
> 
> Sounds like you and I should talk on the phone sometime when i get more 
> time to think about a simple general rewrite system.  Where were you 
> during the workshop!? ;)

Not invited :( Probably just as well, as I'd have probably
been more vocal than even you about things. That's not good,
as I'm not a well-respected guru in this field like you are :)

> 
> > 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 do multiple passes or all translations in a single?  What kind 
> of "engine" did the replacing?

Multiple passes...several hundred passes in fact :)
The problem I have now is not in being able to write very
complex rules, it's keeping all those rules in an order
that works. For example, I fire the "make any functions
that are missing a return type return 'int'" rule before
the "change the 'int main()' C function to the equivalent
Java method" rule.

Here's a very high-level design description:
http://jazillian.com/design.html
And here's an English description of what many of my rules
are doing:
http://jazillian.com/how.html

I'll be writing a complete writeup of the design in a couple
of weeks, I'll post a link when it's ready.

Andy

> 
> Ter
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!





 
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