Parser-generator that outputs C# given a BNF grammar? [closed]

空扰寡人 提交于 2019-11-29 04:18:56

Normally BNF grammars are too ambiguous. ANTLR will be probably good for what you are looking for.

The Visual Studio SDK actually ships with lexer and parser generation tools. These are called MPPG and MPLex and are part of the Managed Babel package. 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.

MPLex and MPPG are based on GPLEX and 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.

Here's a screencast showing MPLex and MPPG in action:
http://msdn.microsoft.com/en-us/vstudio/cc837016.aspx

You will have to tweak the BNF a bit, but TinyPG is a great tool.

Also take a look at Irony:

http://irony.codeplex.com/

seems very promising

IronMeta is a C# implementation of Alex Warth's OMeta; it's a packrat PEG (parsing expression grammar; uses biased choice), so grammars can be cleaner than when using a yacc-like LALR system.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!