229 |> add_fixes vars |-> fold_map Proof_Context.inferred_param |>> map Free; |
229 |> add_fixes vars |-> fold_map Proof_Context.inferred_param |>> map Free; |
230 |
230 |
231 val (named_thms, modifiers) = map (check_attrib lthy2) (declares @ uses) |> split_list; |
231 val (named_thms, modifiers) = map (check_attrib lthy2) (declares @ uses) |> split_list; |
232 val method_names = map (Local_Theory.full_name lthy2) methods; |
232 val method_names = map (Local_Theory.full_name lthy2) methods; |
233 |
233 |
234 fun parser args eval = |
234 fun parser args = |
235 apfst (Config.put_generic Method.old_section_parser true) #> |
235 apfst (Config.put_generic Method.old_section_parser true) #> |
236 (parse_term_args args -- |
236 (parse_term_args args -- |
237 parse_method_args method_names --| |
237 parse_method_args method_names --| |
238 (Scan.depend (fn context => |
238 (Scan.depend (fn context => |
239 Scan.succeed (fold Named_Theorems.clear uses_internal context, ())) -- |
239 Scan.succeed (fold Named_Theorems.clear uses_internal context, ())) -- |
240 Method.sections modifiers) >> eval); |
240 Method.sections modifiers)); |
241 |
241 |
242 val lthy3 = lthy2 |
242 val lthy3 = lthy2 |
243 |> fold dummy_named_thm named_thms |
243 |> fold dummy_named_thm named_thms |
244 |> Method.local_setup (Binding.make (Binding.name_of name, Position.none)) |
244 |> Method.local_setup (Binding.make (Binding.name_of name, Position.none)) |
245 (parser term_args |
245 (parser term_args >> (fn (fixes, decl) => |
246 (fn (fixes, decl) => fn ctxt => get_recursive_method ctxt fixes (decl ctxt))) "(internal)"; |
246 fn ctxt => get_recursive_method ctxt fixes (decl ctxt))) "(internal)"; |
247 |
247 |
248 val (text, src) = read_closure lthy3 source; |
248 val (text, src) = read_closure lthy3 source; |
249 |
249 |
250 val morphism = |
250 val morphism = |
251 Variable.export_morphism lthy3 |
251 Variable.export_morphism lthy3 |
258 val term_args' = map (Morphism.term morphism) term_args; |
258 val term_args' = map (Morphism.term morphism) term_args; |
259 |
259 |
260 fun real_exec ts ctxt = |
260 fun real_exec ts ctxt = |
261 method_instantiate (match_term_args ctxt term_args' ts) text' ctxt; |
261 method_instantiate (match_term_args ctxt term_args' ts) text' ctxt; |
262 val real_parser = |
262 val real_parser = |
263 parser term_args' (fn (fixes, decl) => fn ctxt => |
263 parser term_args' >> (fn (fixes, decl) => fn ctxt => |
264 real_exec fixes (put_recursive_method real_exec (decl ctxt))); |
264 real_exec fixes (put_recursive_method real_exec (decl ctxt))); |
265 in |
265 in |
266 lthy3 |
266 lthy3 |
267 |> Local_Theory.close_target |
267 |> Local_Theory.close_target |
268 |> Proof_Context.restore_naming lthy |
268 |> Proof_Context.restore_naming lthy |