myocamlbuild.ml 792 Bytes
Newer Older
1 2 3
open Ocamlbuild_plugin
open Command

4 5 6 7 8 9

(* Define ocamlbuild flags [only_tokens] and [external_tokens(Foo)] and
   [unused_token(Bar)] which correspond to menhir's [--only-tokens] and
   [--external-tokens Foo] and [--unused-token Bar]. When they are used, these
   flags should be passed both to [menhir] and to [menhir --raw-depend]. *)

10 11 12 13 14 15 16
let menhir_flags() =
  List.iter (fun mode ->
    
    flag [ mode; "only_tokens" ] (S[A "--only-tokens"]);

    pflag [ mode ] "external_tokens" (fun name ->
      S[A "--external-tokens"; A name]
17 18 19 20
    );

    pflag [ mode ] "unused_token" (fun name ->
      S[A "--unused-token"; A name]
21
    )
22
      
23 24 25 26 27 28
  ) [ "menhir"; "menhir_ocamldep" ]

let () =
  dispatch (fun event ->
    match event with
    | After_rules ->
29
      menhir_flags()
30 31
    | _ -> ()
  )