I have a simple grammar that keeps giving me mismatched input on seemingly right inputs. My grammar is as follows
root: expression;
expression
: METRIC comparator RHS
| expression AND expression
| expression OR expression
| LPAREN expression RPAREN
;
comparator
: EQ | GT | GE | LT | LE;
EQ: [eE][qQ];
GE: [gG][eE];
GT: [gG][tT];
LE: [lL][eE];
LT: [lL][tT];
LPAREN: '(';
RPAREN: ')';
AND: [aA][nN][dD];
OR: [oO][rR];
WS: [
]+;
METRIC: 'latency' | 'qps';
RHS: 'foobar' | 'foobaz';
Why does this grammar give a mismatched input 'latency'
error when the input is latency eq foobar
. Surely this follows the first production METRIC comparator RHS