Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
61f52514
Commit
61f52514
authored
Sep 24, 2015
by
POTTIER Francois
Browse files
Major simplification of the ocamlbuild code governing parser choice.
parent
185d8b0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Makefile
View file @
61f52514
...
...
@@ -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.
...
...
src/_tags
View file @
61f52514
...
...
@@ -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
...
...
src/myocamlbuild.ml
View file @
61f52514
...
...
@@ -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"
(* ---------------------------------------------------------------------------- *)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment