[antlr-interest] problem with backtracking

Lloyd Dupont ld at galador.net
Fri Jul 13 07:41:14 PDT 2007


Hre is my one of my rule:
========
identifier
 options
 {
  backtrack=true;
  memoize=true;
 } 
 : ((  { IsXamlPrefix(input.LT(1).getText()) }? xaml=ID COLON )? id0=ID -> ^( ID[$id0] ^( XAMLNS $xaml )? $id0 ) )
  ( DOT id1=ID -> ^( DOT $identifier $id1 ) )*
  ( LT gt+=identifier (COMMA gt+=identifier)* GT -> ^( GENERICTYPE $identifier $gt+ ) )?
 ;
========

when I try to compile the grammer, it complains:
===
     [fatal] rule identifier has non-LL(*) decision due to recursive rule invocations for alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrach=true option
===

but but but.... I set backtrack to true!!!!

I had a predictae before but, while testing, I noticed it didn't pick up a LT identifier GT, exiting the rule instead, so I decided to try without the predicate...

isn't ANTLR greedy?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070714/04f21446/attachment.html 


More information about the antlr-interest mailing list