[antlr-interest] AST rewriting

Alvaro Egana Viedma aegana at noao.edu
Tue Jul 1 09:46:02 PDT 2008


Hi all,

I'm new to the list and kind of new to ANTLR so I don't know if this 
stuff is possible or not. I'm working with antlr v3.1b1 and I noticed 
that you can use output=AST for tree grammars in that version. Well, I'm 
using output=AST and but I have a little problem with it. My tree 
grammar looks like:


def : ^(DEF name expr)
     ;
name : <<some rules>>;

expr  returns [String value]
     : <<some rules>>
     ;


I've been trying to do this rewrite:

def : ^(DEF name expr) -> ^(DEF name $expr.value)

(I'm writing a name resolver ...)


But antlr complains saying there is a reference to an undefined rule 
'value'.

Does anyone knows some hack to do something like this?

Thanks in advance for any help.

Alvaro Egana



More information about the antlr-interest mailing list