我的语法有以下问题:
我要解析的输入字符串如下:
ruledef COMPLEX1
ftp command args = abc
ftp command args = ftp
ftp command args = cde
exit
我使用的语法:
grammar main;
/*Lexical*/
NUM : [0-9]+;
STRING : [0-9a-zA-Z]+;
WS : [ \t\r\n]+ -> skip; // Whitespace definition: skip spaces, tabs and newlines
ruledefrule: 'ruledef' STRING (ruledef_ftpcommandargsrule )* 'exit';
ruledef_ftpcommandargsrule: 'ftp' 'command' 'args' '=' STRING ;
当我通过 antlr 运行它时,我收到一个错误:
line 3:23 missing STRING at 'ftp'
更重要的是,输入中使用的任何单词,例如“命令”或“参数”都会导致同样的问题。
ftp command args = ftp
ftp command args = args
ftp command args = command
有谁知道如何处理这类问题?