ocamlocamlbuildocaml-batteriesmenhir

Using Batteries in .mly file with ocamlbuild


I have a project with OCaml .ml files and a Menhir .mly file. I use ocamlbuild to compile the project.

My _tags file contains this single line:

true: use_menhir, package(batteries)

Everything works well, except when I want to use Batteries in the .mly file. If I open Batteries ;; between %{ and %} in my .mly file, I get "Error: Unbound module Batteries" when calling ocamlbuild.

It seems that when ocamlbuild is calling menhir, like this:

/usr/bin/menhir --ocamlc '/usr/bin/ocamlfind ocamlc' --infer parser.mly

it forgets to add -package batteries (or something equivalent) in the --ocamlc option of menhir.

How can I fix that? Maybe a special rule for my .mly file in my _tags file could help? Or is it a ocamlbuild bug?


Solution

  • This is supposedly fixed in recent OCaml versions (see http://caml.inria.fr/mantis/view.php?id=5763). Which version are you running?