[antlr-interest] AST rewriting
Sean Walton
swalton at cs.utah.edu
Fri Jul 28 09:31:48 PDT 2006
I have poring over the documentation and trying to figure out how to do
AST rewriting. I finally figured out how to use "^" to emit a parent
node. But I would like to create a parent node so that an implied
declaration (like a C method) can be flagged appropriately. This is the
kind of thing that I would like to get from the source:
Source:
int* fn(char c, long l);
Grammar:
method: retval ID LPAREN! (params)? RPAREN! SEMI!;
params: param (COMMA! param)*;
param: retval ID
AST:
(METHOD REVAL(int *) fn PARAMS(PARAM(REVAL(char), c)
PARAM(RETVAL(long), l)))
-Sean
More information about the antlr-interest
mailing list