src/Pure/Syntax/symbol_font.ML
author paulson
Thu Sep 25 12:09:41 1997 +0200 (1997-09-25)
changeset 3706 e57b5902822f
parent 3069 de1f64558c01
child 4144 873489c611fc
permissions -rw-r--r--
Generalized and exported biresolution_from_nets_tac to allow the declaration
of Clarify_tac
wenzelm@2207
     1
(*  Title:      Pure/Syntax/symbol_font.ML
wenzelm@2207
     2
    ID:         $Id$
wenzelm@2207
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@2207
     4
wenzelm@2943
     5
The Isabelle symbol font.
wenzelm@2207
     6
*)
wenzelm@2207
     7
wenzelm@2207
     8
signature SYMBOL_FONT =
wenzelm@2207
     9
sig
wenzelm@2208
    10
  val char: string -> string option
wenzelm@2362
    11
  val name: string -> string option
wenzelm@2362
    12
  val read_charnames: string list -> string list
wenzelm@2913
    13
  val read_chnames: string -> string
wenzelm@2913
    14
  val write_charnames: string list -> string list	(*normal backslashes*)
wenzelm@2913
    15
  val write_chnames: string -> string
wenzelm@2913
    16
  val write_charnames': string list -> string list	(*escaped backslashes*)
wenzelm@2913
    17
  val write_chnames': string -> string
wenzelm@2207
    18
end;
wenzelm@2207
    19
wenzelm@2362
    20
wenzelm@2207
    21
structure SymbolFont : SYMBOL_FONT =
wenzelm@2207
    22
struct
wenzelm@2207
    23
wenzelm@2362
    24
wenzelm@2362
    25
(** font encoding vector **)
wenzelm@2362
    26
wenzelm@2362
    27
(* tables *)
wenzelm@2207
    28
wenzelm@3069
    29
val enc_start = 160;
wenzelm@2207
    30
val enc_end = 255;
wenzelm@2207
    31
wenzelm@2207
    32
val enc_vector =
wenzelm@2207
    33
[
wenzelm@2942
    34
(* GENERATED TEXT FOLLOWS - Do not edit! *)
wenzelm@3064
    35
  "space2",
wenzelm@2943
    36
  "Gamma",
wenzelm@2943
    37
  "Delta",
wenzelm@2943
    38
  "Theta",
wenzelm@2943
    39
  "Lambda",
wenzelm@2943
    40
  "Pi",
wenzelm@2943
    41
  "Sigma",
wenzelm@2943
    42
  "Phi",
wenzelm@2943
    43
  "Psi",
wenzelm@2943
    44
  "Omega",
wenzelm@2943
    45
  "alpha",
wenzelm@2943
    46
  "beta",
wenzelm@2943
    47
  "gamma",
wenzelm@2943
    48
  "delta",
wenzelm@2943
    49
  "epsilon",
wenzelm@2943
    50
  "zeta",
wenzelm@2943
    51
  "eta",
wenzelm@2943
    52
  "theta",
wenzelm@2943
    53
  "kappa",
wenzelm@2943
    54
  "lambda",
wenzelm@2943
    55
  "mu",
wenzelm@2943
    56
  "nu",
wenzelm@2943
    57
  "xi",
wenzelm@2943
    58
  "pi",
wenzelm@2943
    59
  "rho",
wenzelm@2943
    60
  "sigma",
wenzelm@2943
    61
  "tau",
wenzelm@2943
    62
  "phi",
wenzelm@2943
    63
  "chi",
wenzelm@2943
    64
  "psi",
wenzelm@2943
    65
  "omega",
wenzelm@2943
    66
  "not",
wenzelm@2943
    67
  "and",
wenzelm@2943
    68
  "or",
wenzelm@2943
    69
  "forall",
wenzelm@2943
    70
  "exists",
wenzelm@2943
    71
  "And",
wenzelm@3064
    72
  "lceil",
wenzelm@3064
    73
  "rceil",
wenzelm@3064
    74
  "lfloor",
wenzelm@3064
    75
  "rfloor",
wenzelm@2943
    76
  "turnstile",
wenzelm@2943
    77
  "Turnstile",
wenzelm@2943
    78
  "lbrakk",
wenzelm@2943
    79
  "rbrakk",
wenzelm@2943
    80
  "cdot",
wenzelm@2943
    81
  "in",
wenzelm@2943
    82
  "subseteq",
wenzelm@2943
    83
  "inter",
wenzelm@2943
    84
  "union",
wenzelm@2943
    85
  "Inter",
wenzelm@2943
    86
  "Union",
wenzelm@2943
    87
  "sqinter",
wenzelm@2943
    88
  "squnion",
wenzelm@2943
    89
  "Sqinter",
wenzelm@2943
    90
  "Squnion",
wenzelm@2943
    91
  "bottom",
wenzelm@2943
    92
  "doteq",
wenzelm@2943
    93
  "equiv",
wenzelm@2943
    94
  "noteq",
wenzelm@2943
    95
  "sqsubset",
wenzelm@2943
    96
  "sqsubseteq",
wenzelm@2943
    97
  "prec",
wenzelm@2943
    98
  "preceq",
wenzelm@2943
    99
  "succ",
wenzelm@2943
   100
  "approx",
wenzelm@2943
   101
  "sim",
wenzelm@2943
   102
  "simeq",
wenzelm@2943
   103
  "le",
wenzelm@2943
   104
  "Colon",
wenzelm@2943
   105
  "leftarrow",
wenzelm@2943
   106
  "midarrow",
wenzelm@2943
   107
  "rightarrow",
wenzelm@2943
   108
  "Leftarrow",
wenzelm@2943
   109
  "Midarrow",
wenzelm@2943
   110
  "Rightarrow",
wenzelm@2943
   111
  "bow",
wenzelm@2943
   112
  "mapsto",
wenzelm@2943
   113
  "leadsto",
wenzelm@2943
   114
  "up",
wenzelm@2943
   115
  "down",
wenzelm@2943
   116
  "notin",
wenzelm@2943
   117
  "times",
wenzelm@2943
   118
  "oplus",
wenzelm@2943
   119
  "ominus",
wenzelm@2943
   120
  "otimes",
wenzelm@2943
   121
  "oslash",
wenzelm@2943
   122
  "subset",
wenzelm@2943
   123
  "infinity",
wenzelm@2943
   124
  "box",
wenzelm@2943
   125
  "diamond",
wenzelm@2943
   126
  "circ",
wenzelm@2943
   127
  "bullet",
wenzelm@2943
   128
  "parallel",
wenzelm@2943
   129
  "surd",
wenzelm@2943
   130
  "copyright"
wenzelm@2942
   131
(* END OF GENERATED TEXT *)
wenzelm@2207
   132
];
wenzelm@2207
   133
wenzelm@2362
   134
val enc_rel = enc_vector ~~ (map chr (enc_start upto enc_end));
wenzelm@2362
   135
wenzelm@2362
   136
val enc_tab = Symtab.make enc_rel;
wenzelm@2362
   137
val dec_tab = Symtab.make (map swap enc_rel);
wenzelm@2362
   138
wenzelm@2362
   139
wenzelm@2362
   140
(* chars and names *)
wenzelm@2362
   141
wenzelm@2362
   142
fun char name = Symtab.lookup (enc_tab, name);
wenzelm@2419
   143
wenzelm@2419
   144
fun name char =
wenzelm@2419
   145
  if ord char < enc_start then None
wenzelm@2419
   146
  else Symtab.lookup (dec_tab, char);
wenzelm@2362
   147
wenzelm@2207
   148
wenzelm@2207
   149
wenzelm@2362
   150
(** input and output of symbols **)
wenzelm@2362
   151
wenzelm@2362
   152
(* read_charnames *)
wenzelm@2362
   153
wenzelm@2362
   154
local
wenzelm@2362
   155
  open Scanner;
wenzelm@2207
   156
wenzelm@2362
   157
  fun scan_symbol ("\\" :: "<" :: cs) =
wenzelm@2362
   158
        let
wenzelm@2362
   159
          val (name, cs') = (scan_id -- $$ ">" >> #1) cs handle LEXICAL_ERROR
wenzelm@2362
   160
            => error ("Malformed symbolic char specification: \"\\<" ^ implode cs ^ "\"");
wenzelm@2362
   161
          val c = the (char name) handle OPTION _
wenzelm@2362
   162
            => error ("Unknown symbolic char name: " ^ quote name);
wenzelm@2362
   163
        in (c, cs') end
wenzelm@2362
   164
    | scan_symbol _ = raise LEXICAL_ERROR;
wenzelm@2362
   165
in
wenzelm@2419
   166
  fun read_charnames chs =
wenzelm@2419
   167
    if forall (not_equal "\\") chs then chs
wenzelm@2419
   168
    else #1 (repeat (scan_symbol || scan_one (K true)) chs);
wenzelm@2913
   169
wenzelm@2913
   170
  val read_chnames = implode o read_charnames o explode;
wenzelm@2362
   171
end;
wenzelm@2207
   172
wenzelm@2362
   173
wenzelm@2362
   174
(* write_charnames *)
wenzelm@2362
   175
wenzelm@2407
   176
fun write_char prfx ch =
wenzelm@2362
   177
  (case name ch of
wenzelm@2362
   178
    None => ch
wenzelm@2407
   179
  | Some nm => prfx ^ "\\<" ^ nm ^ ">");
wenzelm@2362
   180
wenzelm@2419
   181
fun write_chars prfx chs =
wenzelm@2419
   182
  if forall (fn ch => ord ch < enc_start) chs then chs
wenzelm@2419
   183
  else map (write_char prfx) chs;
wenzelm@2419
   184
wenzelm@2419
   185
val write_charnames = write_chars "";
wenzelm@2419
   186
val write_charnames' = write_chars "\\";
wenzelm@2362
   187
wenzelm@2913
   188
val write_chnames = implode o write_charnames o explode;
wenzelm@2913
   189
val write_chnames' = implode o write_charnames' o explode;
wenzelm@2207
   190
wenzelm@2207
   191
end;