[antlr-interest] ambiguity when calling rule
Corno
antlr-interest at schraverus.com
Thu May 25 01:08:13 PDT 2006
Hi all,
I'm trying to understand why my grammar gives an error for ambiguity. First
I thought that the problem was somehow related to ll(k) and that it would
disappear when I reworked it to ll(*). Today I tried that with antlr3 but
the problem persisted.
Basically the problem is as follows; when I have 1 rule, say X, that is
called by both A and B, I get an error. When I literally copy the rule,
rename the copy to Y and let B call Y (while A still calls X) the error
disappears. I know that the combination A-X needs another lookahead than B-Y
but I thought ll(*) would determine a solution that fits both needs.
example
selection : 'v' ( '.' 'w' )* ;
selection2 : 'v' ( '.' 'w' )* ;
statement
:
'<'
(
(
'x' selection statement //error
//'x' selection2 statement //fine
|
'y' selection '.' 'w' '<' ( 'z' ) * '>'
)
) *
'>'
;
Can somebody explain why this is and if there is a way to prevent having to
copy rules?
TIA,
Corno
More information about the antlr-interest
mailing list