Skip to content

Instantly share code, notes, and snippets.

@arucil
arucil / cps.scm
Last active April 3, 2018 06:52
A simple basic CPS transformer in Scheme
;;; This library is described at https://www.cs.indiana.edu/chezscheme/match/
(load "match.ss")
(define (id x) x)
(define (cps exp)
(letrec ([cps
(lambda (exp k)
@arucil
arucil / macros_that_work.scm
Last active October 31, 2017 01:59
A simple implementation of the hygienic macro expander described in Macros-That-Work
;e;; A simple macro expander implementation based on Macros That Work.
;;;
;;; Usage:
;;; (macroexpand s-exp) yields a fully expanded form
;;;
;;; Primitive special forms:
;;; if
;;; set!
;;; begin
@arucil
arucil / quasiquote.scm
Created October 12, 2017 13:01
Simple quasiquote implementation in macros
(define-syntax quasiquote
(syntax-rules ()
[(_ e) (qq-expand e)]))
(define-syntax qq-expand
(syntax-rules (quasiquote unquote unquote-splicing)
[(_ `x . lv)
(list 'quasiquote
(qq-expand x #f . lv))]
@arucil
arucil / macro_by_example.scm
Last active October 26, 2017 09:19
A simple macro-by-example implementation
;;; Usage:
;;; (mbe pattern template sexp)
;;; Expand a single-rule macro (represented by pattern & template)
(define (wrong msg . args)
(apply error 'error msg args))
(define (match sexp pattern)
(let ([env (match-help (cdr sexp) (cdr pattern))])
@arucil
arucil / decompile.sh
Last active March 5, 2017 00:28
shell script for decompiling minecraft mod
#!/bin/bash
showUsage() {
echo "Usage: $0 version jar-file"
echo 'Supported versions:'
for ver in ${!mcp[*]}; do
echo " $ver"
done
exit 1
}