NOT(〜)运算符有时不起作用。 我有一个DSL Java语言转换器。在其中,我的打印语句以':'开头,以及所有常规关键字(如IF,FOR等)。我无法弄清楚other_words规则不排除CR的原因和时间。这是随机行为。
main : statement+;
statement: ':' (identifier|other_words)+ CR*;
identifier : '$' IDENTIFIER;
other_words : ~(CR)+ ;
IDENTIFIER : [A-Za-z]+ ;
CR : '\r'? '\n' ;
WS : [ \t]+ -> skip ;