Indeed, ocamlbuild misses some built-in flag for menhir features. That said, it is easy to add these flags through your myocamlbuild.ml. Here is what I have in an incremental-menhir-using project (inside a dispatch call):

        flag ["menhir"; "parser"; "trace"] (A"--trace");
        flag ["menhir"; "parser"; "table"] (A "--table");
        flag ["menhir"; "parser"; "canonical"] (A"--canonical");

but it would be easy to add those to the built-in -use-menhir mode.

(If you are not comfortable with using myocamlbuild.ml, see the ocamlbuild manual:
  https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc#Sec_Plugins
)

In this project I also have rules for handling of .messages files corresponding Menhir's new error message support. I include the complete code at the end of my email. I would like to get a bit more experience using those, before considering including them in ocamlbuild proper.

----

module Menhir = struct
  let menhir () =
    if !Options.ocamlyacc = N then V"MENHIR" else !Options.ocamlyacc
  let menhir_tags mly =
    tags_of_pathname mly ++"ocaml"++"parser"++"menhir"

  let menhir_produce_messages env build =
    let messages, mly = env "%.messages", env "%.mly" in
    let open Ocamlbuild_pack in
    Ocaml_compiler.prepare_compile build mly;
    Cmd(S[menhir (); T (menhir_tags mly);
          A "--list-errors"; P mly; Sh ">"; Px messages])

  let menhir_compile_messages env build =
    let mly = env "%.mly" in
    let messages = env "%.messages" in
    let target = env "%_messages.ml" in
    Cmd(S[menhir (); T (menhir_tags mly); P mly;
          A "--compile-errors"; P messages;
          Sh ">"; Px target])

  let menhir_update_messages env build =
    let mly = env "%.mly" in
    let messages = env "%.messages" in
    let tmp = Filename.temp_file "menhir" ".messages" in
    Seq [
      Cmd(S[menhir (); T (menhir_tags mly); P mly;
            A "--update-errors"; P messages;
            Sh ">"; P tmp]);
      Cmd(S[A "mv"; P tmp; P messages]);
    ]

  let dispatcher = function
      | After_rules ->
        flag ["menhir"; "parser"; "menhir_trace"] (A"--trace");
        flag ["menhir"; "parser"; "menhir_table"] (A "--table");
        flag ["menhir"; "parser"; "menhir_canonical"] (A"--canonical");
        rule "menhir: .mly -> .messages"
          ~prod:"%.messages"
          ~deps:["%.mly"]
          menhir_produce_messages;
        rule "menhir: .mly & .messages -> _messages.ml"
          ~prod:"%_messages.ml"
          ~deps:["%.mly"; "%.messages"]
          menhir_compile_messages;
        rule "menhir: .mly & .messages -> .messages & .messages.update"
          ~stamp:"%.messages.update"
          ~deps:["%.mly"; "%.messages"]
          menhir_update_messages;
      | _ -> ()
end


On Tue, Feb 28, 2017 at 10:30 PM, Helmut Brandl <helmut.brandl@gmx.net> wrote:
Hello list,

does anybody know how to build a project with ocamlbuild and use the incremental api of menhir. By using menhir directly I would use the ‘-table’ flag. But I don’t know how to transfer this flag to menhir by using ocamlbuild.

Kind regards
Helmut

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs