有什么好的编译资源?
不耐烦的摘要:我正在寻找有关为通用语言结构生成代码而不是解析的良好参考。
我对编程语言感兴趣,并尝试尽可能多地阅读文献。但是它们中的大多数都是从功能和理论的角度涵盖该主题的,我发现它们很难理解,更不用说实现这些想法了。
所以问题是;我们建议使用哪些资源来以更必要和更实际的方式涵盖该主题的编程语言实现?
例如,我发现" Lua 5.0的实现"文件很有启发性。
请注意,我并不是在寻找有关解析或者标记化的文章。
解决方案
这是一堆好教科书:
Java的现代编译器实现(老虎书籍)
A.W.阿佩尔
剑桥大学出版社,1998年
书号0-52158-388-8
关于编译器实现的教科书教程,包括许多语言功能的技术
编译器:原理,技巧和工具(Dragon book)
Aho,Lam,Sethi和Ullman
艾迪生·韦斯利(2006年)
书号0321486811
经典的编译器教科书,尽管其前端重点反映了它的年代。
高级编译器设计和实现(鲸鱼书)
史蒂文·莫尼克(Steven Muchnick)
摩根考夫曼出版社,1997年
书号1-55860-320-4
本质上是一本关于优化的食谱书;非常完整,适合工业从业人员和研究人员。
工程编译器(方舟书)
基思·库珀(Keith D. Cooper),琳达·托尔宗(Linda Torczon)
摩根考夫曼出版社,2003年
书号1-55860-698-X
一本现代的课堂教科书,越来越强调后端和实施技术。
针对现代架构优化编译器
兰迪·艾伦和肯·肯尼迪
摩根考夫曼出版社,2001年
书号1-55860-286-0
一本现代的教科书,着重于优化,包括并行化和内存层次结构优化。
编程语言语用学
迈克尔·斯科特(Michael L.Scott)
摩根·考夫曼出版社,2005年
书号0126339511
紫龙书是有史以来最好的书。
Bjarne Stroustrup撰写的C ++的Design and Evolution,虽然代码很少,但主要讨论了在设计语言时的权衡问题和其他问题。
尝试查看LLVM项目及其出版物和教程。
我建议与ANTLR一起玩。我曾经使用过一段时间,发现它非常易于使用。
我最喜欢的是罗伯特·摩根(Robert Morgan)的"构建优化的编译器"。非常实用,涵盖了静态单项分配。
另一个提示:不要开始钻研海湾合作委员会;这太复杂了。我们想从一开始就进行更多的研究和简化,我建议我们研究一下用Java编写的Java编译器或者用Erlang编写的Erlang编译器。
"龙"和"虎"书(见上文)均非常出色,尽管我发现"虎"(阿佩尔)书有些密集。我也非常喜欢David Galles的Modern Compiler Design。至于有助于我们理解的工具和实用程序,建议我们查看以下一项或者多项内容:
- 用于lex和解析器生成的JavaaCC
- 用于lex和解析器生成的Grammatica
- Jasmin和Jasper用于代码生成
我喜欢Nicolas Wirth的《编译器构造》,但这也许是因为学习(Turbo)Pascal才使我决定进入计算机科学领域。
http://www-old.oberon.ethz.ch/WirthPubl/CBEAll.pdf
据推测(我读过它,但还没有读完),一种增量式编译器构建方法非常出色。它描述了作者如何教授其编译器课程。
从摘要:
Compilers are perceived to be magical artifacts, carefully crafted by the wizards, and unfathomable by the mere mortals. Books on compilers are better described as wizard-talk: written by and for a clique of all-knowing practitioners. Real-life compilers are too complex to serve as an educational tool. And the gap between real-life compilers and the educational toy compilers is too wide. The novice compiler writer stands puzzled facing an impenetrable barrier, “better write an interpreter instead.” The goal of this paper is to break that barrier. We show that building a compiler can be as easy as building an interpreter. The compiler we construct accepts a large subset of the Scheme programming language and produces assembly code for the Intel-x86 architecture, the dominant architecture of personal computing. The development of the compiler is broken into many small incremental steps. Every step yields a fully working compiler for a progressively expanding subset of Scheme. Every compiler step produces real assembly code that can be assembled then executed directly by the hardware. We assume that the reader is familiar with the basic computer architecture: its components and execution model. Detailed knowledge of the Intel-x86 architecture is not required. The development of the compiler is described in detail in an extended tutorial. Supporting material for the tutorial such as an automated testing facility coupled with a comprehensive test suite are provided with the tutorial. It is our hope that current and future implementors of Scheme find in this paper the motivation for developing high-performance compilers and the means for achieving that goal.