[antlr-interest] AST Tree rewriting

Floris van Nee floris.vannee at gmail.com
Mon Mar 16 04:45:09 PDT 2009


Hi Des,

I think you need to specify output=AST in the options section.

Floris

2009/3/16 Des Hartman <des at deshartman.com>

> I has just been reading up about AST tree rewriting and it seems to be
> exactly what I need. However I am struggling to compile what I believe is a
> very simple tree.  I have tried it with language=Java, but the same errors.
> Looks like ANTLRWorks does not understand tree rewrites??? The problem I am
> having is that ANTLRWorks 1.2.3 with antlr-3.1.2 complains and will not
> compile this code. It says
>
> "Unexpected token: ^("
> "expecting SEMI, found ')' "
>
> LREF and IREF are defined in the Parser Formula and convertLocalReference
> converts a reference like "A" to "{1}" in code.
>
>
>
> tree grammar L2ITree;
>
> options {
>     language=ActionScript;
>     tokenVocab=Formula;
>     ASTLabelType=CommonTree;
>     filter=true;
>     rewrite=true;
> }
>
> @members {
>     // This function gets overriden in the main code. Returns the IREF
> value based on LREF value.
>     public function convertLocalReference(ref:CommonTree):Number {return
> null;}
>
> }
>
> reference
>     : ^(LREF   lr=NAME) { iref:Number = convertLocalReference($lr); }
> -> ^(IREF iref)
>     ;
>
> ===================================================
> Thanks
> Des
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090316/b7699342/attachment.html 


More information about the antlr-interest mailing list