I have a (badly specified) requirement that I recognize certain keywords, but there is also provision for ‘any string’ …
For instance, in the input “let’s have a ” I have to handle == “beer”, == “curry” and == anything else at all (in theory, the keywords beer & curry have priority over all other strings).
When I try to define this, of course, I get
Decision can match input such as "'curry" using multiple alternatives: 2, 3
As a result, alternative(s) 3 were disabled for that input
I imagine this is a st00pid n00b FAQ, but don’t see an obvious answer. Any help gratefully received …
You need to apply some of the grammar disambiguation techniques that you are either learning (if this is homework). Generally speaking you add an additional rule that disambiguates the grammar.
Another antlr specific thing you can do is add an action to the rule that will handle the differences.
I might be able to help more if you post the antlr code in question.