aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--interp/syntax_def.ml12
-rw-r--r--interp/syntax_def.mli7
2 files changed, 19 insertions, 0 deletions
diff --git a/interp/syntax_def.ml b/interp/syntax_def.ml
index 17c0e96c8..25dc54b37 100644
--- a/interp/syntax_def.ml
+++ b/interp/syntax_def.ml
@@ -73,3 +73,15 @@ let rec set_loc loc _ a =
let search_syntactic_definition loc kn =
set_loc loc () (KNmap.find kn !syntax_table)
+
+exception BoundToASyntacticDefThatIsNotARef
+
+let locate_global qid =
+ match Nametab.extended_locate qid with
+ | TrueGlobal ref -> ref
+ | SyntacticDef kn ->
+ match search_syntactic_definition dummy_loc kn with
+ | Rawterm.RRef (_,ref) -> ref
+ | _ ->
+ errorlabstrm "" (pr_qualid qid ++
+ str " is bound to a notation that does not denote a reference")
diff --git a/interp/syntax_def.mli b/interp/syntax_def.mli
index 96361ab3f..50f2f3e7d 100644
--- a/interp/syntax_def.mli
+++ b/interp/syntax_def.mli
@@ -23,3 +23,10 @@ val declare_syntactic_definition : bool -> identifier -> bool -> aconstr
val search_syntactic_definition : loc -> kernel_name -> rawconstr
+(* [locate_global] locates global reference possibly following a chain of
+ syntactic aliases; raise Not_found if not bound in the global env;
+ raise an error if bound to a syntactic def that does not denote a
+ reference *)
+
+val locate_global : Libnames.qualid -> Libnames.global_reference
+