Commit 5cf1260c authored by POTTIER Francois's avatar POTTIER Francois

Nice cleanup of myocamlbuild.ml.

parent c71bf554
......@@ -27,46 +27,43 @@ let fancy () : bool =
mark_tag_used "fancy_parser";
Tags.mem "fancy_parser" (tags_of_pathname "")
let parser_rule () =
let compile_messages grammar messages target =
rule
"compile a custom table of messages"
~prod:target
~deps:[ grammar; messages ]
(fun env _ ->
Cmd(S[
!Options.ocamlyacc; (* menhir *)
(* no additional flags; may allow them in the future *)
P (env grammar);
A "--compile-errors"; P (env messages);
Sh ">"; Px (env target);
]))
let parser_configuration () =
(* Create [parser.mly] by copying the appropriate source file. *)
copy_rule "create parser.mly"
(* source: *)
(if fancy() then "fancy-parser.mly" else "yacc-parser.mly")
(* target: *)
"parser.mly"
let driver_rule () =
;
(* Create [Driver.ml] by copying the appropriate source file. *)
copy_rule "create Driver.ml"
(* source: *)
(if fancy() then "fancyDriver.ml" else "yaccDriver.ml")
(* target: *)
"Driver.ml"
(* ---------------------------------------------------------------------------- *)
(* The file [FancyParserMessages.ml] is generated by Menhir based on
[fancy-parser.messages], which is maintained by hand. Of course,
this is possible only in stage 2 of the bootstrap process, since
Menhir is required. *)
let messages_rule () =
if Tags.mem "fancy_parser" (tags_of_pathname "") then
(* The target. *)
let prod = "FancyParserMessages.ml" in
(* The two source files. *)
let messages = "fancy-parser.messages"
and grammar = "parser.mly" in
(* The production rule. *)
rule
"fancy parser messages"
~prod:prod
~deps:[ messages; grammar ]
(fun env _ ->
Cmd(S[
!Options.ocamlyacc; (* menhir *)
P (env grammar);
A "--compile-errors"; P (env messages);
Sh ">"; Px (env prod);
]))
;
(* In the fancy case, use Menhir to generate [FancyParserMessages.ml] based
on [fancy-parser.messages], which is maintained by hand. *)
if fancy() then
compile_messages
(* sources: *)
"parser.mly" "fancy-parser.messages"
(* target: *)
"FancyParserMessages.ml"
(* ---------------------------------------------------------------------------- *)
......@@ -75,9 +72,7 @@ let messages_rule () =
let () =
dispatch (function After_rules ->
(* Add our rules after the standard ones. *)
parser_rule();
driver_rule();
messages_rule();
parser_configuration();
flags();
| _ -> ()
)
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