// Grammar for an inherently ambiguous language // Crafted so it's not trivially ambiguous (generating lambda, for example) // The language of this grammar is: // n n m m n n // a b c union a b c // In other words, strings in this language have either the same number of a's and b's // OR the same number of b's and c's terminal Object a, b, c; non terminal Object S, AmatchB, BmatchC, As, Cs; start with S; S ::= AmatchB Cs | As BmatchC | a | c | /* empty */ ; AmatchB ::= a AmatchB b | a b ; BmatchC ::= b BmatchC c | b c ; As ::= a As | /* empty */ ; Cs ::= c Cs | /* empty */ ;