summaryrefslogtreecommitdiff
path: root/src/PureToExtract.ml
diff options
context:
space:
mode:
authorSon Ho2022-02-02 15:48:24 +0100
committerSon Ho2022-02-02 15:48:24 +0100
commit4f500539e8681c0814cd59fc27680bca73b602c3 (patch)
treedd636ccacea0c7fb8cc6a7788f8b79a4fa25b09f /src/PureToExtract.ml
parent5faf86a5718daf2030d77a8e8e1b321ffb13913d (diff)
Start generating code for type definitions
Diffstat (limited to '')
-rw-r--r--src/PureToExtract.ml13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/PureToExtract.ml b/src/PureToExtract.ml
index d6e96d3d..4e6c9014 100644
--- a/src/PureToExtract.ml
+++ b/src/PureToExtract.ml
@@ -211,6 +211,19 @@ type names_map = {
We use it for lookups (during the translation) and to check for name clashes.
*)
+(** Initialize a names map with a proper set of keywords/names coming from the
+ target language/prover. *)
+let initialize_names_map (keywords : string list) : names_map =
+ let name_to_id =
+ StringMap.of_list (List.map (fun x -> (x, UnknownId)) keywords)
+ in
+ let names_set = StringSet.of_list keywords in
+ (* We initialize [id_to_name] as empty, because the id of a keyword is [UnknownId].
+ * Also note that we don't need this mapping for keywords: we insert keywords only
+ * to check collisions. *)
+ let id_to_name = IdMap.empty in
+ { id_to_name; name_to_id; names_set }
+
let names_map_add (id : id) (name : string) (nm : names_map) : names_map =
(* Sanity check: no clashes *)
assert (not (StringSet.mem name nm.names_set));