什么是好的 C# 编译器-编译器/解析器生成器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1194584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 10:31:43  来源:igfitidea点击:

What is a good C# compiler-compiler/parser generator?

c#parser-generator

提问by HasaniH

I'm looking for a parser generator that given an EBNF for a LL(k) language will give me a C# parser and generate classes the types defined in the EBNF.

我正在寻找一个解析器生成器,它为 LL(k) 语言提供 EBNF,它将为我提供 C# 解析器并生成 EBNF 中定义的类型的类。

采纳答案by plinth

Goldis OK as far a parser generators go.

就解析器生成器而言,黄金是可以的。

回答by Vinay Sajip

You might want to look at MinosseCC, a port of JavaCCto C#. Another possibility is Spart.

您可能想查看MinosseCC,它是JavaCCC# 的一个端口。另一种可能性是Spart

回答by Martin v. L?wis

ANTLR(nothing else to say)

ANTLR(没什么好说的)

回答by Bob Peterson

Grammatica supports LL(k). http://grammatica.percederberg.net/

Grammatica 支持 LL(k)。http://grammatica.percederberg.net/

回答by Ali

Find Irony in http://irony.codeplex.com/

http://irony.codeplex.com/ 中找到 Irony

PROS: It is simple CONS: -Lack of document -Rather Slow

优点:很简单 缺点:-缺乏文件-相当慢

回答by Traummaennlein

Coco/R(from the SSW - "Johannes Kepler" University Linz)

Coco/R(来自 SSW - “约翰内斯开普勒”林茨大学)

回答by Qwertie

There is a new parser generator on the block called LLLPG, that supports LL(k) grammars and zero-width assertions. The runtime library is optional (a base class suffices). The documentation is fairly detailed now, and I have used LLLPG to parse most of a dialect of C# called Enhanced C# (which, in fact, is the main input language of LLLPG). The input syntax is not EBNF, though (it's sort of a mashup of C# + ANTLR-style code).

块上有一个名为LLLPG的新解析器生成器,它支持 LL(k) 语法和零宽度断言。运行时库是可选的(一个基类就足够了)。文档现在已经相当详细了,我已经使用 LLLPG 来解析大部分 C# 方言,称为 Enhanced C#(实际上,它是 LLLPG 的主要输入语言)。但是,输入语法不是 EBNF(它是 C# + ANTLR 样式代码的混搭)。

Full disclosure: I wrote it. Questions welcome.

完全披露:我写的。欢迎提问。

Edit:the top Google result for "C# parser generator" is written by a guy named "Tomassetti" who claims my parser generator "is not really usable standalone" - that's like saying a PC is "not really usable as a standalone gaming rig" because it can alsodo web browsing and spreadsheets. True, after installing the Visual Studio extension you must separately go to NuGet and get the runtime library (Loyc.Syntax), but I don't think that's what he means and I don't think he ever actually tried to use it. LLLPG's design is a feature, not a bug. All I can say is, please give it a try and let me know what you think.

编辑:“C# 解析器生成器”的 Google 排名靠前的结果是由一个名叫“Tomassetti”的人编写的,他声称我的解析器生成器“不能真正独立使用”——这就像说 PC“不能真正用作独立游戏装备”因为它可以同时做网页浏览和电子表格。确实,在安装 Visual Studio 扩展后,您必须单独转到 NuGet 并获取运行时库 (Loyc.Syntax),但我认为这不是他的意思,而且我认为他从未真正尝试过使用它。LLLPG 的设计是一个特性,而不是一个错误。我只能说,请尝试一下,让我知道您的想法。