diff options
Diffstat (limited to 'toplevel')
| -rw-r--r-- | toplevel/command.ml | 4 | ||||
| -rw-r--r-- | toplevel/metasyntax.ml | 12 | ||||
| -rw-r--r-- | toplevel/metasyntax.mli | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/toplevel/command.ml b/toplevel/command.ml index 3657c5d5af..8bb875ffb5 100644 --- a/toplevel/command.ml +++ b/toplevel/command.ml @@ -273,7 +273,7 @@ let interp_mutual_inductive (paramsl,indl) notations finite = let mldatas = List.map2 (mk_mltype_data evdref env_params params) arities indnames in let constructors = - States.with_state_protection (fun () -> + Metasyntax.with_syntax_protection (fun () -> (* Temporary declaration of notations and scopes *) List.iter (Metasyntax.set_notation_for_interpretation impls) notations; (* Interpret the constructor types *) @@ -753,7 +753,7 @@ let interp_recursive isfix fixl notations = (* Interp bodies with rollback because temp use of notations/implicit *) let fixdefs = - States.with_state_protection (fun () -> + Metasyntax.with_syntax_protection (fun () -> List.iter (Metasyntax.set_notation_for_interpretation impls) notations; list_map3 (interp_fix_body evdref env_rec impls) fixctxs fixl fixccls) () in diff --git a/toplevel/metasyntax.ml b/toplevel/metasyntax.ml index 76326f51ff..8415f0bcc9 100644 --- a/toplevel/metasyntax.ml +++ b/toplevel/metasyntax.ml @@ -987,6 +987,18 @@ let inNotation : notation_obj -> obj = classify_function = classify_notation} (**********************************************************************) + +let with_lib_stk_protection f x = + let fs = Lib.freeze () in + try let a = f x in Lib.unfreeze fs; a + with e -> Lib.unfreeze fs; raise e + +let with_syntax_protection f x = + with_lib_stk_protection + (with_grammar_rule_protection + (with_notation_protection f)) x + +(**********************************************************************) (* Recovering existing syntax *) let contract_notation ntn = diff --git a/toplevel/metasyntax.mli b/toplevel/metasyntax.mli index 74a8e0fe9c..e228b829ac 100644 --- a/toplevel/metasyntax.mli +++ b/toplevel/metasyntax.mli @@ -62,3 +62,5 @@ val add_syntactic_definition : identifier -> identifier list * constr_expr -> val print_grammar : string -> unit val check_infix_modifiers : syntax_modifier list -> unit + +val with_syntax_protection : ('a -> 'b) -> 'a -> 'b |
