Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bmourad01/eoc

A compiler for a subset of Typed Racket.
https://github.com/bmourad01/eoc

Last synced: 3 months ago
JSON representation

A compiler for a subset of Typed Racket.

Awesome Lists containing this project

README

        

# eoc

Implementation of a compiler from a subset of Typed Racket to AMD64, based on the book [Essentials of Compilation](https://github.com/IUCompilerCourse/Essentials-of-Compilation) by Jeremy Siek.

# Requirements

- OCaml (>= 4.08)
- nasm (>= 2.15.05)
- a C99-compatible C compiler
- a POSIX-compliant shell

Additionally, the following OCaml packages are required:

- core_kernel (>= 0.14.0)
- dune (>= 2.8.0)
- menhir
- ocamlgraph (>= 2.0.0)
- ppx_compare
- ppx_hash
- ppx_let
- ppx_sexp_conv

# Instructions

For building the project, run `dune build`. To compile a program, run `./compile .rkt`. To execute the compiled program, run `./output/`.

# Target Machine

First of all, the compiler targets AMD64 (otherwise known as x86-64 to mindless plebians) and follows the System V ABI for the most part (floating-point numbers are handled in a non-standard way).

Given this, the output assembly programs should work fine on a corresponding Linux system.
Other systems have not been tested, though BSD should work fine with a normal GNU toolchain.
macOS systems will require some adjustments for the handling of symbol names.
Windows systems follow a [different ABI](https://en.wikipedia.org/wiki/X86_calling_conventions#Microsoft_x64_calling_convention), so some work would be needed to ensure compatibility.

# Features Implemented

- Integers, booleans, floating-point numbers
- Basic arithmetic and bitwise operations
- Let-binding
- If-then-else expressions
- Register allocation with move biasing
- Heap-allocated objects (tuples via `vector`) and stop-and-copy garbage collection
- Top-level functions via `define`
- Anonymous functions via `lambda`
- Loops (via `while`), sequencing (via `begin`, `when`, and `unless`), and assignment (via `set!`)