[antlr-interest] [newbie] AST Rewriting

Robin diabeteman at gmail.com
Mon Mar 19 04:04:29 PDT 2012


Hello list :)

I am trying to rewrite an AST (by filtering out most of the nodes). From
what i could read on antlr wiki and some interesting forums & other medias,
you can do this with tree grammars and tree operators "->".

The grammar I use to generate AST is here
http://www.antlr.org/grammar/1207932239307/Java1_5Grammars and here is my
test rig http://pastebin.com/LeR4miVu

I modified JavaTreeParser.g and added the options output = AST; and rewrite
= true; Also, just for testing purposes, I added "->" at the end of each
rule in order to filter out all of the nodes. Here is what it looks like
http://pastebin.com/u6UG7fEB

The problem is that in my test rig, the returned tree is not rewrited at
all.

I am sure I'm doing something wrong. Could you help ?

Thanks in advance,
Robin


More information about the antlr-interest mailing list