| |
| |
| |
Introduction | |
| |
| |
Why Study Compilers? | |
| |
| |
Basic Compiler Design | |
| |
| |
Phases of Compilation | |
| |
| |
| |
Lexical Analysis | |
| |
| |
File Processing and Tokens | |
| |
| |
Deterministic Finite Automata | |
| |
| |
Regular Expressions | |
| |
| |
JavaCC -- A Lexical Analyzer and Parser Generator | |
| |
| |
Creating a Lexical Analyzer for simpleJav using JavaCC | |
| |
| |
Lex - A Lexical Analyzer Generator | |
| |
| |
Exercises | |
| |
| |
| |
Context-Free Grammars | |
| |
| |
Context-Free Grammar Defintion | |
| |
| |
Derivations | |
| |
| |
CFG Shorthand | |
| |
| |
Parse Trees | |
| |
| |
Ambiguous Grammars | |
| |
| |
Extended Bakus Naur Form | |
| |
| |
Exercisees | |
| |
| |
| |
Top-Down Parsing | |
| |
| |
Recursive Descent Parsers | |
| |
| |
Grammars That Are Not LL(1) | |
| |
| |
LL(k) Parsers | |
| |
| |
JavaCC -- A LL(k) Parser Generator | |
| |
| |
Writing a Parser for simpleJava Using JavaCC | |
| |
| |
Exercises | |
| |
| |
| |
Bottom-up Parsing | |
| |
| |
Rightmost Parsers | |
| |
| |
Creating LR Parse Tables | |
| |
| |
Yacc - Yet ANother Compiler Compiler | |
| |
| |
Exercises | |
| |
| |
| |
Abstract Syntax Trees | |
| |
| |
Abstract Syntax Tree Definition | |
| |
| |
Implementing Trees in Java | |
| |
| |
JavaCC Actions | |
| |
| |
Creating an Abstract Syntax Tree for simpleJava using JavaCC | |
| |
| |
Working with Abstract Syntax Trees in C | |
| |
| |
Exercises | |
| |
| |
| |
Semantic Analysis | |
| |
| |
Semantic Errors | |
| |
| |
Environments | |
| |
| |
Type Checking | |
| |
| |
Semantic Analyzer Overview | |
| |
| |
Implementing a Semantic Analyzer for simpleJava in Java | |
| |
| |
Semantic Analyzer Project in Java | |
| |
| |
Implementing a Semantic Analyzer for simpleJava in C | |
| |
| |
Exercises | |
| |
| |
| |
Creating Assembly Trees | |
| |
| |
Implementing Variables | |
| |
| |
Abstract Assembly | |
| |
| |
Creating Abstract Assembly | |
| |
| |
Creating Abstract Assembly Trees in Java | |
| |
| |
Building Assembly Trees for simpleJava in Java | |
| |
| |
Creating Abstract Assembly Trees in C | |
| |
| |
Exercises | |
| |
| |
| |
Code Genearation | |
| |
| |
Target Assembly Code | |
| |
| |
Simple Tiling | |
| |
| |
More Sophisticated Tiling | |
| |
| |
Extended Example | |
| |
| |
Code Generation in Java | |
| |
| |
Code Generation in C | |
| |
| |
Code Generation For x86 | |
| |
| |
Exercises | |
| |
| |
| |
Memory Management | |
| |
| |
a aStatic Storage | |
| |
| |
Heap-Based Storage | |
| |
| |
Programmer-Controlled Deallocation a aa aAutomatic Deallocation -- Garbage Collection | |
| |
| |
Creating a Programmer-Controlled Memory Manager For simpleJava a | |
| |
| |
Creating a Garbage Collector for simpleJava | |
| |
| |
Exercises | |
| |
| |
| |
Object-Oriented Extensions | |
| |
| |
Methods in Classes | |
| |
| |
Inheritance | |
| |
| |
Access Control | |
| |
| |
Function and Method Overloading | |
| |
| |
Recursive Classes | |
| |
| |
Virtual Methods | |
| |
| |
| |
asimpleJava Reference Manual | |
| |
| |
Tokens aa Comments | |
| |
| |
Program Structure | |
| |
| |
Expressions | |
| |
| |
Statements | |
| |
| |
Built-in Functions aa Sample simpleJava Programs | |
| |
| |
| |
How Lexical Analyzer Generators Work | |
| |
| |
Non-Deterministic Finite Automata | |
| |
| |
Converting a Regular Expression into a NFA | |
| |
| |
Converting a NFA Into a DFA | |
| |
| |
State Minimization of Deterministic Finte Automata | |
| |
| |
Multiple Types of Final States | |
| |
| |
Converting a DFA unto Code | |
| |
| |
Extended Example | |
| |
| |
Exercises | |