150 | advancedN true = "advanced_"; |
150 | advancedN true = "advanced_"; |
151 |
151 |
152 in |
152 in |
153 |
153 |
154 fun parse_ast_translation (a, (txt, pos)) = |
154 fun parse_ast_translation (a, (txt, pos)) = |
155 txt |> ML_Context.use_let pos ("val parse_ast_translation: (string * (" ^ advancedT a ^ |
155 txt |> ML_Context.expression pos |
|
156 ("val parse_ast_translation: (string * (" ^ advancedT a ^ |
156 "Syntax.ast list -> Syntax.ast)) list") |
157 "Syntax.ast list -> Syntax.ast)) list") |
157 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns (parse_ast_translation, [], [], []))") |
158 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns (parse_ast_translation, [], [], []))") |
158 |> Context.theory_map; |
159 |> Context.theory_map; |
159 |
160 |
160 fun parse_translation (a, (txt, pos)) = |
161 fun parse_translation (a, (txt, pos)) = |
161 txt |> ML_Context.use_let pos ("val parse_translation: (string * (" ^ advancedT a ^ |
162 txt |> ML_Context.expression pos |
|
163 ("val parse_translation: (string * (" ^ advancedT a ^ |
162 "term list -> term)) list") |
164 "term list -> term)) list") |
163 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], parse_translation, [], []))") |
165 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], parse_translation, [], []))") |
164 |> Context.theory_map; |
166 |> Context.theory_map; |
165 |
167 |
166 fun print_translation (a, (txt, pos)) = |
168 fun print_translation (a, (txt, pos)) = |
167 txt |> ML_Context.use_let pos ("val print_translation: (string * (" ^ advancedT a ^ |
169 txt |> ML_Context.expression pos |
|
170 ("val print_translation: (string * (" ^ advancedT a ^ |
168 "term list -> term)) list") |
171 "term list -> term)) list") |
169 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], print_translation, []))") |
172 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], print_translation, []))") |
170 |> Context.theory_map; |
173 |> Context.theory_map; |
171 |
174 |
172 fun print_ast_translation (a, (txt, pos)) = |
175 fun print_ast_translation (a, (txt, pos)) = |
173 txt |> ML_Context.use_let pos ("val print_ast_translation: (string * (" ^ advancedT a ^ |
176 txt |> ML_Context.expression pos |
|
177 ("val print_ast_translation: (string * (" ^ advancedT a ^ |
174 "Syntax.ast list -> Syntax.ast)) list") |
178 "Syntax.ast list -> Syntax.ast)) list") |
175 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], [], print_ast_translation))") |
179 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfuns ([], [], [], print_ast_translation))") |
176 |> Context.theory_map; |
180 |> Context.theory_map; |
177 |
181 |
178 fun typed_print_translation (a, (txt, pos)) = |
182 fun typed_print_translation (a, (txt, pos)) = |
179 txt |> ML_Context.use_let pos ("val typed_print_translation: (string * (" ^ advancedT a ^ |
183 txt |> ML_Context.expression pos |
|
184 ("val typed_print_translation: (string * (" ^ advancedT a ^ |
180 "bool -> typ -> term list -> term)) list") |
185 "bool -> typ -> term list -> term)) list") |
181 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfunsT typed_print_translation)") |
186 ("Context.map_theory (Sign.add_" ^ advancedN a ^ "trfunsT typed_print_translation)") |
182 |> Context.theory_map; |
187 |> Context.theory_map; |
183 |
188 |
184 fun token_translation (txt, pos) = |
189 fun token_translation (txt, pos) = |
185 txt |> ML_Context.use_let pos |
190 txt |> ML_Context.expression pos |
186 "val token_translation: (string * string * (string -> output * int)) list" |
191 "val token_translation: (string * string * (string -> output * int)) list" |
187 "Context.map_theory (Sign.add_tokentrfuns token_translation)" |
192 "Context.map_theory (Sign.add_tokentrfuns token_translation)" |
188 |> Context.theory_map; |
193 |> Context.theory_map; |
189 |
194 |
190 end; |
195 end; |
231 |
235 |
232 |
236 |
233 (* declarations *) |
237 (* declarations *) |
234 |
238 |
235 fun declaration (txt, pos) = |
239 fun declaration (txt, pos) = |
236 txt |> ML_Context.use_let pos "val declaration: Morphism.declaration" |
240 txt |> ML_Context.expression pos |
|
241 "val declaration: Morphism.declaration" |
237 "Context.map_proof (LocalTheory.declaration declaration)" |
242 "Context.map_proof (LocalTheory.declaration declaration)" |
238 |> Context.proof_map; |
243 |> Context.proof_map; |
239 |
244 |
240 |
245 |
241 (* simprocs *) |
246 (* simprocs *) |
242 |
247 |
243 fun simproc_setup name lhss (proc, pos) identifier = |
248 fun simproc_setup name lhss (proc, pos) identifier = |
244 ML_Context.use_let pos |
249 ML_Context.expression pos |
245 "val proc: Morphism.morphism -> Simplifier.simpset -> cterm -> thm option" |
250 "val proc: Morphism.morphism -> Simplifier.simpset -> cterm -> thm option" |
246 ("Context.map_proof (Simplifier.def_simproc {name = " ^ ML_Syntax.print_string name ^ ", \ |
251 ("Context.map_proof (Simplifier.def_simproc {name = " ^ ML_Syntax.print_string name ^ ", \ |
247 \lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \ |
252 \lhss = " ^ ML_Syntax.print_strings lhss ^ ", proc = proc, \ |
248 \identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})") proc |
253 \identifier = Library.maps ML_Context.thms " ^ ML_Syntax.print_strings identifier ^ "})") proc |
249 |> Context.proof_map; |
254 |> Context.proof_map; |
380 |
385 |
381 fun use path = Toplevel.keep (fn state => |
386 fun use path = Toplevel.keep (fn state => |
382 Context.setmp_thread_data (try Toplevel.generic_theory_of state) (ThyInfo.load_file false) path); |
387 Context.setmp_thread_data (try Toplevel.generic_theory_of state) (ThyInfo.load_file false) path); |
383 |
388 |
384 (*passes changes of theory context*) |
389 (*passes changes of theory context*) |
385 fun use_mltext_theory (txt, pos) = |
390 fun use_mltext_theory (txt, pos) = Toplevel.theory' (fn int => |
386 Toplevel.theory' (fn int => Context.theory_map (ML_Context.use_mltext_update int pos txt)); |
391 Context.theory_map (ML_Context.exec (fn () => ML_Context.eval int pos txt))); |
387 |
392 |
388 (*ignore result theory context*) |
393 (*ignore result theory context*) |
389 fun use_mltext verbose (txt, pos) = Toplevel.keep' (fn int => fn state => |
394 fun use_mltext verbose (txt, pos) = Toplevel.keep' (fn int => fn state => |
390 (ML_Context.use_mltext (verbose andalso int) pos txt (try Toplevel.generic_theory_of state))); |
395 (ML_Context.eval_in (try Toplevel.generic_theory_of state) (verbose andalso int) pos txt)); |
391 |
396 |
392 val use_commit = Toplevel.imperative Secure.commit; |
397 val use_commit = Toplevel.imperative Secure.commit; |
393 |
398 |
394 |
399 |
395 (* nested commands *) |
400 (* nested commands *) |