可以自行编译的*概念上*最小的*编译器*是什么? [英] What is the *conceptually* smallest *compiler* that can compile itself?

查看:18
本文介绍了可以自行编译的*概念上*最小的*编译器*是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本着这个问题的精神,我我想问一个类似的问题,但关于编译器,而不是关于解释器.

In the spirit of this question, I'd like to ask a similar question, but about compilers, not about interpreters.

什么是概念上最小的编译器,可以编译自己的代码?

What is the conceptually smallest compiler that can compile its own code?

当我说概念上最小的"时,我的意思是它只使用非常基本的概念并从那里构建,而不是它包含非常短的代码.为什么这是一个重要区别的一个例子是 OTCC 一个非常小的 C 编译器,它很小,因为它被混淆了,不一定是因为它在概念上很简单(它也可能在概念上很简单,但我不知道;它被混淆了).

When I say "conceptually smallest" I mean that it uses only very basic concepts and builds up from there, rather than that it contains very short code. An example of why this is an important distinction is OTCC a very tiny C compiler which is small because it's obfuscated, not necessarily because it is conceptually simple (it may also be conceptually simple, but I don't know; it's obfuscated).

我还想补充一点,以下也可能是一个概念上非常小的程序,但它实际上并没有告诉我们发生了什么,所以它也不是我真正想要的:

I would also like to add that the following also might be a very conceptually small program, but it doesn't actually tell us anything about what's going on, so it's not really what I'm looking for either:

(writefile argv[2] (generate (parse (readfile argv[1]))))

我真正想要的是一种语言:

What I'm really looking for is a language that is:

  1. 图灵完备.
  2. 能够自行编译.

我对此很感兴趣,因为

  1. 这将是一个有趣的案例研究,并且
  2. 它可以作为引导编译器的起点.

如果它不存在,我可以自己写.:)

If it doesn't exist, I may just write it myself. :)

推荐答案

我不太清楚你所说的概念上最小"是什么意思.大概您对 最小图灵机 中的表示不感兴趣href="http://compilers.iecc.com/comparch/article/03-02-038" rel="noreferrer">Lambda 演算?如果您在谈论物理编译器实现,那么您实际上是在谈论生成机器代码指令的编译器.Anthony Mills 的评论中提到的 TCC 是相关的.另一个应该有实际应用的有趣讨论是这个详细的 对从头开始编写的引导编译器的描述.

I'm not really clear what you mean by 'conceptually smallest'. Presumably you're not interested in minimal Turing machines or representations in Lambda calculus? If you're talking about physical compiler implementations, then you're really talking about a compiler that generates machine code instructions. TCC, as mentioned by Anthony Mills' comment, is relevant. Another interesting discussion that should have practical application is this detailed description of a bootstrapping compiler written from scratch.

不久前有一个有趣的讨论.值得一试的编译器新闻组.

There was an interesting discussion a while back on the comp.compilers newsgroup that's worth checking out.

这篇关于可以自行编译的*概念上*最小的*编译器*是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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