This repository contains my C++ implementation of a COOL compiler.
COOL stands for Classroom Object Oriented Language and is a simple programming language used for teaching compilers in Stanford's CS143 open course. The course project consists of 4 programming assignments (one for each compiler phase) that assembled together constitute a complete COOL compiler.
Among other things COOL is:
- Object oriented supporting inheritance and dynamic dispatching.
- Statically typed, strongly typed and type safe.
- Garbage collected; memory is managed automatically.
Built a lexical analyzer using flex.
Generated a LALR parser using bison that builds an abstract syntax tree (AST) for each program.
Wrote the semantic analyzer which also does type checking. The analyzer reports any semantic errors and annotates the AST with type information.
Built a stack machine code generator for the 32-bit MIPS architecture.