[antlr-interest] passing parameters...

Pady Srinivasan padysrini at hotmail.com
Tue Dec 30 15:47:19 PST 2008


In my tree grammar, I have rules as follows:

statement
 : ifStatement | statementBlock[true]
 ;

statementBlock[boolean result]
 : assignment[$result]  | compoundStatement[$result]
 ;

compoundStatement[boolean result]
 : ({$result}?=> ^(BLOCK statement*) )
 ;

assignment[boolean result]
 : ({$result}?=> ^(EVAL statementExpression) )
 ;


In the generated java class, I see code generated in the statement() method 
as follows: ( and is not compiling )

..
             else if ( (LA2_0==BLOCK||LA2_0==EVAL) && ((result))) {
                 alt2=2;
            }
..

Where did the "result" variable come into the statement() method ? I am 
confused on whether I am not passing the params correctly ( although I saw a 
similar example in antlr book for passing parameters ).



Thanks

-- pady 



More information about the antlr-interest mailing list