• Stars
    star
    112
  • Rank 301,855 (Top 7 %)
  • Language
    OCaml
  • Created over 1 year ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A garden of small programming language implementations 🪴

Language garden 🌱

Some toy programming language implementations, mostly implemented in OCaml.

These projects are mostly my attempt to understand different techniques and approaches to implementing programming languages. Perhaps from these seedlings something new and interesting might germinate?

Implementations

Elaboration

Elaboration is an approach to implementing language front-ends where a complicated, user friendly surface language is type checked and lowered to a simpler, typed core language. This approach to type checking is particularly popular and useful for implementing dependently typed programming languages, but is more widely applicable as well.

  • elab-dependent: An elaborator for a small dependently typed lambda calculus.
  • elab-record-patching: An elaborator of a dependently typed lambda calculus with singletons and record patching.
  • elab-stlc-unification: An elaborator for a simply typed lambda calculus where type annotations can be omitted.

Compilation

These are related to compilation. Mainly to stack-machines, but I’m interested in exploring more approaches in the future, and other compilation passes related to compiling functional programming languages.

  • compile-arith: Compiling arithmetic expressions to stack machine instructions and A-Normal Form.
  • compile-arithcond: Compiling arithmetic and conditional expressions to stack machine instructions and A-Normal Form.
  • compile-arith-verified: A formally verified arithmetic expression compiler and decompiler in Lean 4.
  • compile-closure-conv: Typed closure conversion and lambda lifting for a simply typed lambda calculus with booleans and integers.

Languages

Miscellaneous programming language experiments.

  • lang-fractal-growth: Experiments with using grammars and rewriting systems to model fractal growth.
  • lang-shader-graphics: An embedded DSL for describing procedural graphics, based on signed distance functions. These can be rendered on the CPU or compiled to GLSL shaders.

Work in progress projects

While most of the above projects need more work put into them, the following projects need more work put into them and a more incomplete in comparison.

Development setup

Using Nix is not required, but can be useful for setting up a development shell with the packages and tools used in this project. With Nix flakes enabled and nix-direnv installed, run:

echo "use flake" > .envrc
direnv allow

You’ll want to locally exclude the .envrc, or add it to your global gitignore.

After that, dune can be used to build, test, and run the projects:

dune build
dune test
dune exec compile-arith <<< "1 + 2 * 27"

Alternatively, opam files are provided (but might be broken).

More Repositories

1

codespan

Beautiful diagnostic reporting for text-based programming languages.
Rust
1,036
star
2

gl-rs

An OpenGL function pointer loader for Rust
Rust
677
star
3

approx

Approximate floating point equality comparisons and assertions
Rust
144
star
4

rust-nbe-for-mltt

Normalization by evaluation for Martin-Löf Type Theory with dependent records
Rust
87
star
5

moniker

Automagical variable binding library for Rust
Rust
63
star
6

algebra

Abstract algebra for Rust (still very much a WIP!)
Rust
60
star
7

color-rs

A library that provides types and conversions for working with various color formats.
Rust
46
star
8

ocaml-flake-example

An overly elaborate example of building a ‘Hello World’ package with Nix flakes, OCaml, and Dune
Nix
40
star
9

chronicle

An event sourced CQRS framework for Rust
Rust
37
star
10

open.gl-tutorials

DEPRECATED
Rust
17
star
11

rusp

A minimal scripting and data language for Rust.
Rust
16
star
12

sax-rs

DEPRECATED - use https://github.com/netvl/rust-xml/ instead.
Rust
12
star
13

elm-stlc

Bidirectional type checker for the simply typed lambda calculus
Elm
12
star
14

bullet-rs

Bindings and wrapper for the Bullet physics C API.
Rust
9
star
15

mia-lang

A little concatenative language
Rust
7
star
16

vscode-mercury

Mercury language integration for VSCode
4
star
17

rust-visitors

Experimenting with visitors in Rust
Rust
3
star
18

glfwvbo

D
3
star
19

odyssey-engine-old

An experimental game engine written in D.
D
3
star
20

idris-power-of-pi

Parts of The Power of Pi, implemented in Idris
Idris
3
star
21

ieee754-rs

IEEE 754-2008 floating point arithmetic for Rust (WIP)
Rust
2
star
22

efl-rs

Servo-specific wrapper for the relevant components of the Enlightenment Foundation Libraries.
Rust
2
star
23

lean_tutorial_exercises

Answers to the exercises in the Lean tutorial
Lean
2
star
24

hedge

Indexed based half-edge mesh implementation
Rust
1
star
25

nixpkgs

My personal Nix configuration
Nix
1
star
26

rust-bay-area-2014-06

Demo OpenGL code from the Rust Bay Area meetup on Game Tech.
Rust
1
star
27

sdl2-rs

Rust bindings and wrapper for SDL2 (Incomplete!)
Rust
1
star