[antlr-interest] language conversion

swathy murthy pskswathy at gmail.com
Sat Sep 26 22:34:39 PDT 2009


Hi

I am trying to convert from one language to another using tree
grammar. I have built a parser and am in the process of writing a tree
grammar. I am facing problem in accessing the variable name. My tree
grammar is as follows:

specification_root : ^(SPECIFICATION specification) ->
^(INPUT_VARIABLES specification);
specification : ^('=' KEYWORD_f expr);
expr : ^((',' | ('&'?) | ('|'?)) expr*) | exp;
exp :  ^(('+' | '-' | '>' | '<' | '>=' | '<=' | '=' | '!=') exp*) | term;
term : ^(('*' | '/') term*) | LITERAL;

I want to access the name of the LITERAL which appears in the parser
AST in place of expr in specification rule. So that the rewrite would
be looking like:
('=' f (+ x y)) -> (x y)
I just want to retain the name of the variables in the rule. Can
anyone please tell me how to go about it.

Thanks
Swathy


More information about the antlr-interest mailing list