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:
|
|
|
|
|
2021-01-01 12:52:50 +01:00
|
|
|
#+NAME: raw_printers
|
2020-12-29 00:39:12 +01:00
|
|
|
#+begin_src sh :results output raw
|
|
|
|
grep "val pp " ../*/*.org \
|
|
|
|
| grep -v docs \
|
|
|
|
| cut -d ":" -f 1 \
|
|
|
|
| sed 's|^../||' \
|
2021-01-01 12:52:50 +01:00
|
|
|
| sed 's|.org||' \
|
2020-12-29 00:39:12 +01:00
|
|
|
| sed 's|/| |' \
|
|
|
|
| sed 's/[^ ]*/\u&/g' \
|
|
|
|
| sed 's| |.|' \
|
2021-01-01 12:52:50 +01:00
|
|
|
| grep -v Top.Install_printers
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+NAME: printers
|
|
|
|
#+begin_src python :results output raw :var p=raw_printers
|
|
|
|
result = []
|
|
|
|
for l in p.split():
|
|
|
|
dir, module = l.split('.')
|
|
|
|
if dir == module:
|
|
|
|
e = f'"{module}.pp" ;'
|
|
|
|
else:
|
|
|
|
e = f'"{dir}.{module}.pp" ;'
|
|
|
|
result.append(e)
|
|
|
|
result = '\n'.join(result)
|
|
|
|
print(result)
|
2020-12-29 00:39:12 +01:00
|
|
|
#+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
|
|
|
|
|