[antlr-interest] Re: Translators Should Use Tree Grammars

atripp54321 atripp at comcast.net
Mon Nov 22 18:19:09 PST 2004



--- In antlr-interest at yahoogroups.com, Anakreon <anakreonmejdi at y...>
wrote:
> > Yea, I suppose a treewalker is fine when the output is so very
> > close to just a printing of the inorder traversal of the AST.
> > But I'm still not convinced that a treewalker is the best
> > for very complex AST-to-AST transformations.
> > 
> > Andy
> In my opinion treewalker is capable for complex transformations.
> For example, in ASPA a Jscript class declaration is transformed
> into a PHP class declaration.
[snip]
> The transformations involved are complex and are handled with the
treewalker
> Antrl generates.
> The code generation is handled by a TreeParser which recognizes the
generated AST of the
> translator(AST of PHP) and a class of 171 lines (including the
header which declares that
> the source is GPL).
> 
> Personally I found no limitations in the TreeParser approach
although I believe that the
> transformations involved are quite complex.
> 
> Anakreon

Anakreon,

I spent a couple of hours trying to figure out how your stuff works.
It looks to me like you've got tree_js.g (251 lines) for your
Jscript treewalker grammar. You've got tree_js_php.act
containing two things: supporting classes (the first 1481 lines),
plus the actual code that would normally be embedded
in the grammar (the remaining 827 lines). And somehow you
automatically stuff that code into the .g file before
using ANTLR on it? And then you've got 9200 lines of
xml (tests/js_*.xml)
that appears to specify how to translate specific AST structures.
(they appear to contain transformation logic, yet their in
the 'test' directory...are they part of the program, or some
sort of test case?)
 
Am I understanding your code correctly?

Also, could you give a small example of some more complex 
transformation? I didn't see anything in the code you posted
other than very simple syntactic changes (for example, nothing
that would have to look at other places in the AST).

Thanks for jumping in here. Without anything concrete for
everyone to look at, we're all just blowing hot air :)
Andy





 
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