I have a short ANTLR grammar:
query : word (WS word)+;
word : simpleword | compoundword;
compoundword : simpleword (NONWORD+ simpleword)+ | NONWORD+ simpleword (NONWORD+ simpleword)* NONWORD*;
simpleword : SIMPLEWORD;
SIMPLEWORD: [0-9a-zA-Z]+;
NONWORD: [-_];
WS : (' ' | '\r' | '\n');
But the generated parser fails to parse string "abc-def qwe qaz" with message "mismatched input '-' expecting WS".
Any tips how to fix this? Why doesn't the "abc-def" match compoundword production (first alternative)?