C#中的开源C编译器

C#中的开源C编译器

本文介绍了C#中的开源C编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在编译器创建。我发现了一些了不起的初学者的东西和高级的东西,但在中间没有。我已经为玩具语言创建了3个不同的简单的概念验证编译器,但我想把自己暴露给真实的东西。

I've been getting into compiler creation. I've found some terrific beginner stuff and advanced stuff but nothing in the middle. I've created 3 different simple proof-of-concept compilers for toy languages but I want to expose myself to something real.

最直接的真实语言语法似乎是C.由于我现在最舒适的语言是C#,我很想学习一个真正的非教程C编译器C#源代码。 (有源代码可用)存在吗?

The most straight forward real language in terms of syntax seems to be C. Since the language I'm most comfortable with right now is C#, I'd love to study the source code of a real non-tutorial C compiler written in C#. Does one (with source code available) exist?

理想情况下,我想要一个C编译器, C#编译器,但是用C#编写的源代码。

我知道C# - > C感觉有点倒退,但它会让我更深入地编译器开始与熟悉的语言,在我改变之前。

Ideally I'd like a C compiler, not a .NET or C# compiler, but with the source code written in C#.
I know C# --> C feels a little backwards but it'll allow me to ease deeper into compilers starting with a familiar language before I go changing that too.

虽然我不是在寻找C#/。NET编译器,这里有一些,如果有人看到这个问题是谁寻找:

Although I'm not looking for C#/.NET compilers, here are some in case someone sees this question who is looking for that:



  • (感谢Luiscencio)

  • Create a Language Compiler for the .NET Framework
  • Mono C# Compiler
  • Source for a C# compiler written in pure C# (.NET v1) (thanks Luiscencio)

推荐答案

将很难找到示例代码。编译器作者使用。第一个C编译器是用B编写的。然后用来编写第一个C ++编译器。其中用来编写C#编译器。这是非常常用于为托管代码编写编译器。

You are going to have a hard time finding sample code. Compiler writers use bootstrapping. The first C compiler was written in B. Which was then used to write the first C++ compiler. Which was used to write the C# compiler. Which is very commonly used to write compilers for managed code.

这不是一个过去的过程。虽然side-way是常见的,C编译器通常用于交叉编译一个编译器为另一个操作系统。

This is not a process that ever goes backwards. Although side-ways was common, C compilers often were used to cross-compile a compiler for another operating system.

我想我使用,它在附录中有非常好的C编译器代码。写在C.我在一个大型项目中编写我需要的基本编译器时使用了它的一部分。表达式解析器很难得到,它有一个优雅的解决方案为运算符优先级规则。

I think I used this book, it has terrific C compiler code in the appendices. Written in C. I used parts of it when writing a Basic compiler I needed in a large project. The expression parser is hard to get right, it has an elegant solution for the operator precedence rules.

定位托管语言是更容易的方法来实现。语言不应该太重要,它正在使它工作,这是真正的挑战。即使这是一个很容易获得托管代码工作。如果你想要定位C,你需要黑带机器代码skillz和深入了解目标文件格式和链接器。

Targeting a managed language is the easier way to get this going. The language shouldn't matter too much, it is getting it working that is the real challenge. Even though it is a lot easier to get managed code working. If you want to target C, you'll need black-belt machine code skillz and deep insight in the object file format and the linker.

这篇关于C#中的开源C编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 15:56