Comp 388-005 Week 6
Lewis Tower 415, 4:15-8:15
Welcome
Readings:
Mini-Java Compiler
See compiler.html
parsing: a, b, c, d, e are specific symbols, A, B, C are
higher-level constructs
A ::= a A | b B
B ::= c C { c e C }
C ::= d [ e C ]
We can parse this language with
parseA: if (token=a) {accept(a);
parseA();}
else {accept(b); parseB();}
parseB: accept(c); parseC(); while
(token==c) {accept(c); accept(e); parseC();}
parseC: accept(d); if (token==e)
{accept(e); parseC();}
stackmachine
internal structure
opcodes
Memory layout; global vs local variables
Declaration nesting
Symbol tables
LG hack
symboltable1.cs
machine code
recursive-descent compilation
- assignment statements
- compound statements
- while statements
- if statements
- function calls
- recursion
CompileExprN
Zuul
Demo