The big picture
C- Compiler
Write a C- program and follow it through scanning, parsing, semantic analysis, three-address code, and TINY Machine code, then run it.
- Lecture reference: Intro (cont’d): Compiler architecture
- Lecture reference: Introduction to Parsing
- Lecture reference: Ambiguity, Precedence, Associativity & Top-Down Parsing
- Lecture reference: Intro: Compilers, interpreters, and language processors
The program compiled.
Lecture reference: Intro (cont’d): Compiler architectureSource
The numbers input() reads, in order, separated by spaces or line breaks.
Compilation
| Line:col | Token | Lexeme | Value |
|---|---|---|---|
| 5:1 | "int" | ||
| 5:5 | "gcd" | ||
| 5:8 | "(" | ||
| 5:9 | "int" | ||
| 5:13 | "u" | ||
| 5:14 | "," | ||
| 5:16 | "int" | ||
| 5:20 | "v" | ||
| 5:21 | ")" | ||
| 6:1 | "{" | ||
| 7:3 | "if" | ||
| 7:6 | "(" | ||
| 7:7 | "v" | ||
| 7:9 | "==" | ||
| 7:12 | "0" | 0 | |
| 7:13 | ")" | ||
| 8:5 | "return" | ||
| 8:12 | "u" | ||
| 8:13 | ";" | ||
| 9:3 | "return" | ||
| 9:10 | "gcd" | ||
| 9:13 | "(" | ||
| 9:14 | "v" | ||
| 9:15 | "," | ||
| 9:17 | "u" | ||
| 9:19 | "-" | ||
| 9:21 | "u" | ||
| 9:23 | "/" | ||
| 9:25 | "v" | ||
| 9:27 | "*" | ||
| 9:29 | "v" | ||
| 9:30 | ")" | ||
| 9:31 | ";" | ||
| 10:1 | "}" | ||
| 12:1 | "void" | ||
| 12:6 | "main" | ||
| 12:10 | "(" | ||
| 12:11 | "void" | ||
| 12:15 | ")" | ||
| 13:1 | "{" | ||
| 14:3 | "int" | ||
| 14:7 | "a" | ||
| 14:8 | ";" | ||
| 15:3 | "int" | ||
| 15:7 | "b" | ||
| 15:8 | ";" | ||
| 16:3 | "a" | ||
| 16:5 | "=" | ||
| 16:7 | "input" | ||
| 16:12 | "(" | ||
| 16:13 | ")" | ||
| 16:14 | ";" | ||
| 17:3 | "b" | ||
| 17:5 | "=" | ||
| 17:7 | "input" | ||
| 17:12 | "(" | ||
| 17:13 | ")" | ||
| 17:14 | ";" | ||
| 18:3 | "output" | ||
| 18:9 | "(" | ||
| 18:10 | "gcd" | ||
| 18:13 | "(" | ||
| 18:14 | "a" | ||
| 18:15 | "," | ||
| 18:17 | "b" | ||
| 18:18 | ")" | ||
| 18:19 | ")" | ||
| 18:20 | ";" | ||
| 19:1 | "}" | ||
| 20:1 | ENDFILE | "" |