https://gitlab.com/nomadic-labs/mi-cho-coq
Raw File
Tip revision: 904746e64772b0bebfb70f3c3e04784c8d28f053 authored by Arvid Jakobsson on 10 May 2021, 07:35:53 UTC
Merge branch 'arvid@re-organize-contracts_coq' into 'dev'
Tip revision: 904746e
michocoq.ml.hand-written
(* Conversion functions between Coq and OCaml strings, taken from CompCert. *)

let camlstring_of_coqstring (s : char list) =
  let r = Stdlib.Bytes.create (Stdlib.List.length s) in
  let rec fill pos = function
    | [] -> r
    | c :: s -> Stdlib.Bytes.set r pos c; fill (pos + 1) s
  in Stdlib.Bytes.to_string (fill 0 s)

let coqstring_of_camlstring s =
  let rec cstring accu pos =
    if pos < 0 then accu else cstring (Stdlib.String.get s pos :: accu) (pos - 1)
  in cstring [] (Stdlib.String.length s - 1)

(* main entrypoint *)
let () =
  if Array.length Sys.argv > 1 then
    print_endline (camlstring_of_coqstring (Main0.print_info (coqstring_of_camlstring Sys.argv.(1)) Main0.fixed_fuel));
back to top