Parser-generator that outputs C# given a BNF gramm

2019-01-24 09:58发布

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)

Does such a generator exist?

标签: c# parsing bnf
5条回答
欢心
2楼-- · 2019-01-24 10:36

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.

查看更多
SAY GOODBYE
3楼-- · 2019-01-24 10:54

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

查看更多
一纸荒年 Trace。
4楼-- · 2019-01-24 10:55

Also take a look at Irony:

http://irony.codeplex.com/

seems very promising

查看更多
forever°为你锁心
5楼-- · 2019-01-24 10:56

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

查看更多
Summer. ? 凉城
6楼-- · 2019-01-24 11:01

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

查看更多
登录 后发表回答