author | wenzelm |
Sat, 15 May 2010 23:16:32 +0200 | |
changeset 36950 | 75b8f26f2f07 |
parent 33223 | d27956b4d3b4 |
child 36953 | 2af1ad9aa1a3 |
permissions | -rw-r--r-- |
5829 | 1 |
(* Title: Pure/Isar/outer_syntax.ML |
2 |
Author: Markus Wenzel, TU Muenchen |
|
3 |
||
27353
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
26990
diff
changeset
|
4 |
The global Isabelle/Isar outer syntax. |
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
26990
diff
changeset
|
5 |
|
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
26990
diff
changeset
|
6 |
Note: the syntax for files is statically determined at the very |
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
26990
diff
changeset
|
7 |
beginning; for interactive processing it may change dynamically. |
5829 | 8 |
*) |
9 |
||
10 |
signature OUTER_SYNTAX = |
|
11 |
sig |
|
36950 | 12 |
val command: string -> string -> Keyword.T -> |
29311 | 13 |
(Toplevel.transition -> Toplevel.transition) parser -> unit |
36950 | 14 |
val markup_command: ThyOutput.markup -> string -> string -> Keyword.T -> |
29311 | 15 |
(Toplevel.transition -> Toplevel.transition) parser -> unit |
36950 | 16 |
val improper_command: string -> string -> Keyword.T -> |
29311 | 17 |
(Toplevel.transition -> Toplevel.transition) parser -> unit |
18 |
val internal_command: string -> (Toplevel.transition -> Toplevel.transition) parser -> unit |
|
36950 | 19 |
val local_theory': string -> string -> Keyword.T -> |
29380 | 20 |
(bool -> local_theory -> local_theory) parser -> unit |
36950 | 21 |
val local_theory: string -> string -> Keyword.T -> |
29311 | 22 |
(local_theory -> local_theory) parser -> unit |
36950 | 23 |
val local_theory_to_proof': string -> string -> Keyword.T -> |
29311 | 24 |
(bool -> local_theory -> Proof.state) parser -> unit |
36950 | 25 |
val local_theory_to_proof: string -> string -> Keyword.T -> |
29311 | 26 |
(local_theory -> Proof.state) parser -> unit |
5883 | 27 |
val print_outer_syntax: unit -> unit |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
28 |
val scan: Position.T -> string -> OuterLex.token list |
25580 | 29 |
val parse: Position.T -> string -> Toplevel.transition list |
26431 | 30 |
val process_file: Path.T -> theory -> theory |
26600 | 31 |
type isar |
32 |
val isar: bool -> isar |
|
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
33 |
val prepare_command: Position.T -> string -> Toplevel.transition |
29428
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
34 |
val load_thy: string -> Position.T -> string list -> bool -> unit -> unit |
5829 | 35 |
end; |
36 |
||
26600 | 37 |
structure OuterSyntax: OUTER_SYNTAX = |
5829 | 38 |
struct |
39 |
||
7750 | 40 |
structure T = OuterLex; |
36950 | 41 |
type 'a parser = 'a Parse.parser; |
29311 | 42 |
|
6860 | 43 |
|
5829 | 44 |
|
45 |
(** outer syntax **) |
|
46 |
||
29311 | 47 |
(* command parsers *) |
5829 | 48 |
|
29311 | 49 |
datatype command = Command of |
24868 | 50 |
{comment: string, |
51 |
markup: ThyOutput.markup option, |
|
52 |
int_only: bool, |
|
29311 | 53 |
parse: (Toplevel.transition -> Toplevel.transition) parser}; |
5829 | 54 |
|
29311 | 55 |
fun make_command comment markup int_only parse = |
56 |
Command {comment = comment, markup = markup, int_only = int_only, parse = parse}; |
|
5829 | 57 |
|
58 |
||
59 |
(* parse command *) |
|
60 |
||
6860 | 61 |
local |
6199 | 62 |
|
14925
0f86a8a694f8
added read (provides transition names and sources);
wenzelm
parents:
14687
diff
changeset
|
63 |
fun terminate false = Scan.succeed () |
36950 | 64 |
| terminate true = Parse.group "end of input" (Scan.option Parse.sync -- Parse.semicolon >> K ()); |
14925
0f86a8a694f8
added read (provides transition names and sources);
wenzelm
parents:
14687
diff
changeset
|
65 |
|
26620 | 66 |
fun body cmd (name, _) = |
7026 | 67 |
(case cmd name of |
29311 | 68 |
SOME (Command {int_only, parse, ...}) => |
36950 | 69 |
Parse.!!! (Scan.prompt (name ^ "# ") (Parse.tags |-- parse >> pair int_only)) |
15531 | 70 |
| NONE => sys_error ("no parser for outer syntax command " ^ quote name)); |
6860 | 71 |
|
72 |
in |
|
5829 | 73 |
|
26620 | 74 |
fun parse_command do_terminate cmd = |
36950 | 75 |
Parse.semicolon >> K NONE || |
76 |
Parse.sync >> K NONE || |
|
77 |
(Parse.position Parse.command :-- body cmd) --| terminate do_terminate |
|
6860 | 78 |
>> (fn ((name, pos), (int_only, f)) => |
15531 | 79 |
SOME (Toplevel.empty |> Toplevel.name name |> Toplevel.position pos |> |
6860 | 80 |
Toplevel.interactive int_only |> f)); |
5829 | 81 |
|
6199 | 82 |
end; |
83 |
||
5829 | 84 |
|
85 |
||
9132 | 86 |
(** global outer syntax **) |
5829 | 87 |
|
7026 | 88 |
local |
89 |
||
32738 | 90 |
val global_commands = Unsynchronized.ref (Symtab.empty: command Symtab.table); |
91 |
val global_markups = Unsynchronized.ref ([]: (string * ThyOutput.markup) list); |
|
5952 | 92 |
|
29311 | 93 |
fun change_commands f = CRITICAL (fn () => |
32738 | 94 |
(Unsynchronized.change global_commands f; |
23939 | 95 |
global_markups := |
29311 | 96 |
Symtab.fold (fn (name, Command {markup = SOME m, ...}) => cons (name, m) | _ => I) |
97 |
(! global_commands) [])); |
|
6722 | 98 |
|
7026 | 99 |
in |
100 |
||
9132 | 101 |
(* access current syntax *) |
7026 | 102 |
|
33223 | 103 |
fun get_commands () = ! global_commands; |
104 |
fun get_markups () = ! global_markups; |
|
7026 | 105 |
|
29311 | 106 |
fun get_command () = Symtab.lookup (get_commands ()); |
36950 | 107 |
fun get_syntax () = CRITICAL (fn () => (Keyword.get_lexicons (), get_command ())); |
7789 | 108 |
|
24868 | 109 |
fun is_markup kind name = AList.lookup (op =) (get_markups ()) name = SOME kind; |
5829 | 110 |
|
111 |
||
112 |
(* augment syntax *) |
|
113 |
||
29311 | 114 |
fun add_command name kind cmd = CRITICAL (fn () => |
36950 | 115 |
(Keyword.command name kind; |
29311 | 116 |
if not (Symtab.defined (get_commands ()) name) then () |
24868 | 117 |
else warning ("Redefining outer syntax command " ^ quote name); |
29311 | 118 |
change_commands (Symtab.update (name, cmd)))); |
5829 | 119 |
|
24868 | 120 |
fun command name comment kind parse = |
29311 | 121 |
add_command name kind (make_command comment NONE false parse); |
5829 | 122 |
|
24868 | 123 |
fun markup_command markup name comment kind parse = |
29311 | 124 |
add_command name kind (make_command comment (SOME markup) false parse); |
24868 | 125 |
|
126 |
fun improper_command name comment kind parse = |
|
29311 | 127 |
add_command name kind (make_command comment NONE true parse); |
7026 | 128 |
|
129 |
end; |
|
5829 | 130 |
|
29311 | 131 |
fun internal_command name parse = |
36950 | 132 |
command name "(internal)" Keyword.control (parse >> (fn tr => Toplevel.no_timing o tr)); |
29311 | 133 |
|
5829 | 134 |
|
26990 | 135 |
(* local_theory commands *) |
136 |
||
137 |
fun local_theory_command do_print trans name comment kind parse = |
|
36950 | 138 |
command name comment kind (Parse.opt_target -- parse |
26990 | 139 |
>> (fn (loc, f) => (if do_print then Toplevel.print else I) o trans loc f)); |
140 |
||
29380 | 141 |
val local_theory' = local_theory_command false Toplevel.local_theory'; |
29311 | 142 |
val local_theory = local_theory_command false Toplevel.local_theory; |
26990 | 143 |
val local_theory_to_proof' = local_theory_command true Toplevel.local_theory_to_proof'; |
29311 | 144 |
val local_theory_to_proof = local_theory_command true Toplevel.local_theory_to_proof; |
26990 | 145 |
|
146 |
||
24872 | 147 |
(* inspect syntax *) |
7026 | 148 |
|
29311 | 149 |
fun dest_commands () = |
150 |
get_commands () |> Symtab.dest |> sort_wrt #1 |
|
151 |
|> map (fn (name, Command {comment, int_only, ...}) => (name, comment, int_only)); |
|
5829 | 152 |
|
9223 | 153 |
fun print_outer_syntax () = |
7026 | 154 |
let |
27353
71c4dd53d4cb
moved global keywords from OuterSyntax to OuterKeyword, tuned interfaces;
wenzelm
parents:
26990
diff
changeset
|
155 |
fun pretty_cmd (name, comment, _) = |
7026 | 156 |
Pretty.block [Pretty.str (name ^ ":"), Pretty.brk 2, Pretty.str comment]; |
29311 | 157 |
val (int_cmds, cmds) = List.partition #3 (dest_commands ()); |
7026 | 158 |
in |
36950 | 159 |
[Pretty.strs ("syntax keywords:" :: map quote (Keyword.dest_keywords ())), |
18326 | 160 |
Pretty.big_list "commands:" (map pretty_cmd cmds), |
161 |
Pretty.big_list "interactive-only commands:" (map pretty_cmd int_cmds)] |
|
9223 | 162 |
|> Pretty.chunks |> Pretty.writeln |
7026 | 163 |
end; |
5829 | 164 |
|
165 |
||
166 |
||
9132 | 167 |
(** toplevel parsing **) |
5829 | 168 |
|
9132 | 169 |
(* basic sources *) |
6860 | 170 |
|
26620 | 171 |
fun toplevel_source term do_recover cmd src = |
9132 | 172 |
let |
173 |
val no_terminator = |
|
36950 | 174 |
Scan.unless Parse.semicolon (Scan.one (T.not_sync andf T.not_eof)); |
23682
cf4773532006
nested source: explicit interactive flag for recover avoids duplicate errors;
wenzelm
parents:
23679
diff
changeset
|
175 |
fun recover int = |
cf4773532006
nested source: explicit interactive flag for recover avoids duplicate errors;
wenzelm
parents:
23679
diff
changeset
|
176 |
(int, fn _ => Scan.prompt "recover# " (Scan.repeat no_terminator) >> K [NONE]); |
9132 | 177 |
in |
178 |
src |
|
12876
a70df1e5bf10
got rid of explicit marginal comments (now stripped earlier from input);
wenzelm
parents:
10749
diff
changeset
|
179 |
|> T.source_proper |
9132 | 180 |
|> Source.source T.stopper |
36950 | 181 |
(Scan.bulk (Parse.$$$ "--" -- Parse.!!! Parse.doc_source >> K NONE || Parse.not_eof >> SOME)) |
23682
cf4773532006
nested source: explicit interactive flag for recover avoids duplicate errors;
wenzelm
parents:
23679
diff
changeset
|
182 |
(Option.map recover do_recover) |
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19060
diff
changeset
|
183 |
|> Source.map_filter I |
24868 | 184 |
|> Source.source T.stopper |
36950 | 185 |
(Scan.bulk (fn xs => Parse.!!! (parse_command term (cmd ())) xs)) |
23682
cf4773532006
nested source: explicit interactive flag for recover avoids duplicate errors;
wenzelm
parents:
23679
diff
changeset
|
186 |
(Option.map recover do_recover) |
19482
9f11af8f7ef9
tuned basic list operators (flat, maps, map_filter);
wenzelm
parents:
19060
diff
changeset
|
187 |
|> Source.map_filter I |
9132 | 188 |
end; |
5829 | 189 |
|
7746 | 190 |
|
25580 | 191 |
(* off-line scanning/parsing *) |
14925
0f86a8a694f8
added read (provides transition names and sources);
wenzelm
parents:
14687
diff
changeset
|
192 |
|
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
193 |
fun scan pos str = |
16195 | 194 |
Source.of_string str |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
195 |
|> Symbol.source {do_recover = false} |
36950 | 196 |
|> T.source {do_recover = SOME false} Keyword.get_lexicons pos |
16195 | 197 |
|> Source.exhaust; |
198 |
||
25580 | 199 |
fun parse pos str = |
200 |
Source.of_string str |
|
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
201 |
|> Symbol.source {do_recover = false} |
36950 | 202 |
|> T.source {do_recover = SOME false} Keyword.get_lexicons pos |
29311 | 203 |
|> toplevel_source false NONE get_command |
25580 | 204 |
|> Source.exhaust; |
205 |
||
14091 | 206 |
|
26431 | 207 |
(* process file *) |
208 |
||
209 |
fun process_file path thy = |
|
210 |
let |
|
26881 | 211 |
val trs = parse (Path.position path) (File.read path); |
28424
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
212 |
val init = Toplevel.init_theory "" (K thy) (K ()) Toplevel.empty; |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
213 |
val result = fold Toplevel.command (init :: trs) Toplevel.toplevel; |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
214 |
in |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
215 |
(case (Toplevel.is_theory result, Toplevel.generic_theory_of result) of |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
216 |
(true, Context.Theory thy') => thy' |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
217 |
| _ => error "Bad result state: global theory expected") |
fc6ce1c4d5b7
simplified process_file, eliminated Toplevel.excursion;
wenzelm
parents:
27872
diff
changeset
|
218 |
end; |
26431 | 219 |
|
220 |
||
24868 | 221 |
(* interactive source of toplevel transformers *) |
222 |
||
26600 | 223 |
type isar = |
224 |
(Toplevel.transition, (Toplevel.transition option, |
|
225 |
(OuterLex.token, (OuterLex.token option, (OuterLex.token, (OuterLex.token, |
|
30573 | 226 |
(Symbol_Pos.T, Position.T * (Symbol.symbol, (string, unit) Source.source) |
27770 | 227 |
Source.source) Source.source) Source.source) Source.source) |
228 |
Source.source) Source.source) Source.source) Source.source; |
|
26600 | 229 |
|
230 |
fun isar term : isar = |
|
24868 | 231 |
Source.tty |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
232 |
|> Symbol.source {do_recover = true} |
36950 | 233 |
|> T.source {do_recover = SOME true} Keyword.get_lexicons Position.none |
29311 | 234 |
|> toplevel_source term (SOME true) get_command; |
24868 | 235 |
|
236 |
||
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
237 |
(* prepare toplevel commands -- fail-safe *) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
238 |
|
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
239 |
val not_singleton = "Exactly one command expected"; |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
240 |
|
29311 | 241 |
fun prepare_span commands span = |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
242 |
let |
29315
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
243 |
val range_pos = Position.encode_range (ThySyntax.span_range span); |
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
244 |
val toks = ThySyntax.span_content span; |
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
245 |
val _ = List.app ThySyntax.report_token toks; |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
246 |
in |
29311 | 247 |
(case Source.exhaust (toplevel_source false NONE (K commands) (Source.of_list toks)) of |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
248 |
[tr] => (tr, true) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
249 |
| [] => (Toplevel.ignored range_pos, false) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
250 |
| _ => (Toplevel.malformed range_pos not_singleton, true)) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
251 |
handle ERROR msg => (Toplevel.malformed range_pos msg, true) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
252 |
end; |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
253 |
|
29311 | 254 |
fun prepare_unit commands (cmd, proof, proper_proof) = |
28436
4faf705a177d
load_thy: more precise treatment of improper cmd or proof (notably 'oops');
wenzelm
parents:
28432
diff
changeset
|
255 |
let |
29311 | 256 |
val (tr, proper_cmd) = prepare_span commands cmd; |
257 |
val proof_trs = map (prepare_span commands) proof |> filter #2 |> map #1; |
|
28436
4faf705a177d
load_thy: more precise treatment of improper cmd or proof (notably 'oops');
wenzelm
parents:
28432
diff
changeset
|
258 |
in |
4faf705a177d
load_thy: more precise treatment of improper cmd or proof (notably 'oops');
wenzelm
parents:
28432
diff
changeset
|
259 |
if proper_cmd andalso proper_proof then [(tr, proof_trs)] |
4faf705a177d
load_thy: more precise treatment of improper cmd or proof (notably 'oops');
wenzelm
parents:
28432
diff
changeset
|
260 |
else map (rpair []) (if proper_cmd then tr :: proof_trs else proof_trs) |
4faf705a177d
load_thy: more precise treatment of improper cmd or proof (notably 'oops');
wenzelm
parents:
28432
diff
changeset
|
261 |
end; |
28432
944cb67f809a
load_thy: Toplevel.excursion based on units of command/proof pairs;
wenzelm
parents:
28424
diff
changeset
|
262 |
|
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
263 |
fun prepare_command pos str = |
29311 | 264 |
let val (lexs, commands) = get_syntax () in |
29315
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
265 |
(case ThySyntax.parse_spans lexs pos str of |
29311 | 266 |
[span] => #1 (prepare_span commands span) |
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
267 |
| _ => Toplevel.malformed pos not_singleton) |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
268 |
end; |
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
269 |
|
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
270 |
|
26611 | 271 |
(* load_thy *) |
7746 | 272 |
|
27839
0be8644c45eb
Symbol.source/OuterLex.source: more explicit do_recover argument;
wenzelm
parents:
27831
diff
changeset
|
273 |
fun load_thy name pos text time = |
7683 | 274 |
let |
29311 | 275 |
val (lexs, commands) = get_syntax (); |
23866
5295671034f8
moved deps_thy to ThyLoad (independent of outer syntax);
wenzelm
parents:
23796
diff
changeset
|
276 |
|
17932 | 277 |
val _ = Present.init_theory name; |
27855
b1bf607e06c2
load_thy: no untabify (preserve position information!), present spans instead of verbatim source;
wenzelm
parents:
27839
diff
changeset
|
278 |
|
29315
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
279 |
val toks = Source.exhausted (ThySyntax.token_source lexs pos (Source.of_list text)); |
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
280 |
val spans = Source.exhaust (ThySyntax.span_source toks); |
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
281 |
val _ = List.app ThySyntax.report_span spans; |
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
282 |
val units = Source.exhaust (ThySyntax.unit_source (Source.of_list spans)) |
29311 | 283 |
|> maps (prepare_unit commands); |
23866
5295671034f8
moved deps_thy to ThyLoad (independent of outer syntax);
wenzelm
parents:
23796
diff
changeset
|
284 |
|
27855
b1bf607e06c2
load_thy: no untabify (preserve position information!), present spans instead of verbatim source;
wenzelm
parents:
27839
diff
changeset
|
285 |
val _ = Present.theory_source name |
29315
b074c05f00ad
renamed ThyEdit (in thy_edit.ML) to ThySyntax (in thy_syntax.ML);
wenzelm
parents:
29311
diff
changeset
|
286 |
(fn () => HTML.html_mode (implode o map ThySyntax.present_span) spans); |
27855
b1bf607e06c2
load_thy: no untabify (preserve position information!), present spans instead of verbatim source;
wenzelm
parents:
27839
diff
changeset
|
287 |
|
23866
5295671034f8
moved deps_thy to ThyLoad (independent of outer syntax);
wenzelm
parents:
23796
diff
changeset
|
288 |
val _ = if time then writeln ("\n**** Starting theory " ^ quote name ^ " ****") else (); |
29428
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
289 |
val results = cond_timeit time "" (fn () => Toplevel.excursion units); |
23866
5295671034f8
moved deps_thy to ThyLoad (independent of outer syntax);
wenzelm
parents:
23796
diff
changeset
|
290 |
val _ = if time then writeln ("**** Finished theory " ^ quote name ^ " ****\n") else (); |
29428
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
291 |
|
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
292 |
fun after_load () = |
36950 | 293 |
ThyOutput.present_thy (#1 lexs) Keyword.command_tags is_markup (Lazy.force results) toks |
29428
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
294 |
|> Buffer.content |
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
295 |
|> Present.theory_output name; |
3ab54b42ded8
load_thy: explicit after_load phase for presentation;
wenzelm
parents:
29380
diff
changeset
|
296 |
in after_load end; |
23866
5295671034f8
moved deps_thy to ThyLoad (independent of outer syntax);
wenzelm
parents:
23796
diff
changeset
|
297 |
|
5829 | 298 |
end; |