When I want to create a parser out of my grammar ANTLR gives me an error about a non-LL(*) conform content. I do understand that this means that there must be a point where the parser can't distinguish between two or more rules but what I don't understand is what ANTLR means by saying that this ambiguity is reachable from (for example) 'alts 1,2'.
Is there a way to interpret these numbers to actually find the particular input which causes this ambiguity so that I know what I have to fix? Because I find it really difficult to look at my grammar again and find out what causes this issue...
Best regards Raven
The message will state the line in the grammar file where the problem occured. 'alts 1,2' means ANTLR found ways two ways to match the input which differ in how to continue at given location, so it cannot decide which way to take. Examples of what is meant by alternatives 1 and 2:
rule1:
( choice1 // alternative 1
| choice2 // alternative 2
)
;
rule2:
choice? // alternative 1: go into choice rule
// alternative 2: skip over choice rule
;
rule3:
choice* // alternative 1: go into choice rule (either first time or repeatedly)
// alternative 2: skip over choice rule (either skip it or don't repeat anymore)
;
rule4:
choice+ // alternative 1: repeat once more
// alternative 2: don't repeat anymore
;