Commit 6af0a79a authored by POTTIER Francois's avatar POTTIER Francois

Remove [Makefile.preprocess], no longer needed.

parent 03c7271f
......@@ -20,7 +20,7 @@ test: all
mli:
@ $(OCAMLBUILD) $(MLI)
include Makefile.preprocess
include $(shell ocamlfind query visitors)/Makefile.preprocess
processed: Term.processed.ml
......
# This Makefile allows running visitors as a preprocessor,
# so as to inspect the generated code and possibly include
# it in a TeX document.
# This assumes the visitors package is installed.
# The rewriting command.
PPX := `ocamlfind query ppx_deriving`/ppx_deriving \
`ocamlfind query visitors`/ppx_deriving_visitors.cma
REWRITE := ocamlfind ppx_tools/rewriter -ppx '$(PPX)'
# Use GNU sed to extract the generated code.
# This requires GNU sed 3.95 or above, I am told.
SED := $(shell if command -v gsed >/dev/null ; then echo gsed ; else echo sed ; fi)
EXTRACT := $(SED) -e '/VISITORS.BEGIN/,/VISITORS.END/!d;//d'
# Use sed to fix some deficiencies of OCaml's code printer.
# 0. Force a space after a comma.
# 1. Replace multiple consecutive spaces with a single space.
# This will destroy indentation; we restore it afterwards.
# 2. Force a line break after [in].
# 3. Force a line break after [->].
# 4. (Ad hoc.) Force a line break between [= let],
# presumably at the beginning of a method definition.
# 5. Remove the line break between [=] and [object].
BEAUTIFY := \
| $(SED) -e 's/,/, /g' \
| $(SED) -e 's/ / /g' \
| $(SED) -e 's/ in / in\n/g' \
| $(SED) -e 's/ -> / ->\n/g' \
| $(SED) -e 's/= let /=\nlet /g' \
| perl -0777 -pe 's/=\n *object/= object/gs' \
# Use ocp-indent to beautify the generated code.
INDENT := ocp-indent --config=JaneStreet,match_clause=4
%.processed.ml: %.ml
$(REWRITE) $< | $(EXTRACT) $(BEAUTIFY) | $(INDENT) > $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment