Commit 391f3d05 authored by POTTIER Francois's avatar POTTIER Francois

Merge branch 'master' into coverage

parents 62e4518e de68e474
......@@ -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.
......@@ -68,7 +67,7 @@ FLAGS := -v -lg 1 -la 1 -lc 1 --comment --infer --stdlib $(SRC) --strict --fixed
stage2:
@$(OCAMLBUILD) -build-dir _stage2 -tag fancy_parser \
-use-menhir -menhir "$(SRC)/_stage1/menhir.$(TARGET) $(FLAGS)" \
-use-menhir -menhir "$(SRC)/_stage1/menhir.$(TARGET)" -yaccflags "$(FLAGS)" \
menhir.$(TARGET)
# ----------------------------------------------------------------------------
......@@ -77,7 +76,7 @@ stage2:
# is identical to the stage 2 parser.
stage3:
@$(OCAMLBUILD) -build-dir _stage3 -tag fancy_parser \
-use-menhir -menhir "$(SRC)/_stage2/menhir.$(TARGET) $(FLAGS)" \
-use-menhir -menhir "$(SRC)/_stage2/menhir.$(TARGET)" -yaccflags "$(FLAGS)" \
parser.ml parser.mli
@for i in parser.ml parser.mli ; do \
if ! diff _stage2/$$i _stage3/$$i 2>&1 >/dev/null ; then \
......
......@@ -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
......
......@@ -15,29 +15,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