Skip to content

tingwei628/cool-compiler-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cool Compiler

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.

Assignment 1 - Lexical Analysis

Built a lexical analyzer using flex.

Assignment 2 - Parsing

Generated a LALR parser using bison that builds an abstract syntax tree (AST) for each program.

Assignment 3 - Semantic Analysis & Type Checking

Wrote the semantic analyzer which also does type checking. The analyzer reports any semantic errors and annotates the AST with type information.

Assignment 4 - Code Generation

Built a stack machine code generator for the 32-bit MIPS architecture.
Add AArch64 support

About

COOL compiler implementation for Stanford's CS143 open course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 64.9%
  • Perl 25.6%
  • Assembly 5.3%
  • Shell 1.3%
  • Yacc 0.9%
  • C 0.9%
  • Other 1.1%