问题描述
我可能是错的,但看来到目前为止C#/.NET没有直接的flex/bison(lex/yacc)端口.
I might be wrong, but it looks like that there's no direct flex/bison (lex/yacc) port for C#/.NET so far.
对于LALR解析器,我找到了GPPG/GPLEX,对于LL解析器,有著名的ANTLR.但是,我想尽可能地重用我的flex/bison语法.
For LALR parser, I found GPPG/GPLEX, and for LL parser, there is the famous ANTLR. But, I want to reuse my flex/bison grammar as much as possible.
- C#是否有直接的flex/bison端口?
- 人们通常在C#中使用哪些词法分析器/解析器?有什么选择的理由吗?
推荐答案
我认为您最好的选择是GPLEX/GPPG,对于我所知道的C#,它是最接近Yacc/Lex的,并且您需要无论如何,都将您的操作移植到C#中.
I think your best bet is going to be GPLEX/GPPG, it's the closest thing to Yacc/Lex for C# that I know of, and you will need to port your actions into C# regardless.
我还使用了Coco/R,ANTLR(当然),最近还使用了Irony.net,fslex/fsyacc(F#)和fparsec(F#).
I have also used Coco/R, ANTLR (of course), and have more recently played with Irony.net, fslex/fsyacc (F#), and fparsec (F#).
这里有一些链接
我没有使用技术对其他技术的理由:我主要是为了娱乐而玩这些游戏.早在几年前,我确实为工作项目创建了一些DSL,但是我却在上面手动滚动了扫描仪/解析器(当时我主要在Pascal工作,发现TP Lex/Yacc不适合我的口味, DSL非常简单).我发现FParsec和Irony最适合我的口味,因为我发现其他的比较杂乱"(缺乏优雅感).
I don't have a technical reason for using one versus another: I play around with these mostly for fun. I did create some DSLs for work projects a good number of years ago, but I hand rolled the scanners/parsers on those (back then I was working mostly in Pascal, and I found that TP Lex/Yacc did not suit my tastes, and the DSLs were simple enough). I have found that FParsec and Irony suit my tastes the best, as I find the other somewhat "messy" (lacking in elegance).
这篇关于C#是否具有(直接)flex/yacc端口?还是人们为C#使用什么词法分析器/解析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!