首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bnfc漂亮打印机java错误

bnfc漂亮打印机java错误
EN

Stack Overflow用户
提问于 2016-05-30 15:57:34
回答 1查看 78关注 0票数 0

我有一个BNFC文件描述了一个由许多部分组成的配置文件,每个部分在[]之间都有一个名称,后面是一个简单声明列表

代码语言:javascript
复制
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;

示例:

代码语言:javascript
复制
[Section1]
Var1 = 3;
Var2 = "test";
#ignored comment

[SectionA]
var4 = True;

有一个未定义的节和声明的数目。

我从shell中运行了命令bnfc -m -java <filename>,从漂亮的打印机运行了一个部件,一切正常。当编译prettyprinter.java的时候会产生大量的错误。例如:

代码语言:javascript
复制
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失败了?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-05 15:29:46

因为BNFC为每个类别和标签创建java类,如果使用java.lang中的名称,则会产生歧义(例如StringBoolean.)。

它适用于以下重命名(我还添加了一个显式入口点):

代码语言:javascript
复制
entrypoints Config;

comment "#";
rules MyBoolean ::= "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;

TInt.    Type::=Integer;
TChar.   Type::=Char;
TString. Type::=String;
TFloat.  Type::=Double;
TBool.   Type::=MyBoolean;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37529742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档