[antlr-interest] Passing values from one rule to another

swathy murthy pskswathy at gmail.com
Fri Sep 25 13:39:39 PDT 2009


Hi

I am creating a translator from one language to another. My tree
grammar is as follows:

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

I want to pass the value of LITERAL to expr so that the output of the
rewrite would be like:
(INPUT_VARIABLES (+ X Y)) -> (INPUT_VARIABLES X Y)

Can anyone please tell me how to solve this problem. Thanks in advance
for the help.

Swathy


More information about the antlr-interest mailing list