| |
| |
Preface | |
| |
| |
| |
Introduction | |
| |
| |
| |
Levels of programming language | |
| |
| |
| |
Programming language processors | |
| |
| |
| |
Specification of programming languages | |
| |
| |
| |
Syntax | |
| |
| |
| |
Contextual constraints | |
| |
| |
| |
Semantics | |
| |
| |
| |
Case study: the programming language Triangle | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Language Processors | |
| |
| |
| |
Translators and compilers | |
| |
| |
| |
Interpreters | |
| |
| |
| |
Real and abstract machines | |
| |
| |
| |
Interpretive compilers | |
| |
| |
| |
Portable compilers | |
| |
| |
| |
Bootstrapping | |
| |
| |
| |
Bootstrapping a portable compiler | |
| |
| |
| |
Full bootstrap | |
| |
| |
| |
Half bootstrap | |
| |
| |
| |
Bootstrapping to improve efficiency | |
| |
| |
| |
Case study: the Triangle language processor | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Compilation | |
| |
| |
| |
Phases | |
| |
| |
| |
Syntactic analysis | |
| |
| |
| |
Contextual analysis | |
| |
| |
| |
Code generation | |
| |
| |
| |
Passes | |
| |
| |
| |
Multi-pass compilation | |
| |
| |
| |
One-pass compilation | |
| |
| |
| |
Compiler design issues | |
| |
| |
| |
Case study: the Triangle compiler | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Syntactic Analysis | |
| |
| |
| |
Subphases of syntactic analysis | |
| |
| |
| |
Tokens | |
| |
| |
| |
Grammars revisited | |
| |
| |
| |
Regular expressions | |
| |
| |
| |
Extended BNF | |
| |
| |
| |
Grammar transformations | |
| |
| |
| |
Starter sets | |
| |
| |
| |
Parsing | |
| |
| |
| |
The bottom-up parsing strategy | |
| |
| |
| |
The top-down parsing strategy | |
| |
| |
| |
Recursive-descent parsing | |
| |
| |
| |
Systematic development of a recursive-descent parser | |
| |
| |
| |
Abstract syntax trees | |
| |
| |
| |
Representation | |
| |
| |
| |
Construction | |
| |
| |
| |
Scanning | |
| |
| |
| |
Case study: syntactic analysis in the Triangle compiler | |
| |
| |
| |
Scanning | |
| |
| |
| |
Abstract syntax trees | |
| |
| |
| |
Parsing | |
| |
| |
| |
Error handling | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Contextual Analysis | |
| |
| |
| |
Identification | |
| |
| |
| |
Monolithic block structure | |
| |
| |
| |
Flat block structure | |
| |
| |
| |
Nested block structure | |
| |
| |
| |
Attributes | |
| |
| |
| |
Standard environment | |
| |
| |
| |
Type checking | |
| |
| |
| |
A contextual analysis algorithm | |
| |
| |
| |
Decoration | |
| |
| |
| |
Visitor classes and objects | |
| |
| |
| |
Contextual analysis as a visitor object | |
| |
| |
| |
Case study: contextual analysis in the Triangle compiler | |
| |
| |
| |
Identification | |
| |
| |
| |
Type checking | |
| |
| |
| |
Standard environment | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Run-Time Organization | |
| |
| |
| |
Data representation | |
| |
| |
| |
Primitive types | |
| |
| |
| |
Records | |
| |
| |
| |
Disjoint unions | |
| |
| |
| |
Static arrays | |
| |
| |
| |
Dynamic arrays | |
| |
| |
| |
Recursive types | |
| |
| |
| |
Expression evaluation | |
| |
| |
| |
Static storage allocation | |
| |
| |
| |
Stack storage allocation | |
| |
| |
| |
Accessing local and global variables | |
| |
| |
| |
Accessing nonlocal variables | |
| |
| |
| |
Routines | |
| |
| |
| |
Routine protocols | |
| |
| |
| |
Static links | |
| |
| |
| |
Arguments | |
| |
| |
| |
Recursion | |
| |
| |
| |
Heap storage allocation | |
| |
| |
| |
Heap management | |
| |
| |
| |
Explicit storage deallocation | |
| |
| |
| |
Automatic storage deallocation and garbage collection | |
| |
| |
| |
Run-time organization for object-oriented languages | |
| |
| |
| |
Case study: the abstract machine TAM | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Code Generation | |
| |
| |
| |
Code selection | |
| |
| |
| |
Code templates | |
| |
| |
| |
Special-case code templates | |
| |
| |
| |
A code generation algorithm | |
| |
| |
| |
Representation of the object program | |
| |
| |
| |
Systematic development of a code generator | |
| |
| |
| |
Control structures | |
| |
| |
| |
Constants and variables | |
| |
| |
| |
Constant and variable declarations | |
| |
| |
| |
Static storage allocation | |
| |
| |
| |
Stack storage allocation | |
| |
| |
| |
Procedures and functions | |
| |
| |
| |
Global procedures and functions | |
| |
| |
| |
Nested procedures and functions | |
| |
| |
| |
Parameters | |
| |
| |
| |
Case study: code generation in the Triangle compiler | |
| |
| |
| |
Entity descriptions | |
| |
| |
| |
Constants and variables | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Interpretation | |
| |
| |
| |
Iterative interpretation | |
| |
| |
| |
Iterative interpretation of machine code | |
| |
| |
| |
Iterative interpretation of command languages | |
| |
| |
| |
Iterative interpretation of simple programming languages | |
| |
| |
| |
Recursive interpretation | |
| |
| |
| |
Case study: the TAM interpreter | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
| |
Conclusion | |
| |
| |
| |
The programming language life cycle | |
| |
| |
| |
Design | |
| |
| |
| |
Specification | |
| |
| |
| |
Prototypes | |
| |
| |
| |
Compilers | |
| |
| |
| |
Error reporting | |
| |
| |
| |
Compile-time error reporting | |
| |
| |
| |
Run-time error reporting | |
| |
| |
| |
Efficiency | |
| |
| |
| |
Compile-time efficiency | |
| |
| |
| |
Run-time efficiency | |
| |
| |
| |
Further reading | |
| |
| |
Exercises | |
| |
| |
Projects with the Triangle language processor | |
| |
| |
Appendices | |
| |
| |
| |
Answers to Selected Exercises | |
| |
| |
| |
Informal Specification of the Programming Language Triangle | |
| |
| |
| |
Introduction | |
| |
| |
| |
Commands | |
| |
| |
| |
Expressions | |
| |
| |
| |
Value-or-variable names | |
| |
| |
| |
Declarations | |
| |
| |
| |
Parameters | |
| |
| |
| |
Type-denoters | |
| |
| |
| |
Lexicon | |
| |
| |
| |
Programs | |
| |
| |
| |
Description of the Abstract Machine TAM | |
| |
| |
| |
Storage and registers | |
| |
| |
| |
Instructions | |
| |
| |
| |
Routines | |
| |
| |
| |
Class Diagrams for the Triangle Compiler | |
| |
| |
| |
Compiler | |
| |
| |
| |
Abstract syntax trees | |
| |
| |
| |
Commands | |
| |
| |
| |
Expressions | |
| |
| |
| |
Value-or-variable names | |
| |
| |
| |
Declarations | |
| |
| |
| |
Parameters | |
| |
| |
| |
Type-denoters | |
| |
| |
| |
Terminals | |
| |
| |
| |
Syntactic analyzer | |
| |
| |
| |
Contextual analyzer | |
| |
| |
| |
Code generator | |
| |
| |
Bibliography | |
| |
| |
Index | |