首选语言:C/ c++、Java、Ruby。
我正在寻找一些关于如何编写自己的编译器的有用书籍/教程,只是为了教育目的。我最熟悉C/ c++、Java和Ruby,所以我更喜欢包含这三者之一的资源,但任何好的资源都是可以接受的。
首选语言:C/ c++、Java、Ruby。
我正在寻找一些关于如何编写自己的编译器的有用书籍/教程,只是为了教育目的。我最熟悉C/ c++、Java和Ruby,所以我更喜欢包含这三者之一的资源,但任何好的资源都是可以接受的。
当前回答
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.
其他回答
每当我想尝试一种新的语言想法时,我就写一个简单的解析器,让它生成一些容易获得良好编译器的语言,比如C。
你认为c++是如何完成的?
我正在研究同样的概念,发现了Joel Pobar写的一篇很有前景的文章,
为.NET框架创建一个语言编译器-不知道它去了哪里
为.NET框架创建一个语言编译器-原始文档的pdf副本
他讨论了编译器的高级概念,并为. net框架发明了自己的语言。尽管它的目标是。net框架,但其中的许多概念应该能够被复制。文章内容包括:
语言的定义 扫描仪 解析器(位我主要感兴趣) 针对。net框架的 代码生成器
还有其他的话题,但你得到的只是。
它面向初学者,用c#(不完全是Java)编写。
HTH
骨头
我发现Dragon的书太难读了,因为它太专注于语言理论,而实际上编写编译器并不需要这些理论。
我将添加Oberon书籍,其中包含了一个惊人的快速和简单的Oberon编译器项目Oberon的完整源代码。
如果你像我一样,没有受过正规的计算机科学教育,并且对 构建/想知道编译器是如何工作的:
我推荐“Java编程语言处理器:编译器和解释器”, 对于自学成才的计算机程序员来说,这是一本令人惊叹的书。
在我看来,理解那些基本的语言理论、自动化机器和集合理论并不是什么大问题。问题是如何把这些东西转换成代码。上面的书告诉您如何编写解析器、分析上下文和生成代码。如果你不能理解这本书,那么我不得不说,放弃构建编译器吧。这本书是我读过的最好的编程书。
还有一本书,也很好,《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文件 $印刷书籍的链接