aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaëtan Gilbert2020-11-02 15:03:09 +0100
committerGaëtan Gilbert2020-11-02 15:03:09 +0100
commit225a4ee2871b58661f9689255237a1e189ee6a4c (patch)
tree4901f319b8babc4e5bc24e6a3a3d3fa68cb21e35
parent1280a492b87f02aac8c8f8496ebd42039762d7e4 (diff)
Nicer spacing when printing array literals
From [|x; y; z | def : ty |] to [| x; y; z | def : ty |]
-rw-r--r--printing/ppconstr.ml5
-rw-r--r--test-suite/output/prim_array.out9
-rw-r--r--test-suite/output/prim_array.v10
3 files changed, 22 insertions, 2 deletions
diff --git a/printing/ppconstr.ml b/printing/ppconstr.ml
index 6f50f34f36..45d0e39ed6 100644
--- a/printing/ppconstr.ml
+++ b/printing/ppconstr.ml
@@ -681,8 +681,9 @@ let tag_var = tag Tag.variable
| CDelimiters (sc,a) ->
return (pr_delimiters sc (pr mt (LevelLe ldelim) a), ldelim)
| CArray(u, t,def,ty) ->
- hov 0 (str "[|" ++ prvect_with_sep (fun () -> str "; ") (pr mt ltop) t ++
- str " |" ++ spc() ++ pr mt ltop def ++ pr_opt_type_spc (pr mt) ty ++
+ hov 0 (str "[| " ++ prvect_with_sep (fun () -> str "; ") (pr mt ltop) t ++
+ (if not (Array.is_empty t) then str " " else mt()) ++
+ str "|" ++ spc() ++ pr mt ltop def ++ pr_opt_type_spc (pr mt) ty ++
str " |]" ++ pr_universe_instance u), 0
in
let loc = constr_loc a in
diff --git a/test-suite/output/prim_array.out b/test-suite/output/prim_array.out
new file mode 100644
index 0000000000..6c12153ab9
--- /dev/null
+++ b/test-suite/output/prim_array.out
@@ -0,0 +1,9 @@
+[| | 0 : nat |]
+ : array nat
+[| 1; 2; 3 | 0 : nat |]
+ : array nat
+[| | 0 : nat |]@{Set}
+ : array@{Set} nat
+[| bool; list nat | nat : Set |]@{prim_array.4}
+ : array@{prim_array.4} Set
+(* {prim_array.4} |= Set < prim_array.4 *)
diff --git a/test-suite/output/prim_array.v b/test-suite/output/prim_array.v
new file mode 100644
index 0000000000..a82f6a16f1
--- /dev/null
+++ b/test-suite/output/prim_array.v
@@ -0,0 +1,10 @@
+Primitive array := #array_type.
+
+Check [| | 0 |].
+
+Check [| 1; 2; 3 | 0 |].
+
+Set Printing Universes.
+Check [| | 0 |].
+
+Check [| bool; list nat | nat |].