[antlr-interest] syntax predicate strange behavior

Gavin Lambert antlr at mirality.co.nz
Tue May 1 01:22:13 PDT 2007


At 19:53 1/05/2007, David Holroyd wrote:
 >> By the way, this works fine:
 >>
 >> command_user_body
 >> options {backtrack=true;}:	
 >> 	LCURL command_arguments? RCURL -> ^(USER_COMMAND
 >command_arguments?) |					
 >> 	-> USER_COMMAND
 >> ;
 >
 >With backtracking (which I admit I don't wholly understand yet) 
I
 >guess if it fails on the first alt, it will back-off to the 
second,
 >empty alternative?

Speaking of which, since (I think) USER_COMMAND and 
^(USER_COMMAND) are equivalent, wouldn't the above be identical to 
this (ignoring the backtracking for the moment):

command_user_body:
   (LCURL command_arguments? RCURL)? -> ^(USER_COMMAND 
command_arguments?);

(I could be wrong.)



More information about the antlr-interest mailing list