New interface function parameters_of_expr.
authorballarin
Thu, 16 Mar 2006 20:19:25 +0100
changeset 19276 ac90764bb654
parent 19275 3d10de7a8ca7
child 19277 f7602e74d948
New interface function parameters_of_expr.
src/Pure/Isar/locale.ML
--- a/src/Pure/Isar/locale.ML	Wed Mar 15 17:59:33 2006 +0100
+++ b/src/Pure/Isar/locale.ML	Thu Mar 16 20:19:25 2006 +0100
@@ -47,6 +47,8 @@
 
   val parameters_of: theory -> string ->
     ((string * typ) * mixfix) list
+  val parameters_of_expr: theory -> expr ->
+    ((string * typ) * mixfix) list
   val local_asms_of: theory -> string ->
     ((string * Attrib.src list) * term list) list
   val global_asms_of: theory -> string ->
@@ -1275,6 +1277,14 @@
 fun parameters_of thy name =
   the_locale thy name |> #params |> fst;
 
+fun parameters_of_expr thy expr =
+  let
+    val ctxt = ProofContext.init thy;
+    val ((_, syn), raw_elemss) = flatten (ctxt, intern_expr thy)
+        (([], Symtab.empty), Expr expr);
+    val ((parms, _, _), _) = read_elemss false ctxt [] raw_elemss [];
+  in map (fn p as (n, _) => (p, Symtab.lookup syn n |> the)) parms end;
+
 fun local_asms_of thy name =
   gen_asms_of (single o Library.last_elem) thy name;