Lecture 10: Mini Language Compiler
- Chapter 5 (sec. 1-5) of the text (Basic Semantics - Symbol Table)
- Chapter 7 (sec. 1-3) of the text (Control I - Expressions and Statements)
- Chapter 8 (sec. 1-4) of the text (Control II - Procedures)
This lecture shows how to write a compiler that translates Mini Language
programs to programs that execute on a simpler model of computation, namely
a bounded memory random access machine with a single accumulator. The compiler
uses the same infrastructure for parsing that the Mini Language Interpreter
- Random Access Machine (RAM) model.
- Random Access Machine Assembly Language (RAL)
- Compiling Mini Language expressions and statements to RAL
- Symbol Table, Memory Model and Linking symbolic RAL programs.
- Simple optimizations
- Adding support for procedures
- Activation records and local variables
- Parameter passing
- return statement
- Call stack
- ram.h - interface for RAM simulator class
- ram.cpp - implementation of RAM simulator
- main.cpp - main program to run RAM simulator
- prog.txt - sample RAM program
- mem.txt - sample RAM memory configuration
Created: June 4, 2007 by jjohnson AT cs DOT drexel DOT edu
- Implement the compiler as outlined in the lecture notes.
Use Mini Language
Interpreter (i.e. add translate method and code attribute to store
and construct code).
- Add optimizations to compiler
- Add support for functions to your compiler.