src/Pure/General/symbol.ML
author wenzelm
Thu, 11 Feb 1999 21:16:30 +0100
changeset 6272 52d99d68d3be
parent 6225 f453bd781dfd
child 6320 4df282137880
permissions -rw-r--r--
added output_width; output subject to print_mode;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6118
caa439435666 fixed titles;
wenzelm
parents: 6116
diff changeset
     1
(*  Title:      Pure/General/symbol.ML
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     4
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     5
Generalized characters.
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     6
*)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     7
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     8
signature SYMBOL =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
     9
sig
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    10
  type symbol
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    11
  val space: symbol
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    12
  val eof: symbol
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    13
  val is_eof: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    14
  val not_eof: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    15
  val stopper: symbol * (symbol -> bool)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    16
  val is_ascii: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    17
  val is_letter: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    18
  val is_digit: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    19
  val is_quasi_letter: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    20
  val is_letdig: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    21
  val is_blank: symbol -> bool
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    22
  val is_printable: symbol -> bool
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    23
  val length: symbol list -> int
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    24
  val beginning: symbol list -> string
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    25
  val scan: string list -> symbol * string list
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    26
  val source: bool -> (string, 'a) Source.source ->
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    27
    (symbol, (string, 'a) Source.source) Source.source
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    28
  val explode: string -> symbol list
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    29
  val input: string -> string
6225
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
    30
  val use: Path.T -> unit
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    31
  val add_mode: string -> (string -> string * real) -> unit
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    32
  val output: string -> string
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    33
  val output_width: string -> string * real
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    34
end;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    35
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    36
structure Symbol: SYMBOL =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    37
struct
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    38
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
    39
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    40
(** generalized characters **)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    41
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    42
(*symbols, which are considered the smallest entities of any Isabelle
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    43
  string, may be of the following form:
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    44
    (a) ASCII symbols: a
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    45
    (b) printable symbols: \<ident>
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    46
    (c) control symbols: \<^ident>
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    47
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    48
  input may include non-ASCII characters according to isabelle-0 encoding;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    49
  output is subject to the print_mode variable (default: verbatim);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    50
*)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    51
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    52
type symbol = string;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    53
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    54
val space = " ";
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    55
val eof = "";
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    56
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    57
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    58
(* kinds *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    59
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    60
fun is_eof s = s = eof;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    61
fun not_eof s = s <> eof;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    62
val stopper = (eof, is_eof);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    63
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    64
fun is_ascii s = size s = 1 andalso ord s < 128;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    65
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    66
fun is_letter s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    67
  size s = 1 andalso
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    68
   (ord "A" <= ord s andalso ord s <= ord "Z" orelse
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    69
    ord "a" <= ord s andalso ord s <= ord "z");
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    70
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    71
fun is_digit s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    72
  size s = 1 andalso ord "0" <= ord s andalso ord s <= ord "9";
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    73
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    74
fun is_quasi_letter "_" = true
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    75
  | is_quasi_letter "'" = true
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    76
  | is_quasi_letter s = is_letter s;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    77
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    78
val is_blank =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    79
  fn " " => true | "\t" => true | "\n" => true | "\^L" => true
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    80
    | "\160" => true | "\\<spacespace>" => true
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    81
    | _ => false;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    82
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    83
val is_letdig = is_quasi_letter orf is_digit;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    84
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    85
fun is_printable s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    86
  size s = 1 andalso ord space <= ord s andalso ord s <= ord "~" orelse
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    87
  size s > 2 andalso nth_elem (2, explode s) <> "^";
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    88
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    89
fun sym_length ss = foldl (fn (n, s) => if is_printable s then n + 1 else n) (0, ss);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    90
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    91
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    92
(* beginning *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    93
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    94
val smash_blanks = map (fn s => if is_blank s then space else s);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    95
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    96
fun beginning raw_ss =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    97
  let
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    98
    val (all_ss, _) = take_suffix is_blank raw_ss;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
    99
    val dots = if length all_ss > 10 then " ..." else "";
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   100
    val (ss, _) = take_suffix is_blank (take (10, all_ss));
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   101
  in implode (smash_blanks ss) ^ dots end;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   102
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   103
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   104
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   105
(** isabelle-0 encoding table **)
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   106
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   107
val enc_start = 160;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   108
val enc_end = 255;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   109
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   110
val enc_vector =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   111
[
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   112
(* GENERATED TEXT FOLLOWS - Do not edit! *)
6166
a56aaad7ff2d renamed space2 to spacespace
oheimb
parents: 6118
diff changeset
   113
  "\\<spacespace>",
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   114
  "\\<Gamma>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   115
  "\\<Delta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   116
  "\\<Theta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   117
  "\\<Lambda>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   118
  "\\<Pi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   119
  "\\<Sigma>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   120
  "\\<Phi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   121
  "\\<Psi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   122
  "\\<Omega>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   123
  "\\<alpha>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   124
  "\\<beta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   125
  "\\<gamma>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   126
  "\\<delta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   127
  "\\<epsilon>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   128
  "\\<zeta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   129
  "\\<eta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   130
  "\\<theta>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   131
  "\\<kappa>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   132
  "\\<lambda>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   133
  "\\<mu>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   134
  "\\<nu>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   135
  "\\<xi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   136
  "\\<pi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   137
  "\\<rho>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   138
  "\\<sigma>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   139
  "\\<tau>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   140
  "\\<phi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   141
  "\\<chi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   142
  "\\<psi>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   143
  "\\<omega>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   144
  "\\<not>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   145
  "\\<and>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   146
  "\\<or>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   147
  "\\<forall>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   148
  "\\<exists>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   149
  "\\<And>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   150
  "\\<lceil>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   151
  "\\<rceil>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   152
  "\\<lfloor>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   153
  "\\<rfloor>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   154
  "\\<turnstile>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   155
  "\\<Turnstile>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   156
  "\\<lbrakk>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   157
  "\\<rbrakk>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   158
  "\\<cdot>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   159
  "\\<in>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   160
  "\\<subseteq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   161
  "\\<inter>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   162
  "\\<union>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   163
  "\\<Inter>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   164
  "\\<Union>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   165
  "\\<sqinter>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   166
  "\\<squnion>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   167
  "\\<Sqinter>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   168
  "\\<Squnion>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   169
  "\\<bottom>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   170
  "\\<doteq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   171
  "\\<equiv>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   172
  "\\<noteq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   173
  "\\<sqsubset>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   174
  "\\<sqsubseteq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   175
  "\\<prec>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   176
  "\\<preceq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   177
  "\\<succ>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   178
  "\\<approx>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   179
  "\\<sim>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   180
  "\\<simeq>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   181
  "\\<le>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   182
  "\\<Colon>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   183
  "\\<leftarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   184
  "\\<midarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   185
  "\\<rightarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   186
  "\\<Leftarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   187
  "\\<Midarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   188
  "\\<Rightarrow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   189
  "\\<bow>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   190
  "\\<mapsto>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   191
  "\\<leadsto>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   192
  "\\<up>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   193
  "\\<down>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   194
  "\\<notin>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   195
  "\\<times>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   196
  "\\<oplus>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   197
  "\\<ominus>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   198
  "\\<otimes>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   199
  "\\<oslash>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   200
  "\\<subset>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   201
  "\\<infinity>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   202
  "\\<box>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   203
  "\\<diamond>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   204
  "\\<circ>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   205
  "\\<bullet>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   206
  "\\<parallel>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   207
  "\\<surd>",
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   208
  "\\<copyright>"
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   209
(* END OF GENERATED TEXT *)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   210
];
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   211
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   212
val enc_rel = enc_vector ~~ map chr (enc_start upto enc_end);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   213
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   214
val char_tab = Symtab.make enc_rel;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   215
val symbol_tab = Symtab.make (map swap enc_rel);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   216
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   217
fun lookup_symbol c =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   218
  if ord c < enc_start then None
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   219
  else Symtab.lookup (symbol_tab, c);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   220
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   221
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   222
(* encode / decode *)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   223
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   224
fun char s = if_none (Symtab.lookup (char_tab, s)) s;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   225
fun symbol c = if_none (lookup_symbol c) c;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   226
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   227
fun symbol' c =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   228
  (case lookup_symbol c of
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   229
    None => c
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   230
  | Some s => "\\" ^ s);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   231
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   232
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   233
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   234
(** symbol input **)
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   235
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   236
(* scan *)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   237
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   238
val scan_id = Scan.one is_letter ^^ (Scan.any is_letdig >> implode);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   239
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   240
val scan =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   241
  ($$ "\\" --| Scan.optional ($$ "\\") "") ^^ $$ "<" ^^
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   242
    !! (fn (cs, _) => "Malformed symbolic character specification: \\" ^ "<" ^ beginning cs)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   243
      (Scan.optional ($$ "^") "" ^^ scan_id ^^ $$ ">") ||
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   244
  Scan.one not_eof;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   245
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   246
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   247
(* source *)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   248
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   249
val recover = Scan.any1 ((not o is_blank) andf not_eof);
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   250
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   251
fun source do_recover src =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   252
  Source.source stopper (Scan.bulk scan) (if do_recover then Some recover else None) src;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   253
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   254
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   255
(* explode *)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   256
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   257
fun no_syms [] = true
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   258
  | no_syms ("\\" :: "<" :: _) = false
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   259
  | no_syms (c :: cs) = ord c < enc_start andalso no_syms cs;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   260
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   261
fun sym_explode str =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   262
  let val chs = explode str in
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   263
    if no_syms chs then chs     (*tune trivial case*)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   264
    else map symbol (the (Scan.read stopper (Scan.repeat scan) chs))
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   265
  end;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   266
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   267
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   268
(* input *)
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   269
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   270
fun input str =
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   271
  let val chs = explode str in
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   272
    if forall (fn c => ord c < enc_start) chs then str
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   273
    else implode (map symbol' chs)
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   274
  end;
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   275
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   276
6225
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   277
(* version of 'use' with input filtering *)
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   278
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   279
val use =
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   280
  if not needs_filtered_use then File.use	(*ML system (wrongly!) accepts non-ASCII*)
6225
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   281
  else
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   282
    fn path =>
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   283
      let
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   284
        val txt = File.read path;
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   285
        val txt_out = input txt;
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   286
      in
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   287
        if txt = txt_out then File.use path
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   288
        else
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   289
          let val tmp_path = File.tmp_path path in
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   290
            File.write tmp_path txt_out;
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   291
            File.use tmp_path handle exn => (File.rm tmp_path; raise exn);
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   292
            File.rm tmp_path
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   293
          end
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   294
      end;
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   295
f453bd781dfd added 'use';
wenzelm
parents: 6166
diff changeset
   296
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   297
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   298
(** symbol output **)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   299
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   300
(* default_output *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   301
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   302
fun string_size s = (s, real (size s));
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   303
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   304
fun default_output s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   305
  let val cs = explode s in	(*sic!*)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   306
    if not (exists (equal "\\") cs) then string_size s
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   307
    else string_size (implode (map (fn "\\" => "\\\\" | c => c) cs))
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   308
  end;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   309
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   310
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   311
(* isabelle_font_output *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   312
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   313
fun isabelle_font_output s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   314
  let val cs = sym_explode s
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   315
  in (implode (map char cs), real (sym_length cs)) end;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   316
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   317
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   318
(* maintain modes *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   319
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   320
val modes = ref (Symtab.make [("isabelle_font", isabelle_font_output)]);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   321
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   322
fun lookup_mode name = Symtab.lookup (! modes, name);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   323
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   324
fun add_mode name f =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   325
 (if is_none (lookup_mode name) then ()
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   326
  else warning ("Duplicate declaration of symbol print mode " ^ quote name);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   327
  modes := Symtab.update ((name, f), ! modes));
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   328
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   329
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   330
(* mode output *)
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   331
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   332
fun output_width s =
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   333
  (case get_first lookup_mode (! print_mode) of
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   334
    None => default_output s
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   335
  | Some f => f s);
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   336
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   337
val output = #1 o output_width;
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   338
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   339
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   340
(*final declarations of this structure!*)
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   341
val length = sym_length;
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   342
val explode = sym_explode;
6272
52d99d68d3be added output_width;
wenzelm
parents: 6225
diff changeset
   343
6116
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   344
8ba2f25610f7 files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff changeset
   345
end;