在C#开源C编译器? [英] Open source C compiler in C#?

查看:227
本文介绍了在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 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编译器,而不是一个.NET或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:

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

推荐答案

您将有一个很难找到样本code。编译器编写者使用引导。第一个C编译器是写在B.然后将其用来写第一个C ++编译器。这是用来写C#编译器。这是非常普遍用于编写托管code编译器。

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.

这是不是有史以来去倒退的过程。尽管副作用的方法是共同的,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编译器code在附录中。用C编写的我写一个基本的编译器,我需要在一个大的项目时使用它的一部分。这位前pression解析器是很难得到正确的,它为运营商precedence规则的一流解决方案。

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.

定位托管语言是更简单的方法来获得这个部落格。语言不应该的问题太多,是得到了工作那才是真正的挑战。即使它是一个的很多的容易获得托管code工作。如果你想目标C,你需要在目标文件格式和链接黑色皮带机code的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编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆