Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    I assume [a-b] should be [a-z] Commented May 13 at 8:03
  • Yes. The lexer is not guided by the parser. Antlr lexers follow basic rules: 1) The lexer rule that matches the longest input string is selected. 2) If two or more lexer rules match the same string, the first is selected. 3) String literals in parser rules define new lexer rules before all explicit lexer rules internally if there isn't an explicit lexer rule that declares the string literal. In your grammar, Reserved occurs before Identifier so Reserved always matches. Always print out the token types of the tokens when degugging your grammar. Commented May 13 at 9:34