ed-o-saurus / Rust-coolc

A compiler for COOL implemented in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

COOL Compiler in Rust

What is COOL?

COOL is the Classroom Object Oriented Language which was created by Professor Alex Aiken for the purpose of teaching compiler design. A complete description can be found in the The COOL Reference Manual.

What is the Purpose of this Project?

Several years ago, I took an online version of Prof Aiken's compilers course. The course had a series of challenging projects that, together, formed a functioning compiler. Recently, I wanted to learn Rust. To that end, I decided to implement a COOL compiler entirely in Rust.

Building the Compiler

In order to build the compiler, you must have the Rust compiler installed. More information is available at https://www.rust-lang.org/. Building the compiler is accomplished in the standard way:

> cargo build

Using the Compiler

Running the Compiler

To compile COOL source files (i.e. file1.cl, file2.cl)

> ./coolc file1.cl file2.cl

By default, the output assembly file is the name of the first source file with a .s extension. The output can be set is the -o option.

> ./coolc file1.cl file2.cl -o output.s

Executing

The output of coolc is MIPS assembly intended to run on the SPIM emulator.

In addition to installing SPIM, you must obtain the COOL trap.handler file.

To run the assembly file (i.e. name.s), run

> spim -exception_file trap.handler -file name.s

About

A compiler for COOL implemented in Rust

License:GNU General Public License v3.0


Languages

Language:Rust 100.0%