Wrong rule matched
问题 I have the following in the lexer INTEGER : DIGIT+; NOT: '!'; MINUS:'-'; PLUS:'+'; fragment DIGIT: '0'..'9'; I have the following in the parser expr: intLiteral | UnaryOp expr; intLiteral: (PLUS|MINUS)? INTEGER; UnaryOp: NOT|MINUS; When I use grun to test it with -2, I get it being matched to UnaryOp expr instead of just intLiteral. In other words, the minus sign is being detected as a UnaryOp. Why would this be occuring and is there a way to fix it? 回答1: The practice is to use all CAPITALS