19 val master_directory: string -> Path.T |
19 val master_directory: string -> Path.T |
20 val remove_thy: string -> unit |
20 val remove_thy: string -> unit |
21 type context = |
21 type context = |
22 {options: Options.T, |
22 {options: Options.T, |
23 symbols: HTML.symbols, |
23 symbols: HTML.symbols, |
24 bibtex_entries: string list, |
|
25 last_timing: Toplevel.transition -> Time.time} |
24 last_timing: Toplevel.transition -> Time.time} |
26 val use_theories: context -> string -> Path.T -> (string * Position.T) list -> unit |
25 val use_theories: context -> string -> Path.T -> (string * Position.T) list -> unit |
27 val use_thy: string -> unit |
26 val use_thy: string -> unit |
28 val script_thy: Position.T -> string -> theory -> theory |
27 val script_thy: Position.T -> string -> theory -> theory |
29 val register_thy: theory -> unit |
28 val register_thy: theory -> unit |
185 (* context *) |
184 (* context *) |
186 |
185 |
187 type context = |
186 type context = |
188 {options: Options.T, |
187 {options: Options.T, |
189 symbols: HTML.symbols, |
188 symbols: HTML.symbols, |
190 bibtex_entries: string list, |
|
191 last_timing: Toplevel.transition -> Time.time}; |
189 last_timing: Toplevel.transition -> Time.time}; |
192 |
190 |
193 fun default_context (): context = |
191 fun default_context (): context = |
194 {options = Options.default (), |
192 {options = Options.default (), |
195 symbols = HTML.no_symbols, |
193 symbols = HTML.no_symbols, |
196 bibtex_entries = [], |
|
197 last_timing = K Time.zeroTime}; |
194 last_timing = K Time.zeroTime}; |
198 |
195 |
199 |
196 |
200 (* scheduling loader tasks *) |
197 (* scheduling loader tasks *) |
201 |
198 |
301 val thy = Toplevel.end_theory end_pos end_state; |
298 val thy = Toplevel.end_theory end_pos end_state; |
302 in (results, thy) end; |
299 in (results, thy) end; |
303 |
300 |
304 fun eval_thy (context: context) update_time master_dir header text_pos text parents = |
301 fun eval_thy (context: context) update_time master_dir header text_pos text parents = |
305 let |
302 let |
306 val {options, symbols, bibtex_entries, last_timing} = context; |
303 val {options, symbols, last_timing} = context; |
307 val (name, _) = #name header; |
304 val (name, _) = #name header; |
308 val keywords = |
305 val keywords = |
309 fold (curry Keyword.merge_keywords o Thy_Header.get_keywords) parents |
306 fold (curry Keyword.merge_keywords o Thy_Header.get_keywords) parents |
310 (Keyword.add_keywords (#keywords header) Keyword.empty_keywords); |
307 (Keyword.add_keywords (#keywords header) Keyword.empty_keywords); |
311 |
308 |
312 val spans = Outer_Syntax.parse_spans (Token.explode keywords text_pos text); |
309 val spans = Outer_Syntax.parse_spans (Token.explode keywords text_pos text); |
313 val elements = Thy_Element.parse_elements keywords spans; |
310 val elements = Thy_Element.parse_elements keywords spans; |
314 |
311 |
315 fun init () = |
312 fun init () = |
316 Resources.begin_theory master_dir header parents |
313 Resources.begin_theory master_dir header parents |
317 |> Present.begin_theory bibtex_entries update_time |
314 |> Present.begin_theory update_time |
318 (fn () => implode (map (HTML.present_span symbols keywords) spans)); |
315 (fn () => implode (map (HTML.present_span symbols keywords) spans)); |
319 |
316 |
320 val (results, thy) = |
317 val (results, thy) = |
321 cond_timeit true ("theory " ^ quote name) |
318 cond_timeit true ("theory " ^ quote name) |
322 (fn () => excursion keywords master_dir last_timing init elements); |
319 (fn () => excursion keywords master_dir last_timing init elements); |