Skip to content

Instantly share code, notes, and snippets.

@neel-krishnaswami
neel-krishnaswami / pcomb.ml
Last active September 6, 2023 13:43
A linear-time parser combinator library in Ocaml
module C : sig
type t
val empty : t
val one : char -> t
val union : t -> t -> t
val inter : t -> t -> t
val top : t
val mem : char -> t -> bool
val make : (char -> bool) -> t
val equal : t -> t -> bool
@hirrolot
hirrolot / CoC.ml
Last active November 13, 2024 04:32
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@pdarragh
pdarragh / papers.md
Last active April 17, 2024 19:29
Approachable PL Papers for Undergrads

Approachable PL Papers for Undergrads

On September 28, 2021, I asked on Twitter:

PL Twitter:

you get to recommend one published PL paper for an undergrad to read with oversight by someone experienced. the paper should be interesting, approachable, and (mostly) self-contained.

what paper do you recommend?

@p4bl0-
p4bl0- / 00_readme.md
Last active October 12, 2023 09:09
A complete compiler for a simple language (in less than 150 LoC)

This project is a tiny compiler for a very simple language consisting of boolean expression.

The language has two constants: 1 for true and 0 for false, and 4 logic gates: ! (not), & (and), | (or), and ^ (xor).

It can also use parentheses to manage priorities.

Here is its grammar in BNF format:

expr ::= "0" | "1"

@snej
snej / tails.cc
Last active May 8, 2021 18:27
Tails! A tiny Forth core written as a hack for May Forth 2021, using some of Wasm3's secret optimization sauce.
// Tails has grown a bit and moved out into its own repository: https://github.com/snej/tails/
// Please visit it there!
//
// If you want to see the tiny original version from May Forth 2021, it's still here;
// click the "Revisions" button above, or go to:
// https://gist.github.com/snej/9ba59d90689843b22dc5be2730ef0d49/2d55f844b7622aa117b9275bbc9d189613f7ff7f
@MattPD
MattPD / analysis.draft.md
Last active November 12, 2024 06:46
Program Analysis Resources (WIP draft)

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@aprell
aprell / newproject.sh
Created October 12, 2012 09:57
Project templates
#!/bin/bash
usage="Usage: $(basename "$0") <name>"
if [ $# -ne 1 ]; then
echo $usage
exit 0
fi
proj=$1
@aprell
aprell / Makefile
Created November 20, 2011 17:54
Simple unit testing for C
CC = gcc
CPPFLAGS += -D_GNU_SOURCE
CFLAGS += -O0 -g -Wall -Wextra
SRCS = driver.c module.c
OBJS = $(SRCS:.c=.o)
all: utest
utest: $(OBJS)
@vidarh
vidarh / closures-basic.c
Created December 18, 2009 12:10
A number of ways to implement closures in C, in preparation of an upcoming blog post
#include <stdio.h>
#include <stdlib.h>
struct closure {
void (* call)(struct closure *);
int x;
};