Compiler-a program that translates an executable program in one language into an executable program in another language
Interpreter-a program that reads an executable program and produces the results of running that program
Why do we care to study compiler construction
Compiler construction is a microcosm of computer science
greedy algorithms learning algorithms
graph algorithms union-find dynamic programming
DFAs for scanning parser generators lattice theory for analysis Systems
allocation and naming locality synchronization
pipeline management hierarchy management instruction set use
Is Compiler construction not a solved problem?
Machines are constantly changing
Changes in architecture changes in compilers
new features pose new problems
changing costs lead to different concerns
old solutions need re-engineering
Innovations in compilers should prompt changes in architecture New languages and features
What qualities are important in a good compiler?
1. Correct code
2. Output runs fast
3. Compiler runs fast
4. Compile time proportional to program size
5. Support for separate compilation
6. Good diagnostics for syntax errors
7. Works well with the debugger
8. Good diagnostics for ﬂow anomalies
9. Cross language calls
10. Consistent, predictable optimization
What role does a Scanner plays in a compiler?
map characters to tokens
character string value for a token is a lexeme
eliminate white space
character string value for a token is a lexeme, Typical tokens: id, number, do, end …, Key issue is speed
Why the need for Parser?
recognize context-free syntax
guide context-sensitive analysis
produce meaningful error messages
attempt error correction
Define a Context-free grammar-
Context-free syntax is specified with a grammar, usually in Backus-Naur form (BNF)
How are context-free grammars specified?
Please join StudyMode to read the full document