C# 中自己的 DSL 的代码解析器
我正在寻找像 flex/bison 这样可以与 C# 代码一起使用的东西。我希望能够提供一些语言描述符并且应该生成一个解析器。
I'm looking for something like flex/bison that works with C# code. I want to be able to provide some language descriptors and a parser should be generated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 ANTLR 上运气很好,它也可以生成 C# 代码。良好的语言设计支持以及 ANTLR Works,一个用于设计和测试语法的 IDE,以及相当多的教程来解释整个事情。
其他选项是具有 fsLex 和 fsYacc 的 F# powerpack。只是简单地研究一下它,看起来很强大,但文档很少。
对于 C#,我认为这是首先要考虑的两件事。
国杰
I've had my best luck with ANTLR, it can generate C# code as well. Good Language design support as well with ANTLR Works, an IDE for designing and testing your grammars, and quite a few tutorials to explain the whole thing.
Other option is the F# powerpack that has fsLex and fsYacc. Only brielfy poked at it, seems powerful but very little documentation.
For C# that's the two first thing to look at i think.
GJ
有几种选择。我发现讽刺很好。它功能强大,并且具有新颖的语法,利用 C# 运算符重载直接在 C# 中传达语法的语法。
Irony - .NET 语言实现工具包。
http://irony.codeplex.com/
There are several options. I've found Irony to be good. It's powerful, and it has a novel syntax utilizing C# operator overloads to convey the syntax of your grammars directly in C#.
Irony - .NET Language Implementation Kit.
http://irony.codeplex.com/
ANTLR 是一个非常常见的解析器生成器,具有多种语言(包括 c#)的输出绑定,但它是 LLR,可能如果你习惯的话,让它比 flex/bison 更麻烦一点。
ANTLR is a very common parser generator with output bindings for many languages (including c#), but it is LLR which might make it a little more cumbersome than flex/bison if that's what you are accustomed to.