Antlr input using several alternative errors

I get a warning when antlr v3.1 compiles in this rule

 sentence
:
(CAPITAL_LETTERS_AND_NUMBERS | INT | ANY_WORD ) 
(
    INT
| CAPITAL_LETTERS_AND_NUMBERS
| ANY_WORD 
)*;

Warning:

 5:2: Decision can match input such as "CAPITAL_LETTERS_AND_NUMBERS" using multiple alternatives: 1, 2
 As a result, alternative(s) 2 were disabled for that input
 Semantic predicates were present but were hidden by actions.
 Decision can match input such as "INT" using multiple alternatives: 1, 2
 As a result, alternative(s) 2 were disabled for that input
 Semantic predicates were present but were hidden by actions.

The reason I'm confused is the grammar, which is pretty complicated until I add another subrule to another place in the file that also uses the sentence. He accepts this rule until it happens, which seems strange. I'm looking for tips on how best to debug and understand how this can happen?

Thanks Richard

+5
source share
1 answer

It's complicated. Especially with large grammars, changing (or adding) rules can cause ambiguity that is difficult to track.

ANTLRWorks . :

grammar T;

parse
  :  other? WORD? EOF
  ;

other
  :  WORD
  ;

WORD
  :  ('a'..'z' | 'A'..'Z')+
  ;

, parse. , foo ( WORD ), other EOF WORD EOF, :

, , "WORD",

.

ANTLRWorks :

enter image description here

, , , , AFAIK . , , , , , .

+10

All Articles