We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
如果你想为 C# 编写一个编译器,可以从 Dragon Book 开始,以及 C# 4 规范 的副本。但这是一项艰巨的工作,不适合胆小的人。通常,您需要多年的经验才能为 C# 等复杂的东西编写编译器。
我建议从较小的语言开始,也许是像 Brainfuck 这样的简单语言,或者看看现有的玩具编译器。
If you want to write a compiler for C#, the place to start is the Dragon Book, alongside a copy of the C# 4 spec. It's an awful lot of work though, and not for the faint of heart; you generally need years of experience to write a compiler for something as complicated as C#.
I recommend starting with a smaller language, maybe a trivial language like brainfuck, or looking at existing toy compilers.
恕我直言,在非常少数情况下,您需要编写解析器/编译器等。
我会以不同的方式进行。
第一个选择是从 C 应用程序运行 .Net。例如,您可以使用 Mono 来实现这一点。这是描述: http://www.mono-project.com/Embedding_Mono
第二个选项就是直接从 C# 应用程序使用 C 类库。查看 http://www.pinvoke.net/ 了解如何声明它们。
imho there are a very few cases when you need to write your on parser / compiler etc.
I would do it in a different way.
First option would be to run .Net from your C application. You can for instance use Mono for that. Here is a description: http://www.mono-project.com/Embedding_Mono
The second option would be to use your c class library directly from C# applications. Check http://www.pinvoke.net/ for example on how to declare them.
一个明显的选择是重新定位 Mono AOT。例如,这就是 MonoTouch 的工作原理。
困难的途径是实现自己的 C# 解析器、编译器及其大部分标准库。
One obvious option is to retarget the Mono AOT. This is how MonoTouch works, for example.
The hard route is to implement your own C# parser, compiler and a large part of its standard library.