[antlr-interest] [v3] Can't seem to resolve through syntactic predicates...

Gavin Lambert antlr at mirality.co.nz
Wed Jun 27 00:57:43 PDT 2007


At 19:35 27/06/2007, Mark Mandel wrote:
 >tagInnerValues
 >	:
 >	(
 >	{
 >           complicatedPredicate()
 >	}?=> tagAttribute*
 >	)
 >	|
 >	(
 >	{
 >	(	
 >		!complicatedPredicate()
 >	)
 >	}?=> script
 >	)
 >	|
 >	;
[...]
 >rule tagInnerValues has non-LL(*) decision due to recursive rule
 >invocations reachable from alts 1,2,3.  Resolve by 
left-factoring
 >or using syntactic predicates or using backtrack=true option
 >
 >But, I'm confused in that, I have a syntactic predicate - either
 >tagAttributes OR script are going to be required, never both - 
so
 >why am I getting the warning? I would have thought the code 
above
 >would have got rid of it.

Actually that's a *semantic* predicate, not a syntactic one, since 
it uses target code rather than tokens to resolve itself (hence 
the braces).  (Technically it's a *gated* semantic predicate, but 
I can never remember how those are different from regular semantic 
predicates.)

Also, the fact that it's mentioning alt 3 (which is empty) leads 
me to suspect that the problem actually lies further up the 
tree.  You've probably got a "list of nothing"-type construct, 
which makes no sense and causes odd things to happen.



More information about the antlr-interest mailing list