Skip to content

Commit 12ab543

Browse files
committed
Extract Rocq strings to OCaml strings instead of OCaml lists of characters
Native string extraction is now supported by all the Coq versions we support.
1 parent 821abd5 commit 12ab543

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

extraction/extraction.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Require Parser.
2525
Require Initializers.
2626

2727
(* Standard lib *)
28-
From Coq Require Import ExtrOcamlBasic ExtrOcamlString.
28+
From Coq Require Import ExtrOcamlBasic ExtrOcamlNativeString.
2929

3030
(* Coqlib *)
3131
Extract Inlined Constant Coqlib.proj_sumbool => "(fun x -> x)".

lib/Camlcoq.ml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -376,27 +376,11 @@ let first_unused_ident () =
376376

377377
(* Strings *)
378378

379-
let camlstring_of_coqstring (s: char list) =
380-
let r = Bytes.create (List.length s) in
381-
let rec fill pos = function
382-
| [] -> r
383-
| c :: s -> Bytes.set r pos c; fill (pos + 1) s
384-
in Bytes.to_string (fill 0 s)
385-
386-
let coqstring_of_camlstring s =
387-
let rec cstring accu pos =
388-
if pos < 0 then accu else cstring (s.[pos] :: accu) (pos - 1)
389-
in cstring [] (String.length s - 1)
390-
391-
let coqstring_uppercase_ascii_of_camlstring s =
392-
let rec cstring accu pos =
393-
if pos < 0 then accu else
394-
let d = if s.[pos] >= 'a' && s.[pos] <= 'z' then
395-
Char.chr (Char.code s.[pos] - 32)
396-
else
397-
s.[pos] in
398-
cstring (d :: accu) (pos - 1)
399-
in cstring [] (String.length s - 1)
379+
let camlstring_of_coqstring s = s
380+
381+
let coqstring_of_camlstring s = s
382+
383+
let coqstring_uppercase_ascii_of_camlstring s = String.uppercase_ascii s
400384

401385
(* Floats *)
402386

0 commit comments

Comments
 (0)