From a9c92107eaa5b0d16caf9b06c4b63a950bceaea7 Mon Sep 17 00:00:00 2001 From: sneeker Date: Sun, 27 May 2018 08:40:09 +0000 Subject: [PATCH] Build the PPX executable with compiler-libs and make --- .gitignore | 4 ++++ Makefile | 15 +++++++++++++++ README.md | 19 +++++++++++++++++++ continuum_ppx.install | 1 + continuum_ppx.opam | 9 +++++++++ 5 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 continuum_ppx.install create mode 100644 continuum_ppx.opam diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d16f12f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +continuum_ppx +test.byte +*.cmi +*.cmo diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b337236 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +OCAMLC ?= ocamlc + +.PHONY: all test clean +all: continuum_ppx + +continuum_ppx: continuum_ppx.ml + $(OCAMLC) -I +compiler-libs ocamlcommon.cma $< -o $@ + +test: continuum_ppx + $(OCAMLC) -ppx ./continuum_ppx test.ml -o test.byte + ./test.byte + OCAMLC=$(OCAMLC) sh test_errors.sh + +clean: + rm -f continuum_ppx test.byte *.cmi *.cmo diff --git a/README.md b/README.md new file mode 100644 index 0000000..20c243d --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# continuum_ppx + +An OCaml syntax rewriter for callback-based functions: + +```ocaml +let%continue x = producer in body +``` + +expands to `producer (fun x -> body)`. The `let%cps` spelling also +works. Patterns and nested bindings are supported. Recursive bindings and +simultaneous `and` bindings produce a compiler error. + +Build and test with `make test`. Compile a consumer with +`ocamlc -ppx ./continuum_ppx example.ml`. The executable uses OCaml's bundled +compiler libraries and must match the consumer's compiler version. + +Install from this directory with `OPAMBUILDTEST=true opam pin add continuum_ppx .`. +The package installs the `continuum_ppx` executable; it needs no external OCaml +libraries or build tools beyond make. diff --git a/continuum_ppx.install b/continuum_ppx.install new file mode 100644 index 0000000..54a68f3 --- /dev/null +++ b/continuum_ppx.install @@ -0,0 +1 @@ +bin: ["continuum_ppx"] diff --git a/continuum_ppx.opam b/continuum_ppx.opam new file mode 100644 index 0000000..538a349 --- /dev/null +++ b/continuum_ppx.opam @@ -0,0 +1,9 @@ +opam-version: "1.2" +name: "continuum_ppx" +version: "0.1.0" +maintainer: "Local project maintainer" +authors: ["continuum_ppx contributors"] +homepage: "https://github.com/iitalics/ppx_cps/tree/e293af4" +build: [make] +build-test: [make "test"] +available: [ocaml-version = "4.06.1"]