81 -> theory -> theory |
81 -> theory -> theory |
82 val syntax: 'a context_parser -> src -> Proof.context -> 'a * Proof.context |
82 val syntax: 'a context_parser -> src -> Proof.context -> 'a * Proof.context |
83 val setup: binding -> (Proof.context -> method) context_parser -> string -> theory -> theory |
83 val setup: binding -> (Proof.context -> method) context_parser -> string -> theory -> theory |
84 val method_setup: bstring * Position.T -> Symbol_Pos.text * Position.T -> string -> |
84 val method_setup: bstring * Position.T -> Symbol_Pos.text * Position.T -> string -> |
85 theory -> theory |
85 theory -> theory |
86 val simple_args: 'a parser -> ('a -> Proof.context -> method) -> src -> Proof.context -> method |
|
87 val ctxt_args: (Proof.context -> method) -> src -> Proof.context -> method |
|
88 type modifier = (Proof.context -> Proof.context) * attribute |
86 type modifier = (Proof.context -> Proof.context) * attribute |
89 val section: modifier parser list -> thm list context_parser |
87 val section: modifier parser list -> thm list context_parser |
90 val sections: modifier parser list -> thm list list context_parser |
88 val sections: modifier parser list -> thm list list context_parser |
91 val sectioned_args: 'a context_parser -> modifier parser list -> |
|
92 ('a -> Proof.context -> 'b) -> src -> Proof.context -> 'b |
|
93 val bang_sectioned_args: modifier parser list -> |
|
94 (thm list -> Proof.context -> 'a) -> src -> Proof.context -> 'a |
|
95 val bang_sectioned_args': modifier parser list -> 'a context_parser -> |
|
96 ('a -> thm list -> Proof.context -> 'b) -> src -> Proof.context -> 'b |
|
97 val only_sectioned_args: modifier parser list -> (Proof.context -> 'a) -> src -> |
|
98 Proof.context -> 'a |
|
99 val thms_ctxt_args: (thm list -> Proof.context -> 'a) -> src -> Proof.context -> 'a |
|
100 val thms_args: (thm list -> 'a) -> src -> Proof.context -> 'a |
|
101 val thm_args: (thm -> 'a) -> src -> Proof.context -> 'a |
|
102 val parse: text parser |
89 val parse: text parser |
103 end; |
90 end; |
104 |
91 |
105 structure Method: METHOD = |
92 structure Method: METHOD = |
106 struct |
93 struct |
409 (** concrete syntax **) |
396 (** concrete syntax **) |
410 |
397 |
411 structure P = OuterParse; |
398 structure P = OuterParse; |
412 |
399 |
413 |
400 |
414 (* basic *) |
|
415 |
|
416 fun simple_args scan f src ctxt : method = |
|
417 fst (syntax (Scan.lift (scan >> (fn x => f x ctxt))) src ctxt); |
|
418 |
|
419 fun ctxt_args (f: Proof.context -> method) src ctxt = |
|
420 fst (syntax (Scan.succeed (f ctxt)) src ctxt); |
|
421 |
|
422 |
|
423 (* sections *) |
401 (* sections *) |
424 |
402 |
425 type modifier = (Proof.context -> Proof.context) * attribute; |
403 type modifier = (Proof.context -> Proof.context) * attribute; |
426 |
404 |
427 local |
405 local |
433 |
411 |
434 fun section ss = Scan.depend (fn context => (Scan.first ss -- Scan.pass context (thms ss)) :|-- |
412 fun section ss = Scan.depend (fn context => (Scan.first ss -- Scan.pass context (thms ss)) :|-- |
435 (fn (m, ths) => Scan.succeed (app m (context, ths)))); |
413 (fn (m, ths) => Scan.succeed (app m (context, ths)))); |
436 |
414 |
437 fun sections ss = Scan.repeat (section ss); |
415 fun sections ss = Scan.repeat (section ss); |
438 |
|
439 fun sectioned_args args ss f src ctxt = |
|
440 let val ((x, _), ctxt') = syntax (args -- sections ss) src ctxt |
|
441 in f x ctxt' end; |
|
442 |
|
443 fun bang_sectioned_args ss f = sectioned_args Args.bang_facts ss f; |
|
444 fun bang_sectioned_args' ss scan f = |
|
445 sectioned_args (Args.bang_facts -- scan >> swap) ss (uncurry f); |
|
446 fun only_sectioned_args ss f = sectioned_args (Scan.succeed ()) ss (fn () => f); |
|
447 |
|
448 fun thms_ctxt_args f = sectioned_args (thms []) [] f; |
|
449 fun thms_args f = thms_ctxt_args (K o f); |
|
450 fun thm_args f = thms_args (fn [thm] => f thm | _ => error "Single theorem expected"); |
|
451 |
416 |
452 end; |
417 end; |
453 |
418 |
454 |
419 |
455 (* extra rule methods *) |
420 (* extra rule methods *) |