この 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;
セクションと宣言の数が未定義です。
シェルからコマンドを実行した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 に失敗したのか疑問に思っています。ありがとう