doc-src/IsarImplementation/Thy/setup.ML
changeset 21325 df6392bda693
parent 20450 725a91601ed1
equal deleted inserted replaced
21324:a5089fc012b5 21325:df6392bda693
     1 
     1 
     2 local structure O = IsarOutput
     2 local structure O = IsarOutput
     3 
     3 
     4 val str_of_source = space_implode " " o map Args.string_of o #2 o #1 o Args.dest_src;
     4 val str_of_source = space_implode " " o map Args.string_of o #2 o #1 o Args.dest_src;
     5 
     5 
     6 fun ml_val txt = "fn _ => (" ^ txt ^ ");";
     6 fun ml_val (txt1, "") = "fn _ => (" ^ txt1 ^ ");"
     7 fun ml_type txt = "val _ = NONE : (" ^ txt ^ ") option;";
     7   | ml_val (txt1, txt2) = "fn _ => (" ^ txt1 ^ ": " ^ txt2 ^ ");";
     8 fun ml_structure txt = "functor DUMMY_FUNCTOR() = struct structure DUMMY = " ^ txt ^ " end;"
     8 
     9 fun ml_functor txt = "val _ = ();";  (*no check!*)
     9 fun ml_type (txt1, "") = "val _ = NONE : (" ^ txt1 ^ ") option;"
       
    10   | ml_type (txt1, txt2) = "val _ = [NONE : (" ^ txt1 ^ ") option, NONE : (" ^ txt2 ^ ") option];";
       
    11   
       
    12 fun ml_structure (txt, _) = "functor DUMMY_FUNCTOR() = struct structure DUMMY = " ^ txt ^ " end;"
       
    13 
       
    14 fun ml_functor _ = "val _ = ();";  (*no check!*)
    10 
    15 
    11 val verbatim = space_implode "\\verb,|," o map (enclose "\\verb|" "|") o space_explode "|";
    16 val verbatim = space_implode "\\verb,|," o map (enclose "\\verb|" "|") o space_explode "|";
    12 
    17 
    13 fun index_ml kind ml src ctxt (txt1, txt2) =
    18 fun index_ml kind ml src ctxt (txt1, txt2) =
    14   let
    19   let
    15     val txt = if txt2 = "" then txt1 else txt1 ^ ": " ^ txt2;
    20     val txt = if txt2 = "" then txt1 else
       
    21       if kind = "type"
       
    22         then txt1 ^ " = " ^ txt2
       
    23         else txt1 ^ ": " ^ txt2;
    16     val txt' = if kind = "" then txt else kind ^ " " ^ txt;
    24     val txt' = if kind = "" then txt else kind ^ " " ^ txt;
    17     val _ = Context.use_mltext (ml txt) false (SOME (ProofContext.theory_of ctxt));
    25     val _ = Context.use_mltext (ml (txt1, txt2)) false (SOME (ProofContext.theory_of ctxt));
    18   in
    26   in
    19     "\\indexml" ^ kind ^ enclose "{" "}"
    27     "\\indexml" ^ kind ^ enclose "{" "}"
    20       (translate_string (fn "_" => "-" | ">" => "$>$" | c => c) txt1) ^
    28       (translate_string (fn "_" => "-" | ">" => "$>$" | c => c) txt1) ^
    21     ((if ! O.source then str_of_source src else txt')
    29     ((if ! O.source then str_of_source src else txt')
    22     |> (if ! O.quotes then quote else I)
    30     |> (if ! O.quotes then quote else I)