[antlr-interest] rules with parameters are not equivalent to rules without parameters
Kristian Marinkovic
kristian.marinkovic at porsche.co.at
Tue Oct 10 04:43:09 PDT 2006
Hello,
i'm trying to understand why antlr is generating different code for rules
with parameters and rules without parameters.
I assumed that the 2 examples below are equivalent?!
example without parameter:
a : "AAA";
b : "BBB";
c : "CCC";
startRule : (body)*;
body : (a | b) COL c SEMIC {//do sth};
example with parameter:
startRule : (body)*;
body
{
String a = null;
String b = null;
}
:
( {a = a_sub();} | {b = b_sub();} ) COL c SEMIC {//do sth};;
a_sub returns [String a] : a { a = "AAA"; //alt. get it from token};
b_sub returns [String b] : b { b =" BBB"; //alt. get it from token};
Is there another way i can solve this? Because the parser with the
parameter is not deterministic! I'm using Antlr 2.7.5
g,
kris
More information about the antlr-interest
mailing list