[antlr-interest] syntax predicate strange behavior
jimi at temporal-wave.com
Tue May 1 12:37:48 PDT 2007
I saw that you had provided further information, and assumed that you
had solved this. The predicates you need are within the
command_arguments rule to distinguish the option WORD WS sequence I
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Ilia Kantor
Sent: Tuesday, May 01, 2007 11:04 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] syntax predicate strange behavior
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 ?..
> The fact that backtracking mode works makes me guess [pun intended]
> 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
> in command_user_body AND optional in and of itself?
More information about the antlr-interest