现代编译原理--C语言描述(英文影印版)(享有“虎书”的称号,与有“龙书”之称的《编译原理》齐名)
基本信息
编辑推荐
本书享有“虎书”的称号,与有“龙书”之称的《编译原理》齐名。本书出版时间晚,内容新。 书中专门为学生提供了一个用 C 语言编写的实习项目,学生可以在一学期内创建一个功能完整的编译器。美国麻省理工学院等众多名校均采用本书作为编译原理课程的教材。
推荐阅读
内容简介回到顶部↑
本书是一本著名的编译原理课程的教材。国际上众多名校均采用本书作为编译原理课程的教材,包括美国麻省理工学院、加州大学伯克利分校、普林斯顿大学和英国剑桥大学等。本书在国外享有“虎书”的称号,与有“龙书”之称的《编译原理》(alfred aho 等编著)齐名。与编译原理方面的其他名著相比,本书出版时间晚,内容新。 书中专门为学生提供了一个用 c 语言编写的实习项目,包括前端和后端设计,学生可以在一学期内创建一个功能完整的编译器。
本书全面讲述了现代编译器的各个组成部分,包括:词法分析、语法分析、抽象语法、语义检查、中间代码表示、指令选择、数据流分析、寄存器分配以及运行时系统等。与大多数编译原理的教材不同,本书采用了函数语言和面向对象语言来描述代码生成和寄存器分配,对于编译器中各个模块之间的接口都给出了实际的 c 语言头文件。 全书分成两部分,第一部分是编译的基础知识,适用于第一门编译原理课程(一个学期);第二部分是高级主题,包括面向对象语言和函数语言、垃圾收集、循环优化、 ssa (静态单赋值)形式、循环调度、存储结构优化等,适合于专题选讲、后续课程或研究生教学。
本书适用于高等院校计算机及相关专业的本科生和研究生,也可供科研人员或者专业技术人员使用。
本书全面讲述了现代编译器的各个组成部分,包括:词法分析、语法分析、抽象语法、语义检查、中间代码表示、指令选择、数据流分析、寄存器分配以及运行时系统等。与大多数编译原理的教材不同,本书采用了函数语言和面向对象语言来描述代码生成和寄存器分配,对于编译器中各个模块之间的接口都给出了实际的 c 语言头文件。 全书分成两部分,第一部分是编译的基础知识,适用于第一门编译原理课程(一个学期);第二部分是高级主题,包括面向对象语言和函数语言、垃圾收集、循环优化、 ssa (静态单赋值)形式、循环调度、存储结构优化等,适合于专题选讲、后续课程或研究生教学。
本书适用于高等院校计算机及相关专业的本科生和研究生,也可供科研人员或者专业技术人员使用。
作译者回到顶部↑
本书提供作译者介绍
Andrew W.Appel 美国普林斯顿大学计算机科学系教授,第26届ACM SIGPLAN-SIGACT 程序设计原理年会大会执行主席,1998-1999年在贝尔实验室做研究工作。主要研究方向:计算机安全、编译器设计、程序设计语言等。除本书外,还出版了两本不同语言版本的编译原理教材:Modern Compiler mplementation in Java和Modern Compiler lmplementation in ML。
.. << 查看详细
.. << 查看详细
目录回到顶部↑
preface vii
part i fundamentals of compilation
1 introduction 3
1.1 modules and interfaces 4
1.2 tools and software 5
1.3 data structures for tree languages 7
2 lexical analysis 16
2.1 lexical tokens 17
2.2 regular expressions 18
2.3 finite automata 21
2.4 nondeterministic finite automata 24
2.5 lex: a lexical analyzer generator 30
3 parsing 39
3.1 context-free grammars 41
3.2 predictive parsing 46
3.3 lr parsing 56
3.4 using parser generators 69
3.5 error recovery 76
4 abstract syntax 88
4.1 semantic actions 88
part i fundamentals of compilation
1 introduction 3
1.1 modules and interfaces 4
1.2 tools and software 5
1.3 data structures for tree languages 7
2 lexical analysis 16
2.1 lexical tokens 17
2.2 regular expressions 18
2.3 finite automata 21
2.4 nondeterministic finite automata 24
2.5 lex: a lexical analyzer generator 30
3 parsing 39
3.1 context-free grammars 41
3.2 predictive parsing 46
3.3 lr parsing 56
3.4 using parser generators 69
3.5 error recovery 76
4 abstract syntax 88
4.1 semantic actions 88
前言回到顶部↑
Over the past decade, there have been several shifts in the way compilers arebuilt. New kinds of programming languages are being used: object-orientedlanguages with dynamic methods, functional languages with nested scopeand first-class function closures; and many of these languages require garbagecollection. New machines have large register sets and a high penalty for mem-ory access, and can often run much faster with compiler assistance in schedul-ing instructions and managing instructions and data for cache locality.
This book is intended as a textbook for a oneor two-semester coursein compilers. Students will see the theory behind different components of acompiler, the programming techniques used to put the theory into practice,and the interfaces used to modularize the compiler. To make the interfacesand prografnming examples clear and concrete, I have written them in the Cprogramming language. Other editions of this book are available that use theJava and ML languages.
Implementation project. The "student project compiler" that I have outlinedis reasonably simple, but is organized to demonstrate some important tech-niques that are now in common use: abstract syntax trees to avoid tangling syntax and semantics, separation of instruction selection from register alloca-tion, copy propagation to give flexibility to earlier phases of the compiler, and containment of target-machine dependencies. Unlike many "student compil-ers'' found in textbooks, this one has a simple but sophisticated back end,allowing good register allocation to be done after instruction selection.
Each chapter in Part I has a programming exercise corresponding to one module of a compiler. Software useful for the exercises can be found at
Exercises. Each chapter has pencil-and-paper exercises; those marked witha star are more challenging, two-star problems are difficult but solvable, and the occasional three-star exercises are not known to have a solution.Course sequence. The figure shows how the chapters depend on each other.
· A one-semester course could cover all of Part I (Chapters 1-12), with students implementing the project compiler (perhaps working in groups); in addition, lectures could cover selected topics from Part II.
· An advanced or graduate course could cover Part II, as well as additional topics from the current literature. Many of the Part II chapters can stand independently from Part I, so that an advanced course could be taught to students who have used a different book for their first course.
· In a two-quarter sequence, the first quarter could cover Chapters 1-8, and the second quarter could cover Chapters 9-12 and some chapters from Part II.
Acknowledgments. Many people have provided constructive criticism or helped me in other ways on this book. I would like to thank Leonor Abraido-Fandino, Scott Ananian, Stephen Bailey, Max Hailperin, David Hanson, Jef-frey Hsu, David MacQueen, Torben Mogensen, Doug Morgan, Robert Netzer,Elma Lee Noah, Mikael Petterson, Todd Proebsting, Anne Rogers, BarbaraRyder, Amr Sabry, Mooly Sagiv, Zhong Shao, Mary Lou Sofia, Andrew Tol-mach, Kwangkeun Yi, and Kenneth Zadeck.
This book is intended as a textbook for a oneor two-semester coursein compilers. Students will see the theory behind different components of acompiler, the programming techniques used to put the theory into practice,and the interfaces used to modularize the compiler. To make the interfacesand prografnming examples clear and concrete, I have written them in the Cprogramming language. Other editions of this book are available that use theJava and ML languages.
Implementation project. The "student project compiler" that I have outlinedis reasonably simple, but is organized to demonstrate some important tech-niques that are now in common use: abstract syntax trees to avoid tangling syntax and semantics, separation of instruction selection from register alloca-tion, copy propagation to give flexibility to earlier phases of the compiler, and containment of target-machine dependencies. Unlike many "student compil-ers'' found in textbooks, this one has a simple but sophisticated back end,allowing good register allocation to be done after instruction selection.
Each chapter in Part I has a programming exercise corresponding to one module of a compiler. Software useful for the exercises can be found at
Exercises. Each chapter has pencil-and-paper exercises; those marked witha star are more challenging, two-star problems are difficult but solvable, and the occasional three-star exercises are not known to have a solution.Course sequence. The figure shows how the chapters depend on each other.
· A one-semester course could cover all of Part I (Chapters 1-12), with students implementing the project compiler (perhaps working in groups); in addition, lectures could cover selected topics from Part II.
· An advanced or graduate course could cover Part II, as well as additional topics from the current literature. Many of the Part II chapters can stand independently from Part I, so that an advanced course could be taught to students who have used a different book for their first course.
· In a two-quarter sequence, the first quarter could cover Chapters 1-8, and the second quarter could cover Chapters 9-12 and some chapters from Part II.
Acknowledgments. Many people have provided constructive criticism or helped me in other ways on this book. I would like to thank Leonor Abraido-Fandino, Scott Ananian, Stephen Bailey, Max Hailperin, David Hanson, Jef-frey Hsu, David MacQueen, Torben Mogensen, Doug Morgan, Robert Netzer,Elma Lee Noah, Mikael Petterson, Todd Proebsting, Anne Rogers, BarbaraRyder, Amr Sabry, Mooly Sagiv, Zhong Shao, Mary Lou Sofia, Andrew Tol-mach, Kwangkeun Yi, and Kenneth Zadeck.








点击看大图





加载中...

