intern xthm only once;
authorwenzelm
Thu, 28 Aug 2014 13:25:12 +0200
changeset 58068 d6f29bf9b783
parent 58067 a7a0af643499
child 58069 0255436b3d85
intern xthm only once;
src/Pure/Isar/method.ML
--- a/src/Pure/Isar/method.ML	Thu Aug 28 07:34:23 2014 +0200
+++ b/src/Pure/Isar/method.ML	Thu Aug 28 13:25:12 2014 +0200
@@ -462,38 +462,35 @@
 local
 
 fun sect (modifier : modifier parser) = Scan.depend (fn context =>
-  let
-    val ctxt = Context.proof_of context;
-    fun prep_att src =
+  Scan.ahead Parse.not_eof -- modifier -- Scan.repeat (Scan.unless modifier Parse.xthm) >>
+    (fn ((tok, {init, attribute, pos}), xthms) =>
       let
-        val src' = Attrib.check_src ctxt src;
-        val _ = List.app (Token.assign NONE) (Token.args_of_src src');
-      in src' end;
-    val parse_thm =
-      Parse.xthm >> (fn (a, bs) => (Proof_Context.get_fact ctxt a, map prep_att bs));
-  in
-    Scan.ahead Parse.not_eof -- modifier -- Scan.repeat (Scan.unless modifier parse_thm) >>
-      (fn ((tok, {init, attribute, pos}), thms) =>
-        let
-          val decl =
-            (case Token.get_value tok of
-              SOME (Token.Declaration decl) => decl
-            | _ =>
-                let
-                  val facts =
-                    Attrib.partial_evaluation ctxt [((Binding.name "dummy", []), thms)]
-                    |> map (fn (_, bs) => ((Binding.empty, [Attrib.internal (K attribute)]), bs));
-                  val _ =
-                    Context_Position.report ctxt (Token.pos_of tok)
-                      (Markup.entity Markup.method_modifierN ""
-                        |> Markup.properties (Position.def_properties_of pos));
-                  fun decl phi =
-                    Context.mapping I init #>
-                    Attrib.generic_notes "" (Attrib.transform_facts phi facts) #> snd;
-                  val _ = Token.assign (SOME (Token.Declaration decl)) tok;
-                in decl end);
-        in (Morphism.form decl context, decl) end)
-  end);
+        val decl =
+          (case Token.get_value tok of
+            SOME (Token.Declaration decl) => decl
+          | _ =>
+              let
+                val ctxt = Context.proof_of context;
+                fun prep_att src =
+                  let
+                    val src' = Attrib.check_src ctxt src;
+                    val _ = List.app (Token.assign NONE) (Token.args_of_src src');
+                  in src' end;
+                val thms =
+                  map (fn (a, bs) => (Proof_Context.get_fact ctxt a, map prep_att bs)) xthms;
+                val facts =
+                  Attrib.partial_evaluation ctxt [((Binding.name "dummy", []), thms)]
+                  |> map (fn (_, bs) => ((Binding.empty, [Attrib.internal (K attribute)]), bs));
+                val _ =
+                  Context_Position.report ctxt (Token.pos_of tok)
+                    (Markup.entity Markup.method_modifierN ""
+                      |> Markup.properties (Position.def_properties_of pos));
+                fun decl phi =
+                  Context.mapping I init #>
+                  Attrib.generic_notes "" (Attrib.transform_facts phi facts) #> snd;
+                val _ = Token.assign (SOME (Token.Declaration decl)) tok;
+              in decl end);
+      in (Morphism.form decl context, decl) end));
 
 in