Maintaining a balance between a theoretical and practical approach to this important subject, Elements of Compiler Design serves as an introduction to compiler writing for undergraduate students. From a theoretical viewpoint, it introduces rudimental models, such as automata and grammars, that underlie compilation and its essential phases. Based on these models, the author details the concepts, methods, and techniques employed in compiler design in a clear and easy-to-follow way. From a practical point of view, the book describes how compilation techniques are implemented. In fact, throughout the text, a case study illustrates the design of a new programming language and the construction of its compiler. While discussing various compilation techniques, the author demonstrates their implementation through this case study. In addition, the book presents many detailed examples and computer programs to emphasize the applications of the compiler algorithms.After studying this self-contained textbook, students should understand the compilation process, be able to write a simple real compiler, and easily follow advanced books on the subject.
Author(s): Alexander Meduna
Publisher: CRC Press
Year: 2007
Language: English
Pages: 292
Tags: Информатика и вычислительная техника;Системное программное обеспечение (СПО);
Cover......Page 1
Title Page......Page 5
Copyright......Page 6
Contents......Page 9
Preface......Page 11
Acknowledgement......Page 13
About the Author......Page 15
Sets and Sequences......Page 17
Languages......Page 18
Relations and Translations......Page 19
Graphs......Page 20
Proofs......Page 22
Compilation Phases......Page 24
1.3 Rewriting Systems......Page 31
Exercises......Page 35
2.1 Models......Page 37
2.2 Methods......Page 48
2.3.1 Transformation of Regular Expressions to Finite Automata......Page 58
2.3.2 Simplification of Finite Automata......Page 65
2.3.3 Non-Regular Lexical Constructs......Page 72
2.3.4 Decidable problems......Page 81
Exercises......Page 84
3.1 Models......Page 91
3.2 Methods......Page 105
3.3.1 Power of Parsing Models......Page 119
3.3.2 Verification of the Grammatical Syntax Specification......Page 120
3.3.3 Simplification of Grammars......Page 122
3.3.4 Grammatical Normal Forms and Parsing Based on Them......Page 132
3.3.5 Syntax that Grammars cannot Specify......Page 137
3.3.6 Decidable Problems......Page 144
Exercises......Page 145
4.1 Predictive Sets and LL Grammars......Page 155
Predictive Recursive-Descent Parsing......Page 161
Predictive Table-Driven Parsing......Page 164
Handling Errors......Page 168
Exercises......Page 173
Operator Precedence Parsing Algorithm......Page 175
Handling Errors......Page 179
Generalization......Page 182
Restriction......Page 183
LR Parsing Algorithm......Page 184
Handling Errors in LR Parsing......Page 194
Exercises......Page 199
6 Syntax-Directed Translation and Intermediate Code Generation......Page 201
6.1 Bottom-Up Syntax-Directed Translation and Intermediate Code Generation......Page 202
6.1.1 Syntax Trees......Page 203
6.1.2 Three-Address Code......Page 209
6.1.3 Polish Notation......Page 211
6.2 Top-Down Syntax-Directed Translation......Page 212
6.3 Semantic Analysis......Page 215
6.4 Symbol Table......Page 216
6.5 Software Tools for Syntax-Directed Translation......Page 220
Exercises......Page 227
7.1 Tracking the Use of Variables......Page 229
Basic blocks......Page 230
Use of Variables within a Block......Page 231
Use of Variables between Blocks......Page 235
7.2 Optimization of Intermediate Code......Page 237
7.3 Optimization and Generation of Target Code......Page 241
Exercises......Page 245
Conclusion......Page 249
A.1 Concept......Page 255
A.2 Code......Page 258
Bibliography......Page 271