Skip to content

Commit 6d9f95d

Browse files
authored
Merge pull request #101 from SkySkimmer/fix-synterp
Respect synterp/interp phase split
2 parents 353dc24 + 889f675 commit 6d9f95d

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

plugin/bignums_syntax.ml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,34 @@ let bigN_list_of_constructors =
191191
in
192192
build 0
193193

194+
let cache_bignums o =
195+
Notation.declare_scope o.Notation.pt_scope;
196+
Notation.enable_prim_token_interpretation o
197+
198+
let bignums_obj =
199+
Libobject.declare_object @@
200+
Libobject.superglobal_object_nodischarge "bignums_obj"
201+
~cache:cache_bignums
202+
~subst:None
203+
194204
let declare_numeral_interpreter uid sc dir interp (patl,uninterp,b) =
195-
let open Notation in
196-
register_bignumeral_interpretation uid (interp,uninterp);
197-
enable_prim_token_interpretation { pt_local = false;
198-
pt_scope = sc;
199-
pt_interp_info = Uid uid;
200-
pt_required = dir;
201-
pt_refs = patl;
202-
pt_in_match = b }
205+
(* unsynchronized state *)
206+
Notation.register_bignumeral_interpretation uid (interp,uninterp);
207+
let interp () = Lib.add_leaf (bignums_obj {
208+
(* we wrap in out own object (to get superglobal instead of export),
209+
so we pass local to the Notation layer *)
210+
pt_local = true;
211+
pt_scope = sc;
212+
pt_interp_info = Uid uid;
213+
pt_required = dir;
214+
pt_refs = patl;
215+
pt_in_match = b;
216+
})
217+
in
218+
Mltop.declare_cache_obj_full (CacheObj { synterp = (fun () -> ()); interp; }) "coq-bignums.plugin"
203219

204220
(* Actually declares the interpreter for bigN *)
205221
let () =
206-
Notation.declare_scope bigN_scope;
207222
declare_numeral_interpreter "bignums.bigN" bigN_scope
208223
(bigN_path, bigN_module)
209224
interp_bigN
@@ -241,7 +256,6 @@ let uninterp_bigZ (AnyGlobConstr rc) =
241256

242257
(* Actually declares the interpreter for bigZ *)
243258
let () =
244-
Notation.declare_scope bigZ_scope;
245259
declare_numeral_interpreter "bignums.bigZ" bigZ_scope
246260
(bigZ_path, bigZ_module)
247261
interp_bigZ
@@ -263,7 +277,6 @@ let uninterp_bigQ (AnyGlobConstr rc) =
263277

264278
(* Actually declares the interpreter for bigQ *)
265279
let () =
266-
Notation.declare_scope bigQ_scope;
267280
declare_numeral_interpreter "bignums.bigQ" bigQ_scope
268281
(bigQ_path, bigQ_module)
269282
interp_bigQ

0 commit comments

Comments
 (0)