Commit 93909c54 authored by POTTIER Francois's avatar POTTIER Francois

Added [fancyDriver], [yaccDriver], a dependency of [Front] on [Driver],

and ocamlbuild rules.
parent 28245bbb
module F = FancyParserMessages
......@@ -4,6 +4,8 @@
(* Reading a grammar from a file. *)
module D = Driver
let load_partial_grammar filename =
let validExt = if Settings.coq then ".vy" else ".mly" in
if not (Filename.check_suffix filename validExt) then
......
......@@ -39,6 +39,48 @@ let parser_rule () =
rule "yacc-parser -> parser" ~prod:"parser.mly" (copy_file_from_tag "yacc-parser.mly" "parser.mly");
rule "fancy-parser -> parser" ~prod:"parser.mly" (copy_file_from_tag "fancy-parser.mly" "parser.mly")
let driver_rule () =
(* The source file is either [yaccDriver.ml] or [fancyDriver.ml], depending
on which tag is (globally) present: [yacc_parser] or [fancy_parser]. *)
let source =
if Tags.mem "yacc_parser" (tags_of_pathname "")
then "yaccDriver.ml"
else "fancyDriver.ml"
in
(* The target file is [Driver.ml]. *)
let target =
"Driver.ml"
in
(* A copy rule. *)
copy_rule "create Driver.ml" source target
(* ---------------------------------------------------------------------------- *)
(* 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);
]))
(* ---------------------------------------------------------------------------- *)
(* Define custom compilation rules. *)
......@@ -47,6 +89,8 @@ let () =
dispatch (function After_rules ->
(* Add our rules after the standard ones. *)
parser_rule();
driver_rule();
messages_rule();
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