10
1
mirror of https://gitlab.com/scemama/QCaml.git synced 2024-11-14 10:03:39 +01:00
QCaml/top/install_printers.org

60 lines
1.5 KiB
Org Mode
Raw Normal View History

2020-12-29 00:39:12 +01:00
#+begin_src elisp tangle: no :results none :exports none
(setq pwd (file-name-directory buffer-file-name))
(setq name (file-name-nondirectory (substring buffer-file-name 0 -4)))
(setq lib (concat pwd "lib/"))
(setq testdir (concat pwd "test/"))
(setq mli (concat lib name ".mli"))
(setq ml (concat lib name ".ml"))
(setq test-ml (concat testdir name ".ml"))
(org-babel-tangle)
#+end_src
* Intall printers
:PROPERTIES:
:header-args: :noweb yes :comments both
:END:
Installs printers in the top-level environment.
All printers are fetched automatically using the following script:
#+NAME: printers
#+begin_src sh :results output raw
grep "val pp " ../*/*.org \
| grep -v docs \
| cut -d ":" -f 1 \
| sed 's|^../||' \
| sed 's|.org|.pp" ;|' \
| sed 's|/| |' \
| sed 's/[^ ]*/\u&/g' \
| sed 's| |.|' \
| sed 's|^|"|' \
| grep -v Top.Install_printers.pp
#+end_src
#+begin_src ocaml :tangle (eval ml) :exports none
let printers =
[
<<printers()>>
]
let eval_exn str =
let lexbuf = Lexing.from_string str in
let phrase = !Toploop.parse_toplevel_phrase lexbuf in
Toploop.execute_phrase false Format.err_formatter phrase
let rec install_printers = function
2020-12-29 02:29:43 +01:00
| [] -> eval_exn "#require \"lacaml.top\";;"
2020-12-29 00:39:12 +01:00
| printer :: printers ->
let cmd = Printf.sprintf "#install_printer %s;;" printer in
eval_exn cmd && install_printers printers
let () =
if not (install_printers printers) then
Format.eprintf "Problem installing QCaml-printers@."
#+end_src