98 Scan.lift (for_fixes -- (@{keyword "\<Rightarrow>"} |-- Parse.token Parse.cartouche)) |
98 Scan.lift (for_fixes -- (@{keyword "\<Rightarrow>"} |-- Parse.token Parse.cartouche)) |
99 >> (fn ((ctxt, ts), (fixes, cartouche)) => |
99 >> (fn ((ctxt, ts), (fixes, cartouche)) => |
100 (case Token.get_value cartouche of |
100 (case Token.get_value cartouche of |
101 SOME (Token.Source src) => |
101 SOME (Token.Source src) => |
102 let |
102 let |
103 val text = Method_Closure.read_inner_method ctxt src |
103 val text = Method_Closure.read ctxt src; |
104 val ts' = |
104 val ts' = |
105 map |
105 map |
106 (fn (b, (Parse_Tools.Real_Val v, match_args)) => |
106 (fn (b, (Parse_Tools.Real_Val v, match_args)) => |
107 ((Option.map (fn (b, att) => |
107 ((Option.map (fn (b, att) => |
108 (Parse_Tools.the_real_val b, att)) b, match_args), v) |
108 (Parse_Tools.the_real_val b, att)) b, match_args), v) |
109 | _ => raise Fail "Expected closed term") ts |
109 | _ => raise Fail "Expected closed term") ts |
110 val fixes' = map (fn ((p, _), _) => Parse_Tools.the_real_val p) fixes |
110 val fixes' = map (fn ((p, _), _) => Parse_Tools.the_real_val p) fixes |
111 in (ts', fixes', text) end |
111 in (ts', fixes', text) end |
112 | SOME _ => error "Unexpected token value in match cartouche" |
112 | _ => |
113 | NONE => |
|
114 let |
113 let |
115 val (fix_names, ctxt3) = ctxt |
114 val (fix_names, ctxt3) = ctxt |
116 |> Proof_Context.add_fixes_cmd |
115 |> Proof_Context.add_fixes_cmd |
117 (map (fn ((pb, otyp), _) => (Parse_Tools.the_parse_val pb, otyp, NoSyn)) fixes) |
116 (map (fn ((pb, otyp), _) => (Parse_Tools.the_parse_val pb, otyp, NoSyn)) fixes) |
118 ||> Proof_Context.set_mode Proof_Context.mode_schematic; |
117 ||> Proof_Context.set_mode Proof_Context.mode_schematic; |
198 |
197 |
199 val (binds, ctxt6) = ctxt5 |
198 val (binds, ctxt6) = ctxt5 |
200 |> (fn ctxt => fold2 upd_ctxt binds pats ([], ctxt) |> apfst rev) |
199 |> (fn ctxt => fold2 upd_ctxt binds pats ([], ctxt) |> apfst rev) |
201 ||> Proof_Context.restore_mode ctxt; |
200 ||> Proof_Context.restore_mode ctxt; |
202 |
201 |
203 val (src, text) = Method_Closure.read_inner_text_closure ctxt6 (Token.input_of cartouche); |
202 val (text, src) = Method_Closure.read_closure_input ctxt6 (Token.input_of cartouche); |
204 |
203 |
205 val morphism = |
204 val morphism = |
206 Variable.export_morphism ctxt6 |
205 Variable.export_morphism ctxt6 |
207 (ctxt |
206 (ctxt |
208 |> fold Token.declare_maxidx src |
207 |> fold Token.declare_maxidx src |