i like to define a very simple rule, which should represent identifiers. This works quite well for identifiers which are longer than开发者_C百科 one characters, but for identifiers with exactly one character I get a MismatchedTokenException(64!=45). This is the rule:
ID : ('a'..'z' | 'A'..'Z')+ ;
What is wrong with that?
Thanks!
You're absolutely right, the rule on its own is fine, but I figured out that a lot in ANTLR depends on the order of rules. I had another rule before, which did already match the ID rule. Finally it makes sense, because the Lexer cannot decide which rule to take.
Thanks!
精彩评论