Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/bmourad01/eoc
- Owner: bmourad01
- License: gpl-3.0
- Created: 2021-01-13T20:04:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-03T22:54:48.000Z (almost 3 years ago)
- Last Synced: 2024-05-12T22:56:27.381Z (6 months ago)
- Language: OCaml
- Homepage:
- Size: 574 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 shellAdditionally, 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!`)