I am using the --compile-errors
functionality of menhir
and I'm quite happy with it. I'm also using ocamlbuild
to manage the compilation of my project. Since the project is quite basic, the build infrastructure has remained trivial so far.
I have a single _tags
file and a simple Makefile
at the root of the project. I don't have a myocamlbuild.ml
file yet. The _tags
file contains just one line:
<src/*>: package(ppx_deriving.std)
The relevant part of the Makefile is
all: src/ParsingErrors.ml
ocamlbuild $(OPTIONS) src/Main.native
src/ParsingErrors.ml: src/Handcrafted.messages src/Parser.mly
menhir --compile-errors src/Handcrafted.messages src/Parser.mly > src/ParsingErrors.ml
OPTIONS = -j 4 -use-menhir -use-ocamlfind -yaccflag --table -pkgs menhirLib,str,unix
OCamlbuild and Menhir are usually well integrated, but --compile-errors
seems to be a fairly new functionality. My setup is not ideal because I dislike having an automatically generated file, src/ParsingErrors.ml
, in my source directory instead of the build directory. What would be the best way to explain to OCamlbuild that I want Menhir to build this error messages file? Changing the naming convention of my files (into src/Parser.messages
and src/Parser.ml
, for example) does not bother me if it simplifies things.
NB: although I have myocamlbuild.ml
files in other projects, I copied them from online sources. I find them hard to decipher and I don't really understand how to write these things.