src/Pure/Thy/document_antiquotation.ML
author wenzelm
Fri, 19 Jan 2018 19:09:25 +0100
changeset 67474 90def2b06305
parent 67472 7ed8d4cdfb13
child 67571 f858fe5531ac
permissions -rw-r--r--
more uniform output of source / text / theory_text, with handling of formal comments etc.;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Thy/document_antiquotation.ML
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     3
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     4
Document antiquotations.
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     5
*)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     6
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     7
signature DOCUMENT_ANTIQUOTATION =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     8
sig
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
     9
  val thy_output_display: bool Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    10
  val thy_output_quotes: bool Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    11
  val thy_output_margin: int Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    12
  val thy_output_indent: int Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    13
  val thy_output_source: bool Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    14
  val thy_output_break: bool Config.T
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    15
  val thy_output_modes: string Config.T
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    16
  val trim_blanks: Proof.context -> string -> string
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    17
  val trim_lines: Proof.context -> string -> string
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    18
  val indent_lines: Proof.context -> string -> string
67474
90def2b06305 more uniform output of source / text / theory_text, with handling of formal comments etc.;
wenzelm
parents: 67472
diff changeset
    19
  val prepare_lines: Proof.context -> string -> string
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    20
  val quote: Proof.context -> Pretty.T -> Pretty.T
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    21
  val indent: Proof.context -> Pretty.T -> Pretty.T
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    22
  val format: Proof.context -> Pretty.T -> string
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    23
  val output: Proof.context -> Pretty.T -> Output.output
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    24
  val print_antiquotations: bool -> Proof.context -> unit
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    25
  val check: Proof.context -> xstring * Position.T -> string
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    26
  val check_option: Proof.context -> xstring * Position.T -> string
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    27
  val setup: binding -> 'a context_parser ->
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    28
    ({context: Proof.context, source: Token.src, argument: 'a} -> Latex.text) -> theory -> theory
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    29
  val setup_option: binding -> (string -> Proof.context -> Proof.context) -> theory -> theory
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    30
  val boolean: string -> bool
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    31
  val integer: string -> int
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    32
  val evaluate: Proof.context -> Antiquote.text_antiquote -> Latex.text list
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    33
end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    34
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    35
structure Document_Antiquotation: DOCUMENT_ANTIQUOTATION =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    36
struct
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    37
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    38
(* options *)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    39
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    40
val thy_output_display = Attrib.setup_option_bool ("thy_output_display", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    41
val thy_output_break = Attrib.setup_option_bool ("thy_output_break", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    42
val thy_output_quotes = Attrib.setup_option_bool ("thy_output_quotes", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    43
val thy_output_margin = Attrib.setup_option_int ("thy_output_margin", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    44
val thy_output_indent = Attrib.setup_option_int ("thy_output_indent", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    45
val thy_output_source = Attrib.setup_option_bool ("thy_output_source", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    46
val thy_output_modes = Attrib.setup_option_string ("thy_output_modes", \<^here>);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    47
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    48
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    49
(* blanks *)
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    50
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    51
fun trim_blanks ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    52
  not (Config.get ctxt thy_output_display) ? Symbol.trim_blanks;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    53
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    54
fun trim_lines ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    55
  if not (Config.get ctxt thy_output_display) then
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    56
    split_lines #> map Symbol.trim_blanks #> space_implode " "
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    57
  else I;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    58
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    59
fun indent_lines ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    60
  if Config.get ctxt thy_output_display then
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    61
    prefix_lines (Symbol.spaces (Config.get ctxt thy_output_indent))
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    62
  else I;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    63
67474
90def2b06305 more uniform output of source / text / theory_text, with handling of formal comments etc.;
wenzelm
parents: 67472
diff changeset
    64
fun prepare_lines ctxt = trim_lines ctxt #> indent_lines ctxt;
90def2b06305 more uniform output of source / text / theory_text, with handling of formal comments etc.;
wenzelm
parents: 67472
diff changeset
    65
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    66
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    67
(* output *)
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    68
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    69
fun quote ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    70
  Config.get ctxt thy_output_quotes ? Pretty.quote;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    71
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    72
fun indent ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    73
  Config.get ctxt thy_output_display ? Pretty.indent (Config.get ctxt thy_output_indent);
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    74
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    75
fun format ctxt =
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    76
  if Config.get ctxt thy_output_display orelse Config.get ctxt thy_output_break
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    77
  then Pretty.string_of_margin (Config.get ctxt thy_output_margin)
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    78
  else Pretty.unformatted_string_of;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    79
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    80
fun output ctxt = quote ctxt #> indent ctxt #> format ctxt #> Output.output;
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    81
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    82
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    83
(* theory data *)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    84
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    85
structure Data = Theory_Data
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    86
(
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    87
  type T =
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
    88
    (Token.src -> Proof.context -> Latex.text) Name_Space.table *
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    89
      (string -> Proof.context -> Proof.context) Name_Space.table;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    90
  val empty : T =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    91
    (Name_Space.empty_table Markup.document_antiquotationN,
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    92
      Name_Space.empty_table Markup.document_antiquotation_optionN);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    93
  val extend = I;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    94
  fun merge ((commands1, options1), (commands2, options2)) : T =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    95
    (Name_Space.merge_tables (commands1, commands2),
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    96
      Name_Space.merge_tables (options1, options2));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    97
);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    98
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
    99
val get_antiquotations = Data.get o Proof_Context.theory_of;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   100
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   101
fun print_antiquotations verbose ctxt =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   102
  let
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   103
    val (commands, options) = get_antiquotations ctxt;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   104
    val command_names = map #1 (Name_Space.markup_table verbose ctxt commands);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   105
    val option_names = map #1 (Name_Space.markup_table verbose ctxt options);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   106
  in
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   107
    [Pretty.big_list "document antiquotations:" (map Pretty.mark_str command_names),
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   108
     Pretty.big_list "document antiquotation options:" (map Pretty.mark_str option_names)]
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   109
  end |> Pretty.writeln_chunks;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   110
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   111
fun check ctxt = #1 o Name_Space.check (Context.Proof ctxt) (#1 (get_antiquotations ctxt));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   112
fun check_option ctxt = #1 o Name_Space.check (Context.Proof ctxt) (#2 (get_antiquotations ctxt));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   113
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   114
fun setup name scan body thy =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   115
  let
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   116
    fun cmd src ctxt =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   117
      let val (x, ctxt') = Token.syntax scan src ctxt
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
   118
      in body {context = ctxt', source = src, argument = x} end;
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   119
  in thy |> Data.map (apfst (Name_Space.define (Context.Theory thy) true (name, cmd) #> #2)) end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   120
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   121
fun setup_option name opt thy = thy
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   122
  |> Data.map (apsnd (Name_Space.define (Context.Theory thy) true (name, opt) #> #2));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   123
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   124
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   125
(* syntax *)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   126
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   127
local
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   128
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   129
val property =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   130
  Parse.position Parse.name -- Scan.optional (Parse.$$$ "=" |-- Parse.!!! Parse.name) "";
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   131
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   132
val properties =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   133
  Scan.optional (Parse.$$$ "[" |-- Parse.!!! (Parse.enum "," property --| Parse.$$$ "]")) [];
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   134
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   135
in
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   136
67466
wenzelm
parents: 67463
diff changeset
   137
val parse_antiq =
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   138
  Parse.!!!
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   139
    (Parse.token Parse.liberal_name -- properties -- Parse.args --| Scan.ahead Parse.eof)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   140
  >> (fn ((name, props), args) => (props, name :: args));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   141
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   142
end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   143
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   144
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   145
(* evaluate *)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   146
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   147
local
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   148
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   149
fun command src ctxt =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   150
  let val (src', f) = Token.check_src ctxt (#1 o get_antiquotations) src
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   151
  in f src' ctxt end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   152
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   153
fun option ((xname, pos), s) ctxt =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   154
  let
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   155
    val (_, opt) =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   156
      Name_Space.check (Context.Proof ctxt) (#2 (get_antiquotations ctxt)) (xname, pos);
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   157
  in opt s ctxt end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   158
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   159
fun eval ctxt (opts, src) =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   160
  let
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   161
    val preview_ctxt = fold option opts ctxt;
67472
7ed8d4cdfb13 recovered antiquotation check without latex mode (cf. dfc93f2b01ea);
wenzelm
parents: 67466
diff changeset
   162
    val _ = command src preview_ctxt;
7ed8d4cdfb13 recovered antiquotation check without latex mode (cf. dfc93f2b01ea);
wenzelm
parents: 67466
diff changeset
   163
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   164
    val print_ctxt = Context_Position.set_visible false preview_ctxt;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   165
    val print_modes = space_explode "," (Config.get print_ctxt thy_output_modes) @ [Latex.latexN];
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
   166
  in [Print_Mode.with_modes print_modes (fn () => command src print_ctxt) ()] end;
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   167
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   168
in
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   169
67466
wenzelm
parents: 67463
diff changeset
   170
fun evaluate ctxt antiq =
wenzelm
parents: 67463
diff changeset
   171
  (case antiq of
wenzelm
parents: 67463
diff changeset
   172
    Antiquote.Text ss => [Latex.symbols ss]
wenzelm
parents: 67463
diff changeset
   173
  | Antiquote.Control {name, body, ...} =>
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   174
      eval ctxt ([], Token.make_src name (if null body then [] else [Token.read_cartouche body]))
67466
wenzelm
parents: 67463
diff changeset
   175
  | Antiquote.Antiq {range = (pos, _), body, ...} =>
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   176
      let val keywords = Thy_Header.get_keywords' ctxt;
67466
wenzelm
parents: 67463
diff changeset
   177
      in eval ctxt (Token.read_antiq keywords parse_antiq (body, pos)) end);
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   178
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   179
end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   180
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   181
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   182
(* option syntax *)
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   183
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   184
fun boolean "" = true
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   185
  | boolean "true" = true
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   186
  | boolean "false" = false
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
   187
  | boolean s = error ("Bad boolean value: " ^ Library.quote s);
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   188
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   189
fun integer s =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   190
  let
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   191
    fun int ss =
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   192
      (case Library.read_int ss of (i, []) => i
67463
a5ca98950a91 clarified access to antiquotation options;
wenzelm
parents: 67460
diff changeset
   193
      | _ => error ("Bad integer value: " ^ Library.quote s));
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   194
  in (case Symbol.explode s of "-" :: ss => ~ (int ss) | ss => int ss) end;
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   195
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   196
val _ = Theory.setup
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   197
 (setup_option \<^binding>\<open>show_types\<close> (Config.put show_types o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   198
  setup_option \<^binding>\<open>show_sorts\<close> (Config.put show_sorts o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   199
  setup_option \<^binding>\<open>show_structs\<close> (Config.put show_structs o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   200
  setup_option \<^binding>\<open>show_question_marks\<close> (Config.put show_question_marks o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   201
  setup_option \<^binding>\<open>show_abbrevs\<close> (Config.put show_abbrevs o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   202
  setup_option \<^binding>\<open>names_long\<close> (Config.put Name_Space.names_long o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   203
  setup_option \<^binding>\<open>names_short\<close> (Config.put Name_Space.names_short o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   204
  setup_option \<^binding>\<open>names_unique\<close> (Config.put Name_Space.names_unique o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   205
  setup_option \<^binding>\<open>eta_contract\<close> (Config.put Syntax_Trans.eta_contract o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   206
  setup_option \<^binding>\<open>display\<close> (Config.put thy_output_display o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   207
  setup_option \<^binding>\<open>break\<close> (Config.put thy_output_break o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   208
  setup_option \<^binding>\<open>quotes\<close> (Config.put thy_output_quotes o boolean) #>
67460
dfc93f2b01ea discontinued unused wrapper: print_mode is provided directly;
wenzelm
parents: 67386
diff changeset
   209
  setup_option \<^binding>\<open>mode\<close> (Config.put thy_output_modes) #>
67386
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   210
  setup_option \<^binding>\<open>margin\<close> (Config.put thy_output_margin o integer) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   211
  setup_option \<^binding>\<open>indent\<close> (Config.put thy_output_indent o integer) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   212
  setup_option \<^binding>\<open>source\<close> (Config.put thy_output_source o boolean) #>
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   213
  setup_option \<^binding>\<open>goals_limit\<close> (Config.put Goal_Display.goals_limit o integer));
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   214
998e01d6f8fd clarified modules;
wenzelm
parents:
diff changeset
   215
end;