按照这个旧教程,我试图让柠檬解析器自动终止对EOL
令牌的解析。解析器的相关部分如下所示:
start ::= in .
in ::= .
in ::= in commandList EOL .
{
printf("start ::= commandList .\n");
printf("> ");
}
下面是我使用 Flex 扫描的令牌执行解析器的方式:
int lexCode;
do {
lexCode = yylex(scanner);
Parse(shellParser, lexCode, yyget_text(scanner));
// XXX This line should not be necessary; EOL should automatically
// terminate parsing. :-(
if (lexCode == EOL) Parse(shellParser, 0, NULL);
} while (lexCode > 0);
我想消除在EOL
此处检查令牌的需要,并让解析器确定何时完成。我怎么做?
谢谢!