Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
menhir
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
POTTIER Francois
menhir
Commits
5cf1260c
Commit
5cf1260c
authored
Sep 24, 2015
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nice cleanup of myocamlbuild.ml.
parent
c71bf554
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
33 deletions
+28
-33
src/myocamlbuild.ml
src/myocamlbuild.ml
+28
-33
No files found.
src/myocamlbuild.ml
View file @
5cf1260c
...
...
@@ -27,46 +27,43 @@ let fancy () : bool =
mark_tag_used
"fancy_parser"
;
Tags
.
mem
"fancy_parser"
(
tags_of_pathname
""
)
let
parser_rule
()
=
let
compile_messages
grammar
messages
target
=
rule
"compile a custom table of messages"
~
prod
:
target
~
deps
:
[
grammar
;
messages
]
(
fun
env
_
->
Cmd
(
S
[
!
Options
.
ocamlyacc
;
(* menhir *)
(* no additional flags; may allow them in the future *)
P
(
env
grammar
);
A
"--compile-errors"
;
P
(
env
messages
);
Sh
">"
;
Px
(
env
target
);
]))
let
parser_configuration
()
=
(* Create [parser.mly] by copying the appropriate source file. *)
copy_rule
"create parser.mly"
(* source: *)
(
if
fancy
()
then
"fancy-parser.mly"
else
"yacc-parser.mly"
)
(* target: *)
"parser.mly"
let
driver_rule
()
=
;
(* Create [Driver.ml] by copying the appropriate source file. *)
copy_rule
"create Driver.ml"
(* source: *)
(
if
fancy
()
then
"fancyDriver.ml"
else
"yaccDriver.ml"
)
(* target: *)
"Driver.ml"
(* ---------------------------------------------------------------------------- *)
(* 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
);
]))
;
(* In the fancy case, use Menhir to generate [FancyParserMessages.ml] based
on [fancy-parser.messages], which is maintained by hand. *)
if
fancy
()
then
compile_messages
(* sources: *)
"parser.mly"
"fancy-parser.messages"
(* target: *)
"FancyParserMessages.ml"
(* ---------------------------------------------------------------------------- *)
...
...
@@ -75,9 +72,7 @@ let messages_rule () =
let
()
=
dispatch
(
function
After_rules
->
(* Add our rules after the standard ones. *)
parser_rule
()
;
driver_rule
()
;
messages_rule
()
;
parser_configuration
()
;
flags
()
;
|
_
->
()
)
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