equal
deleted
inserted
replaced
200 |
200 |
201 (* process file *) |
201 (* process file *) |
202 |
202 |
203 fun process_file path thy = |
203 fun process_file path thy = |
204 let |
204 let |
205 val result = ref thy; |
|
206 val trs = parse (Path.position path) (File.read path); |
205 val trs = parse (Path.position path) (File.read path); |
207 val init = Toplevel.init_theory "" (K thy) (fn thy' => result := thy'); |
206 val init = Toplevel.init_theory "" (K thy) (K ()) Toplevel.empty; |
208 val _ = Toplevel.excursion (init Toplevel.empty :: trs @ [Toplevel.exit Toplevel.empty]); |
207 val result = fold Toplevel.command (init :: trs) Toplevel.toplevel; |
209 in ! result end; |
208 in |
|
209 (case (Toplevel.is_theory result, Toplevel.generic_theory_of result) of |
|
210 (true, Context.Theory thy') => thy' |
|
211 | _ => error "Bad result state: global theory expected") |
|
212 end; |
210 |
213 |
211 |
214 |
212 (* interactive source of toplevel transformers *) |
215 (* interactive source of toplevel transformers *) |
213 |
216 |
214 type isar = |
217 type isar = |
266 val _ = Present.theory_source name |
269 val _ = Present.theory_source name |
267 (fn () => HTML.html_mode (implode o map ThyEdit.present_span) spans); |
270 (fn () => HTML.html_mode (implode o map ThyEdit.present_span) spans); |
268 |
271 |
269 val _ = if time then writeln ("\n**** Starting theory " ^ quote name ^ " ****") else (); |
272 val _ = if time then writeln ("\n**** Starting theory " ^ quote name ^ " ****") else (); |
270 val _ = cond_timeit time "" (fn () => |
273 val _ = cond_timeit time "" (fn () => |
271 ThyOutput.process_thy (#1 lexs) OuterKeyword.command_tags is_markup trs toks |
274 let |
272 |> Buffer.content |
275 val (states, commit_exit) = Toplevel.command_excursion trs; |
273 |> Present.theory_output name); |
276 val _ = |
|
277 ThyOutput.present_thy (#1 lexs) OuterKeyword.command_tags is_markup (trs ~~ states) toks |
|
278 |> Buffer.content |
|
279 |> Present.theory_output name |
|
280 val _ = commit_exit (); |
|
281 in () end); |
274 val _ = if time then writeln ("**** Finished theory " ^ quote name ^ " ****\n") else (); |
282 val _ = if time then writeln ("**** Finished theory " ^ quote name ^ " ****\n") else (); |
275 in () end; |
283 in () end; |
276 |
284 |
277 end; |
285 end; |