aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp/notation.ml
diff options
context:
space:
mode:
authorGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2014-09-24 17:37:10 +0200
committerGravatar Enrico Tassi <Enrico.Tassi@inria.fr>2014-09-29 21:54:31 +0200
commit8f118b444db7693dcc16dda4c271d2528bfa949a (patch)
treea01df0fd808a3d17b1e3d12d7710225c533bfe12 /interp/notation.ml
parentec49447d078da25959d617ae23e55a668fdd1646 (diff)
Notation: option to attach extra pretty printing rules to notations
so that one can retrieve them and pass them to third party tools (i.e. print the AST with the notations attached to the nodes concerned). Available syntax: - all in one: Notation "a /\ b" := ... (format "...", format "latex" "#1 \wedge #2"). - a posteriori: Format Notation "a /\ b" "latex" "#1 \wedge #2".
Diffstat (limited to 'interp/notation.ml')
-rw-r--r--interp/notation.ml21
1 files changed, 16 insertions, 5 deletions
diff --git a/interp/notation.ml b/interp/notation.ml
index e765701d4..93e6f31c0 100644
--- a/interp/notation.ml
+++ b/interp/notation.ml
@@ -940,17 +940,28 @@ let pr_visibility prglob = function
(* Mapping notations to concrete syntax *)
type unparsing_rule = unparsing list * precedence
-
+type extra_unparsing_rules = (string * string) list
(* Concrete syntax for symbolic-extension table *)
let printing_rules =
- ref (String.Map.empty : unparsing_rule String.Map.t)
+ ref (String.Map.empty : (unparsing_rule * extra_unparsing_rules) String.Map.t)
-let declare_notation_printing_rule ntn unpl =
- printing_rules := String.Map.add ntn unpl !printing_rules
+let declare_notation_printing_rule ntn ~extra unpl =
+ printing_rules := String.Map.add ntn (unpl,extra) !printing_rules
let find_notation_printing_rule ntn =
- try String.Map.find ntn !printing_rules
+ try fst (String.Map.find ntn !printing_rules)
with Not_found -> anomaly (str "No printing rule found for " ++ str ntn)
+let find_notation_extra_printing_rules ntn =
+ try snd (String.Map.find ntn !printing_rules)
+ with Not_found -> []
+let add_notation_extra_printing_rule ntn k v =
+ try
+ printing_rules :=
+ let p, pp = String.Map.find ntn !printing_rules in
+ String.Map.add ntn (p, (k,v) :: pp) !printing_rules
+ with Not_found ->
+ user_err_loc (Loc.ghost,"add_notation_extra_printing_rule",
+ str "No such Notation.")
(**********************************************************************)
(* Synchronisation with reset *)