[antlr-interest] syntax predicate strange behavior

Ilia Kantor ilia at obnovlenie.ru
Tue May 1 11:03:38 PDT 2007


The problem I'm talking about is:

Backtracking chooses 1st alt ,
so 1st alt is ok.

In fact, no backtracking occurs, it just matches 1st alt and goes.

But dfa gives error on 1st alt!

I'm not quite sure how your solution solves this dillema ?..

Thanks
Ilia.

> The fact that backtracking mode works makes me guess [pun intended] that
> your syntactic predicates are not quite enough. 
> You can probably try: 
> (LCURL) => LCURL ( (WORD)=>command_arguments) ? RCURL
> |
> ;



> 
> For the shortest predicate that indicates command_argument is present.
> If that does not work then you will have to predicate the whole of
> command_arguments perhaps, but in that case you are effectively doing
> what backtracking mode does.
> 
> The reason you need to predicate command_arguments is unclear from the
> context you gave us, but is it possible that that rule itself has an
> 'empty' option so that you are confusing things by both making it option
> in command_user_body AND optional in and of itself?
> 
> Jim
> 
> 




More information about the antlr-interest mailing list