Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
61f52514
Commit
61f52514
authored
Sep 24, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major simplification of the ocamlbuild code governing parser choice.
parent
185d8b0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
20 deletions
+9
-20
src/Makefile
src/Makefile
+1
-2
src/_tags
src/_tags
+0
-3
src/myocamlbuild.ml
src/myocamlbuild.ml
+8
-15
No files found.
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