我试图使用antlr4,我有以下语法:
grammar Comp;
start : 'ca\n';
ID : [a-zA-Z][a-zA-Z0-9]* ; // match identifiers
INT : [0-9]+ ; // match integers
NEWLINE : '\r'? '\n' ; // return newlines to parser (is end-statement signal)
WS : [ \t]+ -> skip ; // toss out whitespace
OTHER : (~'\n')* '\n' ;
如果我发送lexem' ca \ n'有用。 但是有了规则:
start : 'ca' '\n';
或
start : 'ca' NEWLINE;
lexem没有得到认可。为什么?
感谢您的帮助。 ;)