Commit 61f52514 authored by POTTIER Francois's avatar POTTIER Francois

Major simplification of the ocamlbuild code governing parser choice.

parent 185d8b0c
......@@ -53,8 +53,7 @@ bootstrap: .versioncheck stage1 stage2 stage3
# Build Menhir using ocamlyacc.
stage1:
@$(OCAMLBUILD) -build-dir _stage1 -tag yacc_parser \
menhir.$(TARGET)
@$(OCAMLBUILD) -build-dir _stage1 menhir.$(TARGET)
# ----------------------------------------------------------------------------
# Stage 2.
......
......@@ -2,9 +2,6 @@
# This is disabled when shipping. (my_warnings)
<*>: my_warnings
# Tag both parser source files with origin_parser.
<{yacc-parser,fancy-parser}.mly>:origin_parser
# Menhir needs the Unix library.
<menhir.{byte,native}>: use_unix
......
......@@ -13,29 +13,22 @@ let flags () =
(* ---------------------------------------------------------------------------- *)
(* A command for copying a file. *)
let copy_file_from_tag src dst env build =
Cmd (S [A "cp"; T (tags_of_pathname src); P dst])
(* ---------------------------------------------------------------------------- *)
(* Dealing with the two parsers. *)
(* Just for fun, Menhir comes with two parsers for its own input files. One is
called [yacc-parser.mly] and is built using [ocamlyacc]. The other is called
[fancy-parser.mly] and is built using Menhir. It depends on [standard.mly].
The choice between the two parsers is determined by the presence of the tag
[yacc_parser] or [fancy_parser]. *)
[fancy_parser]. *)
let parser_rule () =
(* The three dependencies. *)
flag_and_dep ["origin_parser"; "yacc_parser"] (P "yacc-parser.mly");
flag_and_dep ["origin_parser"; "fancy_parser"] (P "fancy-parser.mly");
dep ["origin_parser"; "fancy_parser"] ["standard.mly"];
(* The two rules. *)
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 source =
mark_tag_used "fancy_parser";
if Tags.mem "fancy_parser" (tags_of_pathname "")
then "fancy-parser.mly"
else "yacc-parser.mly"
in
copy_rule "create parser.mly" source "parser.mly"
(* ---------------------------------------------------------------------------- *)
......
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