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
ed40ca11
Commit
ed40ca11
authored
Sep 19, 2019
by
Nicolás Ojeda Bär
Committed by
POTTIER Francois
Sep 24, 2019
Browse files
Add ocamlbuild rule to embed an .mly inside an OCaml module
parent
95145679
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/myocamlbuild.ml
View file @
ed40ca11
...
...
@@ -173,6 +173,24 @@ let generic_compile_errors (check_completeness : bool) =
(* ---------------------------------------------------------------------------- *)
(* This rule allows to embed a text file verbatim inside an OCaml module. The
OCaml module contains a single value [contents] containing the contents
of the text file. *)
let
embed_text_files
input
output
=
rule
"embed a text file inside an OCaml module"
~
prod
:
output
~
dep
:
input
(
fun
env
_
->
let
ic
=
open_in_bin
(
env
input
)
in
let
contents
=
really_input_string
ic
(
in_channel_length
ic
)
in
close_in
ic
;
Echo
([
"let contents =
\"
"
;
String
.
escaped
contents
;
"
\"
"
]
,
env
output
)
)
(* ---------------------------------------------------------------------------- *)
(* This rule generates a .messages file [messages] from an .mly file
[grammar]. *)
...
...
@@ -280,6 +298,8 @@ let parser_configuration () =
grammar is small enough. *)
generic_completeness_check
()
end
;
embed_text_files
"%.mly"
"%_mly.ml"
(* ---------------------------------------------------------------------------- *)
...
...
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