A flow chart shows the stages of the compiler.

1. The lexer turns program.c into a token list.

2. The parser turns the token list into an abstract syntax tree.

3. Semantic analysis turns the AST into a transformed AST. It has three steps:

a. Identifier resolution

b. Type checking

c. Loop Labeling

4. TACKY Generation turns the transformed AST into TACKY.

5. Assembly generation turns TACKY into assembly. It has three steps:

a. Converting TACKY to Assembly

b. Replacing Pseudoregisters

c. Instruction Fix-Up

6. Code emission writes assembly to program.s.

Return to text

Get Writing a C Compiler now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.