src/Pure/Isar/outer_syntax.ML
changeset 27855 b1bf607e06c2
parent 27839 0be8644c45eb
child 27872 631371a02b8c
equal deleted inserted replaced
27854:be5372792b08 27855:b1bf607e06c2
   223   |> Symbol.source {do_recover = true}
   223   |> Symbol.source {do_recover = true}
   224   |> T.source {do_recover = SOME true} OuterKeyword.get_lexicons Position.none
   224   |> T.source {do_recover = SOME true} OuterKeyword.get_lexicons Position.none
   225   |> toplevel_source term (SOME true) get_parser;
   225   |> toplevel_source term (SOME true) get_parser;
   226 
   226 
   227 
   227 
   228 
       
   229 (* prepare toplevel commands -- fail-safe *)
   228 (* prepare toplevel commands -- fail-safe *)
   230 
   229 
   231 val not_singleton = "Exactly one command expected";
   230 val not_singleton = "Exactly one command expected";
   232 
   231 
   233 fun prepare_span parser span =
   232 fun prepare_span parser span =
   254 (* load_thy *)
   253 (* load_thy *)
   255 
   254 
   256 fun load_thy name pos text time =
   255 fun load_thy name pos text time =
   257   let
   256   let
   258     val (lexs, parser) = get_syntax ();
   257     val (lexs, parser) = get_syntax ();
   259     val text_src = Source.of_list (Library.untabify text);
       
   260 
   258 
   261     val _ = Present.init_theory name;
   259     val _ = Present.init_theory name;
   262     val _ = Present.verbatim_source name
   260 
   263       (fn () => Source.exhaust (Symbol.source {do_recover = false} text_src));
   261     val toks = Source.exhausted (ThyEdit.token_source lexs pos (Source.of_list text));
   264     val toks = Source.exhausted (ThyEdit.token_source lexs pos text_src);
       
   265     val spans = Source.exhaust (ThyEdit.span_source toks);
   262     val spans = Source.exhaust (ThyEdit.span_source toks);
   266     val _ = List.app ThyEdit.report_span spans;
   263     val _ = List.app ThyEdit.report_span spans;
   267     val trs = map (prepare_span parser) spans |> filter #2 |> map #1;
   264     val trs = map (prepare_span parser) spans |> filter #2 |> map #1;
       
   265 
       
   266     val _ = Present.theory_source name
       
   267       (fn () => HTML.html_mode (implode o map ThyEdit.present_span) spans);
   268 
   268 
   269     val _ = if time then writeln ("\n**** Starting theory " ^ quote name ^ " ****") else ();
   269     val _ = if time then writeln ("\n**** Starting theory " ^ quote name ^ " ****") else ();
   270     val _ = cond_timeit time "" (fn () =>
   270     val _ = cond_timeit time "" (fn () =>
   271       ThyOutput.process_thy (#1 lexs) OuterKeyword.command_tags is_markup trs toks
   271       ThyOutput.process_thy (#1 lexs) OuterKeyword.command_tags is_markup trs toks
   272       |> Buffer.content
   272       |> Buffer.content