首选语言:C/ c++、Java、Ruby。
我正在寻找一些关于如何编写自己的编译器的有用书籍/教程,只是为了教育目的。我最熟悉C/ c++、Java和Ruby,所以我更喜欢包含这三者之一的资源,但任何好的资源都是可以接受的。
首选语言:C/ c++、Java、Ruby。
我正在寻找一些关于如何编写自己的编译器的有用书籍/教程,只是为了教育目的。我最熟悉C/ c++、Java和Ruby,所以我更喜欢包含这三者之一的资源,但任何好的资源都是可以接受的。
当前回答
来自comp.compiler常见问题解答:
《个人电脑编程》作者:Per Brinch Hansen Prentice-Hall 1982 ISBN 0-13-730283-5
这本书名很不幸的书 解释单用户编程环境的设计和创建 用于微电脑,使用一种类似pascal的语言,叫做Edison。作者介绍 一个的逐步实现的所有源代码和解释 爱迪生编译器和简单的支持操作系统,全部写在 爱迪生本身(除了一个小的支持内核写在符号 PDP 11/23汇编程序;完整的源代码也可以为IBM订购 个人电脑)。
这本书最有趣的地方是:1)它的能力 演示如何创建一个完整的,独立的,自我维护的, 有用的编译器和操作系统,以及2)有趣的讨论 语言设计和规范的问题和权衡。
“Brinch Hansen on Pascal Compilers” by Per Brinch Hansen 普伦蒂斯-霍尔 1985 ISBN 0-13-083098-4
Another light-on-theory heavy-on-pragmatics here's-how-to-code-it book. The author presents the design, implementation, and complete source code for a compiler and p-code interpreter for Pascal- (Pascal "minus"), a Pascal subset with boolean and integer types (but no characters, reals, subranged or enumerated types), constant and variable definitions and array and record types (but no packed, variant, set, pointer, nameless, renamed, or file types), expressions, assignment statements, nested procedure definitions with value and variable parameters, if statements, while statements, and begin-end blocks (but no function definitions, procedural parameters, goto statements and labels, case statements, repeat statements, for statements, and with statements).
编译器和解释器都是用Pascal* (Pascal " * ")编写的 Pascal子集扩展了一些爱迪生风格的创建功能 软件开发系统。用于IBM个人电脑的Pascal编译器由 但是很容易将这本书的Pascal编译器移植到任何作者 方便的Pascal平台。
本书使编译器的设计和实现看起来很简单。我 尤其是作者对质量的关注, 可靠性和测试。编译器和解释器可以很容易地使用 作为一个更复杂的语言或编译器项目的基础,特别是 如果你被要求快速启动并运行一些东西。
其他回答
Not included in the list so far is this book: Basics of Compiler Design (Torben Mogensen) (from the dept. of Computer Science, University of Copenhagen) I'm also interested in learning about compilers and plan to enter that industry in the next couple of years. This book is the ideal theory book to begin learning compilers as far as I can see. It's FREE to copy and reproduce, cleanly and carefully written and gives it to you in plain English without any code but still presents the mechanics by way of instructions and diagrams etc. Worth a look imo.
这里有很多很好的答案,所以我想在列表中再添加一个:
十多年前,我有一本叫做Project Oberon的书,里面有一些关于编译器的非常好的文字。这本书的真正突出之处在于,它的来源和解释都是非常实用和易读的。全文(2005年版)已以pdf格式提供,因此您可以立即下载。编译器将在第12章讨论:
http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf
尼克劳斯·沃斯,于尔格·古特克内西
(这本书的内容不像他关于编译器的书那么广泛)
我读过几本关于编译器的书,我可以第二龙书,花时间在这本书上是非常值得的。
抱歉,这是西班牙文,但这是阿根廷一门名为“Compiladores e Intérpretes”(编译器和口译员)的课程的参考书目。
这门课程从形式化语言理论到编译器构造,这些是你至少构建一个简单的编译器所需要的主题:
Compilers Design in C. Allen I. Holub Prentice-Hall. 1990. Compiladores. Teoría y Construcción. Sanchís Llorca, F.J. , Galán Pascual, C. Editorial Paraninfo. 1988. Compiler Construction. Niklaus Wirth Addison-Wesley. 1996. Lenguajes, Gramáticas y Autómatas. Un enfoque práctico. Pedro Isasi Viñuela, Paloma Martínez Fernández, Daniel Borrajo Millán. Addison-Wesley Iberoamericana (España). 1997. The art of compiler design. Theory and practice. Thomas Pittman, James Peters. Prentice-Hall. 1992. Object-Oriented Compiler Construction. Jim Holmes. Prentice Hall, Englewood Cliffs, N.J. 1995 Compiladores. Conceptos Fundamentales. B. Teufel, S. Schmidt, T. Teufel. Addison-Wesley Iberoamericana. 1995. Introduction to Automata Theory, Languages, and Computation. John E. Hopcroft. Jeffref D. Ullman. Addison-Wesley. 1979. Introduction to formal languages. György E. Révész. Mc Graw Hill. 1983. Parsing Techniques. A Practical Guide. Dick Grune, Ceriel Jacobs. Impreso por los autores. 1995 http://www.cs.vu.nl/~dick/PTAPG.html Yacc: Yet Another Compiler-Compiler. Stephen C. Johnson Computing Science Technical Report Nº 32, 1975. Bell Laboratories. Murray Hill, New Jersey. Lex: A Lexical Analyzer Generator. M. E. Lesk, E. Schmidt. Computing Science Technical Report Nº 39, 1975. Bell Laboratories. Murray Hill, New Jersey. lex & yacc. John R. Levine, Tony Mason, Doug Brown. O’Reilly & Associates. 1995. Elements of the theory of computation. Harry R. Lewis, Christos H. Papadimitriou. Segunda Edición. Prentice Hall. 1998. Un Algoritmo Eficiente para la Construcción del Grafo de Dependencia de Control. Salvador V. Cavadini. Trabajo Final de Grado para obtener el Título de Ingeniero en Computación. Facultad de Matemática Aplicada. U.C.S.E. 2001.
你可能想看看Lex/Yacc(或Flex/Bison,随便你怎么称呼它们)。Flex是一个词法分析器,它将解析和识别语言的语义组件(“标记”),而Bison将用于定义解析每个标记时发生的情况。这可以是,但绝对不限于,打印出C代码,供编译器编译成C,或者动态运行指令。
这个常见问题应该对你有帮助,这个教程看起来很有用。
资源清单:
A Nanopass Framework for Compiler Education ¶ Advanced Compiler Design and Implementation $ An Incremental Approach to Compiler Construction ¶ ANTLR 3.x Video Tutorial Basics of Compiler Design Building a Parrot Compiler Compiler Basics Compiler Construction $ Compiler Design and Construction $ Crafting a Compiler with C $ Crafting Interpreters [Compiler Design in C] 12 ¶ Compilers: Principles, Techniques, and Tools $ — aka "The Dragon Book"; widely considered "the book" for compiler writing. Engineering a Compiler $ Essentials of Programming Languages Flipcode Article Archive (look for "Implementing A Scripting Engine by Jan Niestadt") Game Scripting Mastery $ How to build a virtual machine from scratch in C# ¶ Implementing Functional Languages Implementing Programming Languages (with BNFC) Implementing Programming Languages using C# 4.0 Interpreter pattern (described in Design Patterns $) specifies a way to evaluate sentences in a language Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages $ Let's Build a Compiler by Jack Crenshaw — The PDF ¶ version (examples are in Pascal, but the information is generally applicable) Linkers and Loaders $ (Google Books) Lisp in Small Pieces (LiSP) $ LLVM Tutorial Modern Compiler Implementation in ML $ — There is a Java $ and C $ version as well - widely considered a very good book Object-Oriented Compiler Construction $ Parsing Techniques - A Practical Guide Project Oberon ¶ - Look at chapter 13 Programming a Personal Computer $ Programing Languages: Application and Interpretation Rabbit: A Compiler for Scheme¶ Reflections on Trusting Trust — A quick guide Roll Your Own Compiler for the .NET framework — A quick tutorial from MSDN Structure and Interpretation of Computer Programs Types and Programming Languages Want to Write a Compiler? - a quick guide Writing a Compiler in Ruby Bottom Up Compiling a Lisp — compile directly to x86-64
传说:
链接到PDF文件 $印刷书籍的链接