From 0f1b5603d1922718f36545f201212fc2796f41a4 Mon Sep 17 00:00:00 2001 From: Emilio Jesus Gallego Arias Date: Sat, 24 Sep 2016 20:36:59 +0200 Subject: [notation] Allow to retrieve defined notations. The ML side lacks a method to query Coq for notations with defined parsing/printing rules. This commit adds a method `get_defined_notations` to that purpose. This is very useful for instance in plugins like SerAPI. In the medium-term, the `Notation` interface may benefit from a bit of refactoring to allow programmatic access and manipulation of notations. --- interp/notation.ml | 3 +++ interp/notation.mli | 3 +++ 2 files changed, 6 insertions(+) (limited to 'interp') diff --git a/interp/notation.ml b/interp/notation.ml index 0798d385d4..547c72e107 100644 --- a/interp/notation.ml +++ b/interp/notation.ml @@ -1011,6 +1011,9 @@ let find_notation_parsing_rules ntn = try pi3 (String.Map.find ntn !notation_rules) with Not_found -> anomaly (str "No parsing rule found for " ++ str ntn) +let get_defined_notations () = + String.Set.elements @@ String.Map.domain !notation_rules + let add_notation_extra_printing_rule ntn k v = try notation_rules := diff --git a/interp/notation.mli b/interp/notation.mli index b47e1975e3..2e92a00a8c 100644 --- a/interp/notation.mli +++ b/interp/notation.mli @@ -203,6 +203,9 @@ val find_notation_extra_printing_rules : notation -> extra_unparsing_rules val find_notation_parsing_rules : notation -> notation_grammar val add_notation_extra_printing_rule : notation -> string -> string -> unit +(** Returns notations with defined parsing/printing rules *) +val get_defined_notations : unit -> notation list + (** Rem: printing rules for primitive token are canonical *) val with_notation_protection : ('a -> 'b) -> 'a -> 'b -- cgit v1.2.3 From fd39a2e844f93b314c2f0b78510f0573cfa1bef3 Mon Sep 17 00:00:00 2001 From: Théo Zimmermann Date: Thu, 6 Oct 2016 19:34:28 +0200 Subject: Revert "Make the pretty printer resilient to incomplete nametab (progress on #4363)." This reverts commit 11ccb7333c2a82d59736027838acaea2237e2402. This fixes bug #4874. We fallback to the original error message of v8.4. The fallback printer introduced in this commit only gave unqualified names, which is what this bug reports. --- interp/constrextern.ml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'interp') diff --git a/interp/constrextern.ml b/interp/constrextern.ml index 68a3cf0f4a..ae9b5bace2 100644 --- a/interp/constrextern.ml +++ b/interp/constrextern.ml @@ -147,17 +147,8 @@ let extern_evar loc n l = CEvar (loc,n,l) For instance, in the debugger the tables of global references may be inaccurate *) -let safe_shortest_qualid_of_global vars r = - try shortest_qualid_of_global vars r - with Not_found -> - match r with - | VarRef v -> make_qualid DirPath.empty v - | ConstRef c -> make_qualid DirPath.empty Names.(Label.to_id (con_label c)) - | IndRef (i,_) | ConstructRef ((i,_),_) -> - make_qualid DirPath.empty Names.(Label.to_id (mind_label i)) - let default_extern_reference loc vars r = - Qualid (loc,safe_shortest_qualid_of_global vars r) + Qualid (loc,shortest_qualid_of_global vars r) let my_extern_reference = ref default_extern_reference -- cgit v1.2.3