aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2005-05-20 15:45:51 +0000
committerGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2005-05-20 15:45:51 +0000
commitf95411d169c8d636e980de3a38bb02c72c3b4965 (patch)
tree8d51764141dc5ff922f4cdbb0812a954ca7fa725
parent72e2acbcf23a70b9d6a708676b0053a7cd4eca0b (diff)
Déplacement et export de locate_global (ex-locate_reference) de tacinterp vers syntax_def
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@7051 85f007b7-540e-0410-9357-904b9bb8a0f7
-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
+