antlr3: following token definitions can never be matched

46 Views Asked by At

For the below grammar:

grammar Test;

options {
  language = Java;
  output=AST;
}


reference
 : TASK
 | NAME
 ;

TASK
 : (~'^')+ EOF
 ;

NAME
 : ('A'..'Z')+
 ;

I get the following error:

error(208): Test.g:19:1: The following token definitions can never be matched because prior tokens match the same input: NAME

Both the tokens have different charset but still I don't understand why NAME is already matched by TASK.

I need TASK to strictly end with an EOF and NAME doesn't contain EOF in it. So, both those token can never match the same string.

Anyone know what I am doing wrong ?

0

There are 0 best solutions below