[metaas-dev] Reusing the ANTLR grammar

Don-Duong Quach geekrelief at gmail.com
Mon Apr 28 21:28:50 UTC 2008


Hi,
I'm trying to build an Actionscript 3 to haxe http://haxe.org translator,
and I've been taking a closer look at metaas to see if I could reuse the AS3
and island grammars as the basis for it.  I thought I might as well try to
build something robust with ANTLR than hand code a translator, but I've into
a couple snags with building the project.

I was hoping maybe David Holroyd or someone would give me some pointers on
how to alter the grammar into a tree grammar for rewriting as I'm still
learning how to use ANTLR.

Just as a side note, I setup Netbeans with a Maven plugin to build the
metaas project but ran into some dependency issues with the maven-archiver,
plexus-archiver and plexus-components.  I stopped trying to resolve them at
that point because I wanted to focus on the task of the tree grammar.

I've been reading through the docs and examples, but I don't know I would
translate the certain parser rewrites into a tree grammar rule.  For
example:

classDefinition[LinkedListTree annos, LinkedListTree mods]
    :    CLASS ident
        classExtendsClause
        implementsClause
        typeBlock
        -> ^(CLASS_DEF {$annos} {$mods} ident classExtendsClause
implementsClause typeBlock)
    ;

In The Definitive Guide to ANTLR, Terrence Parr says to copy the rules over
like so:

classDefinition[LinkedListTree annos, LinkedListTree mods]
    :    ^(CLASS_DEF {$annos} {$mods} ident classExtendsClause
implementsClause typeBlock)
    ;

But what would I do about the {$annos} and {$mods} elements in the rule?  I
figure the parameter clause should be removed, but what should I use to
reference the annos and mods elements in the AST?

Thanks,
Don
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.badgers-in-foil.co.uk/pipermail/metaas-dev/attachments/20080428/39eaa221/attachment.htm 


More information about the metaas-dev mailing list