我已经开始阅读this讨论,但它对我没有帮助。
start with file;
file ::= primario SEP secondario SEP terziario EOF {:fm.scriviDebug();:};
fm.scriviDebug()
是我的自定义类,它在stdout上打印CUP解析的内容。
我不知道问题出在哪里。
我使用JFLex扫描文件并以下列方式将符号传递给CUP:
...
{bo} {System.out.println("[BO] ["+yytext() +"]");return symbol(sym.BO);}
{bc} {System.out.println("[BC] ["+yytext() +"]");return symbol(sym.BC);}
{sc} {System.out.println("[SC] ["+yytext() +"]");return symbol(sym.SC);}
{eq} {System.out.println("[EQ] ["+yytext() +"]");return symbol(sym.EQ);}
...
我收到以下类型的多个警告:
Warning in file "Scanner.jflex" (line 115):
Expression matches the empty string, which may lead to non-termination.
.* {
这是我在编译"时得到的。 CUP:
Opening files...
Parsing specification from standard input...
Error at 63(73): java_cup.runtime.Symbol "EOF" has not been declared
Closing files...
------- CUP v0.10k Parser Generation Summary -------
1 error and 0 warnings
20 terminals, 14 non-terminals, and 18 productions declared,
producing 0 unique parse states.
0 terminals declared but not used.
0 non-terminals declared but not used.
0 productions never reduced.
0 conflicts detected (0 expected).
No code produced.
---------------------------------------------------- (v0.10k)
编译CUP后的另一个错误失败:
cannot find symbol
{ return new java_cup.runtime.Symbol(sym.EOF); }
请告诉我是否需要更多信息。