我有这个 BNFC 文件描述了一个由许多部分组成的配置文件,其中每个部分的名称在 [] 之间,后跟一个简单声明列表
comment "#";
rulse Boolean ::= "True" | "False";
Conf. Config ::= [Section]; //a config is a list of sections
terminator Section "";
Sec. Section ::= "[" NomeSec "]" [Decl]; //A section is made of a name and a list of declarations
terminator Decl ";";
NomeSez. NomeSec ::= Ident;
Dec. Decl ::= VarN "=" Type;
VarName. VarN ::= Ident;
Int. Type::=Integer;
Char. Type::=Char;
String. Type::=String;
Float. Type::=Double;
Bool. Type::=Boolean;
例子:
[Section1]
Var1 = 3;
Var2 = "test";
#ignored comment
[SectionA]
var4 = True;
具有未定义数量的部分和声明。
我从 shell 运行了命令bnfc -m -java <filename>,一切都很好,部分来自漂亮的打印机。当编译 prettyprinter.java 时会产生大量错误。例如:
ES5/PrettyPrinter.java:10: error: reference to String is ambiguos
private static final String _L_PAREN = new String("("); both class
ES5.Absyn.String and class java.lang.String in java.lang match
所有的错误都属于这种类型。我想知道,我刚刚建立了语法,我的语法失败了还是 BNFC 失败了?谢谢