aboutsummaryrefslogtreecommitdiffstats
path: root/src/lfsc/type.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/lfsc/type.ml')
-rw-r--r--src/lfsc/type.ml36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/lfsc/type.ml b/src/lfsc/type.ml
new file mode 100644
index 0000000..7c30a2a
--- /dev/null
+++ b/src/lfsc/type.ml
@@ -0,0 +1,36 @@
+(**************************************************************************)
+(* *)
+(* SMTCoq *)
+(* Copyright (C) 2011 - 2019 *)
+(* *)
+(* See file "AUTHORS" for the list of authors *)
+(* *)
+(* This file is distributed under the terms of the CeCILL-C licence *)
+(* *)
+(**************************************************************************)
+
+
+(** Type of S-expressions *)
+type t = Atom of string | List of t list
+
+
+let rec print fmt = function
+ | Atom s -> Format.pp_print_string fmt s
+ | List l ->
+ Format.fprintf fmt "(";
+ List.iter (Format.fprintf fmt "%a " print) l;
+ Format.fprintf fmt ")"
+
+let rec print_list fmt = function
+ | [] -> ()
+ | s :: r ->
+ Format.fprintf fmt "%a@." print s;
+ print_list fmt r
+
+let rec size = function
+ | Atom _ -> 1
+ | List l -> List.fold_left (fun acc s -> size s + acc) 0 l
+
+let rec size_list = function
+ | [] -> 0
+ | s :: r -> size s + size_list r