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

Nice cleanup of myocamlbuild.ml.

parent c71bf554
...@@ -27,46 +27,43 @@ let fancy () : bool = ...@@ -27,46 +27,43 @@ let fancy () : bool =
mark_tag_used "fancy_parser"; mark_tag_used "fancy_parser";
Tags.mem "fancy_parser" (tags_of_pathname "") 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" copy_rule "create parser.mly"
(* source: *) (* source: *)
(if fancy() then "fancy-parser.mly" else "yacc-parser.mly") (if fancy() then "fancy-parser.mly" else "yacc-parser.mly")
(* target: *) (* target: *)
"parser.mly" "parser.mly"
;
let driver_rule () = (* Create [Driver.ml] by copying the appropriate source file. *)
copy_rule "create Driver.ml" copy_rule "create Driver.ml"
(* source: *) (* source: *)
(if fancy() then "fancyDriver.ml" else "yaccDriver.ml") (if fancy() then "fancyDriver.ml" else "yaccDriver.ml")
(* target: *) (* target: *)
"Driver.ml" "Driver.ml"
;
(* ---------------------------------------------------------------------------- *) (* In the fancy case, use Menhir to generate [FancyParserMessages.ml] based
on [fancy-parser.messages], which is maintained by hand. *)
(* The file [FancyParserMessages.ml] is generated by Menhir based on if fancy() then
[fancy-parser.messages], which is maintained by hand. Of course, compile_messages
this is possible only in stage 2 of the bootstrap process, since (* sources: *)
Menhir is required. *) "parser.mly" "fancy-parser.messages"
(* target: *)
let messages_rule () = "FancyParserMessages.ml"
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);
]))
(* ---------------------------------------------------------------------------- *) (* ---------------------------------------------------------------------------- *)
...@@ -75,9 +72,7 @@ let messages_rule () = ...@@ -75,9 +72,7 @@ let messages_rule () =
let () = let () =
dispatch (function After_rules -> dispatch (function After_rules ->
(* Add our rules after the standard ones. *) (* Add our rules after the standard ones. *)
parser_rule(); parser_configuration();
driver_rule();
messages_rule();
flags(); 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