1
votes

I have a grammar that is failing on the first token. I've stripped it down some to reduce the choices, but still have the error:

line 1:0 mismatched input 'main' expecting {, '@', 'def', IDENTIFIER}

I expect the token 'main' to match IDENTIFIER, which has this lexical production:

IDENTIFIER : [a-zA-Z][a-zA-Z0-9]*;

Why would that be failing?

1

1 Answers

1
votes

One of the following is happening:

  1. You have another rule in the grammar located before IDENTIFIER that also matches the input main.
  2. You have a combined grammar (declared as grammar T instead of parser grammar T or lexer grammar T), where one of the parser rules contains the literal 'main' which is causing a separate lexer rule to be implicitly created for this literal.