给定 BNF 语法输出 C# 的解析器生成器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/153572/
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
Parser-generator that outputs C# given a BNF grammar?
提问by ilitirit
I'm looking for a tool that will be able to build a parser (in C#) if I give it a BNF grammar (eg. http://savage.net.au/SQL/sql-2003-2.bnf)
如果我给它一个 BNF 语法(例如http://savage.net.au/SQL/sql-2003-2.bnf),我正在寻找一种能够构建解析器(在 C# 中)的工具
Does such a generator exist?
这样的生成器存在吗?
采纳答案by leppie
Normally BNF grammars are too ambiguous. ANTLR will be probably good for what you are looking for.
通常 BNF 文法过于模糊。ANTLR 可能适合您正在寻找的内容。
回答by Jonathan C Dickinson
回答by Tormod Fjeldsk?r
The Visual Studio SDKactually ships with lexer and parser generation tools. These are called MPPG and MPLex and are part of the Managed Babelpackage. While the intention of bundling them with the SDK is to develop language extensions for Visual Studio, they are perfectly usable for creating general AST-emitting parsers.
在Visual Studio的SDK实际上附带词法和语法分析器生成工具。它们被称为 MPPG 和 MPLex,是Managed Babel包的一部分。虽然将它们与 SDK 捆绑在一起的目的是为 Visual Studio 开发语言扩展,但它们非常适用于创建通用的 AST 发射解析器。
MPLex and MPPG are based on GPLEXand GPPG(projects of Queensland University of Technology) and are used in a similar fashion to Lex and Yacc. The SDK also contains MSBuild actions for making the parser generation a part of the regular build process.
MPLex 和 MPPG 基于GPLEX和GPPG(昆士兰科技大学的项目),并以与 Lex 和 Yacc 类似的方式使用。SDK 还包含 MSBuild 操作,用于使解析器生成成为常规构建过程的一部分。
Here's a screencast showing MPLex and MPPG in action:
http://msdn.microsoft.com/en-us/vstudio/cc837016.aspx
这是显示 MPLex 和 MPPG 运行的截屏视频:http:
//msdn.microsoft.com/en-us/vstudio/cc837016.aspx
回答by Gian Marco Gherardi
Also take a look at Irony:
还可以看看 Irony:
seems very promising
看起来很有前途