[antlr-interest] Listing order of NT alternatives on rhs of production appears to affect "accept/reject" of parser for fixed input.

Andreas Weigel andreas.weigel at tu-harburg.de
Wed Nov 12 04:12:10 PST 2008


Hi,
> I disagree.  My interpretation of that that quote is that enabling 
> backtracking can influence /which/ production is used to match an 
> input (by prioritizing them) however it doesn't say that the set of 
> valid inputs that can match /some/ production changes.
>
> My problem it seems is that in one grammar ordering ANTLR is able to 
> find /some /match for the input while with the other ordering ANTLR 
> decides /no /match can be found.  I claim that changing the ordering 
> should not affect whether /some /match can be found by the parser for 
> a fixed input, irrespective of what that specific match is.  When 
> ANLTR says no match can be found, I point to the syntax tree shown in 
> my original email and say "what about that match?"
>
> -- Matt

I also was under the impression, that backtrack=true should always yield 
at least some match for a valid input. But I have exactly the same issue 
here with another grammar so I'd be very interested in a statement 
concerning that issue. Left factoring is not a great option for me as I 
don't want to tear apart what belongs together and predicates cannot be 
applied as I'm working with another framework (openarchitectureware's 
xText) that generates an Antlr grammar without giving me the possibility 
to intervene and define those.


More information about the antlr-interest mailing list