Name: camlp4-to-ppx
Owner: Ocsigen
Description: Convert from camlp4 + syntax extensions to regular OCaml + extension points and attributes
Created: 2015-10-19 13:53:41.0
Updated: 2016-07-24 15:25:14.0
Pushed: 2016-09-28 15:46:45.0
Homepage: null
Size: 27
Language: OCaml
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
The aim of this project is to automatically convert OCaml source files using camlp4 syntax extensions to their equivalent in the ppx world while preserving comments and the layout. We used a variation of this tool at Jane Street to convert our code base.
For instance it will translate:
t =
A of int (* blah *)
B of string
th sexp, bin_io
x = <:sexp_of< t * int >> (A 42, 10)
into:
t =
A of int (* blah *)
B of string
@deriving sexp, bin_io]
x = [%sexp_of: t * int ] (A 42, 10)
For each syntax extension to convert a plugin needs to be written.
This repository has plugins for all old jane street camlp4 syntax extensions. The ocsigen fork has plugins for deriving, eliom, and other ocsigen related syntax extensions.
It works by writing a dummy camlp4 syntax extension that only register substitutions using locations. After parsing the input file all the substitutions are applied to the original file and the result is printed.
To add a new plugin, add a file to the plugins/ directory and the
corresponding line in bin/main.ml
. pa_ounit.ml
should be a good
model to understand how it works.