什么是好的 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
What is a good C# compiler-compiler/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 Vinay Sajip
回答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
回答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 的设计是一个特性,而不是一个错误。我只能说,请尝试一下,让我知道您的想法。