Skip to content

Commit

Permalink
Open the string scope by default
Browse files Browse the repository at this point in the history
  • Loading branch information
clarus committed Jan 21, 2020
1 parent 53a6b7b commit 87516ae
Show file tree
Hide file tree
Showing 30 changed files with 42 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ let to_coq (ast : t) : SmartPrint.t =
concat (List.map (fun d -> d ^^ newline) [
!^ "(** Generated by coq-of-ocaml *)";
!^ "Require Import OCaml.OCaml." ^^ newline;
!^ "Local Open Scope string_scope.";
!^ "Local Open Scope Z_scope.";
!^ "Local Open Scope type_scope.";
!^ "Import ListNotations." ^^ newline;
Expand Down
2 changes: 1 addition & 1 deletion src/constant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ let rec to_coq (c : t) : SmartPrint.t =
Buffer.add_string b "\"\""
else
Buffer.add_char b c);
nest (double_quotes (!^ (Buffer.contents b)) ^^ !^ "%" ^^ !^ "string")
double_quotes (!^ (Buffer.contents b))
| Warn (c, message) -> group (Error.to_comment message ^^ newline ^^ to_coq c)
3 changes: 2 additions & 1 deletion tests/builtin_types.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand All @@ -18,7 +19,7 @@ Definition c3 : ascii := "009" % char.

Definition c4 : ascii := """" % char.

Definition s : string := "hi\n\t:)\""" % string.
Definition s : string := "hi\n\t:)\""".

Definition b1 : bool := false.

Expand Down
1 change: 1 addition & 0 deletions tests/cfml_set.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
3 changes: 2 additions & 1 deletion tests/first_class_modules.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down Expand Up @@ -116,7 +117,7 @@ End Triple.
Definition tripe : {'[a, b, c, bar] : _ & Triple.signature a b c bar} :=
let va := 0 in
let vb := false in
let vc := "" % string in
let vc := "" in
let foo := 12 in
existT _ [_, _, _, _]
{|
Expand Down
1 change: 1 addition & 0 deletions tests/free_type_variables.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/function_with_explicit_types.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/functor.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/functor_application.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/gadts.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/interface.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/let_rec_and.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/lets.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/local_vs_global_name.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/matching.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/modules.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/mutual_types.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/open_modules.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/operators.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
3 changes: 2 additions & 1 deletion tests/pervasives_basics.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand All @@ -22,7 +23,7 @@ Definition n4 : Z := Z.lxor (Z.lor (Z.land 5 7) 3) 9.

Definition n5 : Z := Z.add (Z.shiftl 156 4) (Z.shiftr 12 1).

Definition s : string := String.append "ghj" % string "klm" % string.
Definition s : string := String.append "ghj" "klm".

Definition c : Z := OCaml.Stdlib.int_of_char "c" % char.

Expand Down
7 changes: 4 additions & 3 deletions tests/pervasives_more.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down Expand Up @@ -76,19 +77,19 @@ Definition n_lsl : Z := Z.shiftl 12 13.

Definition n_lsr : Z := Z.shiftr 12 13.

Definition ss : string := String.append "begin" % string "end" % string.
Definition ss : string := String.append "begin" "end".

Definition n_char : Z := OCaml.Stdlib.int_of_char "c" % char.

Definition i : unit := OCaml.Stdlib.ignore 12.

Definition s_bool : string := OCaml.Stdlib.string_of_bool false.

Definition bool_s : bool := OCaml.Stdlib.bool_of_string "false" % string.
Definition bool_s : bool := OCaml.Stdlib.bool_of_string "false".

Definition s_n : string := OCaml.Stdlib.string_of_int 12.

Definition n_s : Z := OCaml.Stdlib.int_of_string "12" % string.
Definition n_s : Z := OCaml.Stdlib.int_of_string "12".

Definition n1 : Z := fst (12, 13).

Expand Down
1 change: 1 addition & 0 deletions tests/polymorphic_function.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
5 changes: 3 additions & 2 deletions tests/pre_defined_types.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand All @@ -22,6 +23,6 @@ Definition o2 : option Z := Some 12.

Definition c : ascii := "g" % char.

Definition s1 : string := "bla" % string.
Definition s1 : string := "bla".

Definition s2 : string := "\""" % string.
Definition s2 : string := "\""".
7 changes: 4 additions & 3 deletions tests/records.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand All @@ -18,10 +19,10 @@ Module SizedString.
End SizedString.

Definition r : SizedString.t :=
{| SizedString.t.name := "gre" % string; SizedString.t.size := 3 |}.
{| SizedString.t.name := "gre"; SizedString.t.size := 3 |}.

Definition r' : SizedString.t :=
{| SizedString.t.name := "haha" % string; SizedString.t.size := 4 |}.
{| SizedString.t.name := "haha"; SizedString.t.size := 4 |}.

Definition s : Z := Z.add (SizedString.t.size r) (SizedString.t.size r').

Expand Down Expand Up @@ -109,7 +110,7 @@ Module ConstructorWithRecords.

Definition l : loc := {| loc.x := 12; loc.y := 23 |}.

Definition foo : t := Foo {| t.Foo.name := "foo" % string; t.Foo.size := 12 |}.
Definition foo : t := Foo {| t.Foo.name := "foo"; t.Foo.size := 12 |}.

Definition f (x : t) : Z :=
match x with
Expand Down
1 change: 1 addition & 0 deletions tests/recursion.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/recursion_more.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/sum_types.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
1 change: 1 addition & 0 deletions tests/tree.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down
3 changes: 2 additions & 1 deletion tests/tuples.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand All @@ -10,7 +11,7 @@ Unset Guard Checking.

Definition t0 : unit := tt.

Definition t1 : ascii * string := ("c" % char, "one" % string).
Definition t1 : ascii * string := ("c" % char, "one").

Definition t2 : Z * Z * Z * bool * bool := (1, 2, 3, false, true).

Expand Down
1 change: 1 addition & 0 deletions tests/type_synonyms.v
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(** Generated by coq-of-ocaml *)
Require Import OCaml.OCaml.

Local Open Scope string_scope.
Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.
Expand Down

0 comments on commit 87516ae

Please sign in to comment.