[antlr-interest] AST rewrite query

Richard Kenyon richardlkenyon at gmail.com
Tue Jun 12 09:18:04 PDT 2012


Hi all,

I have a rule:

exp	:	term ((PLUS^ | MINUS^) term)*;

My current AST would look something like, for example,

(PLUS (term) (MINUS (term) (term)))

I would prefer to have something like

(EXP (PLUS (term) (EXP (MINUS (term) (term)))))

Essentially I want to make the EXP token the parent of any expression,
I've tried a few different approaches, but not work fully and now I'm
at a dead end. :(


More information about the antlr-interest mailing list