SICP最后两章的简短解释

发布于 2024-10-03 19:27:40 字数 110 浏览 0 评论 0原文

有人能给我一个关于SICP(计算机程序的结构和解释)的最后两章、ch4元语言抽象和ch5寄存器机计算的清晰简洁的解释吗?

我还想知道这两章的内容是否(以及如何)与标准本科编译器课程有所不同。

Can anybody give me a clear and concise explanation of the last 2 chapters of SICP(structure and interpretation of computer programs), ch4 meta-linguistic abstraction and ch5 computing with register machines?

I'd also like to know if(and how) these two chapters differ in content from a standard undergraduate compiler course.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

許願樹丅啲祈禱 2024-10-10 19:27:40

长免责声明,下面的实际答案

如果您确实想要有关如何从头开始构建编译器的信息,并且需要了解所有相关的实用解析、编译、生成和优化技术,那么< href="https://rads.stackoverflow.com/amzn/click/com/0201100886" rel="noreferrer">龙书将是更好的选择。

如果您想使用解释器从头开始构建一种干净的编程语言,我会推荐 Friedman 的 EPL< /a> 书。

如果您的学士论文追求的是对前两本书中的所有基本问题有更深入的理解,那么请继续阅读我下面的回答。 SICP 是一部教育作品,它试图用尽可能清晰的语言传达基本概念。它不会详细介绍左递归解析器、公共子表达式消除、x86 SSE 扩展等。

SICP CH4-5

用于解释所涉及的复杂概念的技术是在您眼前从头开始构建一系列计算机语言。

第4章首先构建一个元循环Scheme解释器:一个用Scheme本身编写的小型Scheme解释器。这将为您提供递归解释器的基础知识,并为构建第 4-5 章其余部分中的一系列迷你语言奠定基础。它回答了如何表示解析后的代码、涉及哪些数据结构、如何将主机与基本语言分开等问题。
重要的是,它向您展示了语言解释器本身只是另一个计算机程序。
第 4 章的其余部分将向您展示如何通过修改以前的解释器来改变语言的风格。两大问题是惰性求值和逻辑编程。

第 5 章制作了“寄存器机”的粗略模型,以抽象级别表示您当前的计算机。他们构建了一种小型寄存器机器语言,可以作为所有意图和目的的汇编语言。他们介绍了下一步所需的所有数据结构和控制流结构:用这种机器语言构建方案解释器。某种程度上仍然类似于元循环解释器。然后,他们跳出深渊,用他们的寄存器机器语言构建了一个方案编译器;包括汇编步骤、尾递归优化、垃圾收集、词法寻址、跟踪等。

虽然 SICP 构建了玩具解释器和编译器,但它们在概念上足够完整,可以让您立即掌握当前实用技术。例如,GCC 的中间代码看起来很像 SICP 的寄存器机器代码,这些人为 ARM 微控制器实现了 SICP 的解释器直接组装。

Long Disclaimer, actual answer below

If you really want information about how to build a compiler from scratch and need to be up to speed with all the related practical parsing, compilation, generation and optimization techniques, then the dragon book would be the better option.

If you want to build a clean programming language from scratch using an interpreter, I would recommend Friedman's EPL book.

If what you are after with your bachelor paper is a deeper understanding of all the fundamental issues in both previous books, then read on to my answer below. SICP is an educational work, it tries to convey the essential concepts in a clear a language as possible. It will not go into details about left-recursive parsers, common sub-expression elimination, x86 SSE extensions and so forth.

SICP CH4-5

The technique used to explain the complex concepts involved is by constructing a series of computer languages from scratch before your eyes.

Chapter 4 starts by building a meta-circular Scheme interpreter: a small Scheme interpreter written in Scheme itself. This will give you the basics of a recursive interpreter, and forms a basis for the construction of a series of mini-languages in the rest of ch4-5. It answers the question of how to represent your parsed code, what datastructures are involved, how to separate the host from the base language, etc.
Importantly, it shows you that a language interpreter is itself just another computer program.
The rest of Chapter 4 shows you how you can vary the flavor of your language by modifying the previous interpreter. The two big ones are lazy evaluation and logic programming.

Chapter 5 makes a rough model of 'register machines', to represent your current day computer at an abstract level. They construct a little register machine language that acts as an assembly-language for all intents and purpose. They introduce all the datastructures and control flow constructs needed to do the next bit: building a scheme interpreter in this machine language. Somehow still similar to the meta-circular interpreter. Afterwards they jump off the deep end and construct a scheme compiler in their register machine language; complete with assembly step, tail-recursion optimization, garbage-collection, lexical addressing, tracing, etc.

Although SICP constructs toy interpreters and compilers, these are conceptually complete enough to get you up to speed in no time with current practical techniques. GCC's intermediate code looks a lot like SICP's register machine code for example and these guys implemented SICP's interpreter for ARM micro-controllers straight in assembly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文