author | wenzelm |
Thu, 22 Nov 2018 17:34:30 +0100 | |
changeset 69327 | 264b44dce6be |
parent 67522 | 9e712280cc37 |
child 69452 | 704915cf59fa |
permissions | -rw-r--r-- |
6118 | 1 |
(* Title: Pure/General/symbol.ML |
63936 | 2 |
Author: Makarius |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
3 |
|
21897 | 4 |
Generalized characters with infinitely many named symbols. |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
5 |
*) |
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 |
signature SYMBOL = |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
8 |
sig |
40509 | 9 |
type symbol = string |
63936 | 10 |
val explode: string -> symbol list |
61865 | 11 |
val spaces: int -> string |
26524 | 12 |
val STX: symbol |
13 |
val DEL: symbol |
|
62210 | 14 |
val open_: symbol |
15 |
val close: symbol |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
16 |
val space: symbol |
62804 | 17 |
val is_space: symbol -> bool |
61579 | 18 |
val comment: symbol |
67413 | 19 |
val cancel: symbol |
67428 | 20 |
val latex: symbol |
14678 | 21 |
val is_char: symbol -> bool |
37533
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
34095
diff
changeset
|
22 |
val is_utf8: symbol -> bool |
14678 | 23 |
val is_symbolic: symbol -> bool |
55033 | 24 |
val is_symbolic_char: symbol -> bool |
14678 | 25 |
val is_printable: symbol -> bool |
61470 | 26 |
val is_control: symbol -> bool |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
27 |
val eof: symbol |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
28 |
val is_eof: symbol -> bool |
27766 | 29 |
val not_eof: symbol -> bool |
27732 | 30 |
val stopper: symbol Scan.stopper |
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
31 |
val is_malformed: symbol -> bool |
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
32 |
val malformed_msg: symbol -> string |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
33 |
val is_ascii: symbol -> bool |
14678 | 34 |
val is_ascii_letter: symbol -> bool |
35 |
val is_ascii_digit: symbol -> bool |
|
24580
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
wenzelm
parents:
23784
diff
changeset
|
36 |
val is_ascii_hex: symbol -> bool |
14678 | 37 |
val is_ascii_quasi: symbol -> bool |
38 |
val is_ascii_blank: symbol -> bool |
|
34095
c2f176a38448
robust representation of low ASCII control characters within XML/YXML text;
wenzelm
parents:
33955
diff
changeset
|
39 |
val is_ascii_control: symbol -> bool |
50236 | 40 |
val is_ascii_letdig: symbol -> bool |
20200 | 41 |
val is_ascii_lower: symbol -> bool |
42 |
val is_ascii_upper: symbol -> bool |
|
43 |
val to_ascii_lower: symbol -> symbol |
|
44 |
val to_ascii_upper: symbol -> symbol |
|
50238
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
wenzelm
parents:
50237
diff
changeset
|
45 |
val is_ascii_identifier: string -> bool |
50236 | 46 |
val scan_ascii_id: string list -> string * string list |
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
47 |
datatype sym = |
63936 | 48 |
Char of string | UTF8 of string | Sym of string | Control of string | Malformed of string | EOF |
14873 | 49 |
val decode: symbol -> sym |
67373 | 50 |
val encode: sym -> symbol |
14678 | 51 |
datatype kind = Letter | Digit | Quasi | Blank | Other |
52 |
val kind: symbol -> kind |
|
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
53 |
val is_letter: symbol -> bool |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
54 |
val is_digit: symbol -> bool |
12904 | 55 |
val is_quasi: symbol -> bool |
14678 | 56 |
val is_blank: symbol -> bool |
47850
c638127b4653
avoid interference of markup for literal tokens, which may contain slightly odd \<^bsub> \<^esub> counted as pseudo-markup (especially relevant for HTML output, e.g. of thm power3_eq_cube);
wenzelm
parents:
43947
diff
changeset
|
57 |
val is_block_ctrl: symbol -> bool |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
58 |
val is_quasi_letter: symbol -> bool |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
59 |
val is_letdig: symbol -> bool |
14728 | 60 |
val beginning: int -> symbol list -> string |
50237 | 61 |
val esc: symbol -> string |
62 |
val escape: string -> string |
|
63 |
val scanner: string -> (string list -> 'a * string list) -> symbol list -> 'a |
|
50162 | 64 |
val split_words: symbol list -> string list |
65 |
val explode_words: string -> string list |
|
61435 | 66 |
val trim_blanks: string -> string |
14678 | 67 |
val bump_init: string -> string |
12904 | 68 |
val bump_string: string -> string |
67512 | 69 |
val sub: symbol |
70 |
val sup: symbol |
|
71 |
val bold: symbol |
|
72 |
val make_sub: string -> string |
|
73 |
val make_sup: string -> string |
|
74 |
val make_bold: string -> string |
|
14678 | 75 |
val length: symbol list -> int |
40131
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
wenzelm
parents:
37728
diff
changeset
|
76 |
val output: string -> Output.output * int |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
77 |
end; |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
78 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
79 |
structure Symbol: SYMBOL = |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
80 |
struct |
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
81 |
|
14678 | 82 |
(** type symbol **) |
6272 | 83 |
|
14678 | 84 |
(*Symbols, which are considered the smallest entities of any Isabelle |
6272 | 85 |
string, may be of the following form: |
14678 | 86 |
|
63936 | 87 |
(1) ASCII: a |
88 |
(2) UTF-8: ä |
|
17823 | 89 |
(2) regular symbols: \<ident> |
14834 | 90 |
(3) control symbols: \<^ident> |
6272 | 91 |
|
14678 | 92 |
Output is subject to the print_mode variable (default: verbatim), |
93 |
actual interpretation in display is up to front-end tools. |
|
6272 | 94 |
*) |
95 |
||
96 |
type symbol = string; |
|
97 |
||
26524 | 98 |
val STX = chr 2; |
99 |
val DEL = chr 127; |
|
100 |
||
62529
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
101 |
val open_ = "\<open>"; |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
102 |
val close = "\<close>"; |
62210 | 103 |
|
26524 | 104 |
val space = chr 32; |
62804 | 105 |
fun is_space s = s = space; |
17063 | 106 |
|
61865 | 107 |
local |
108 |
val small_spaces = Vector.tabulate (65, fn i => replicate_string i space); |
|
109 |
in |
|
110 |
fun spaces n = |
|
111 |
if n < 64 then Vector.sub (small_spaces, n) |
|
112 |
else |
|
113 |
replicate_string (n div 64) (Vector.sub (small_spaces, 64)) ^ |
|
114 |
Vector.sub (small_spaces, n mod 64); |
|
115 |
end; |
|
116 |
||
62529
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
117 |
val comment = "\<comment>"; |
67413 | 118 |
val cancel = "\<^cancel>"; |
67428 | 119 |
val latex = "\<^latex>"; |
61579 | 120 |
|
14678 | 121 |
fun is_char s = size s = 1; |
122 |
||
37533
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
34095
diff
changeset
|
123 |
fun is_utf8 s = size s > 0 andalso forall_string (fn c => ord c >= 128) s; |
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
34095
diff
changeset
|
124 |
|
55033 | 125 |
fun raw_symbolic s = |
62877
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
126 |
String.isPrefix "\092<" s andalso String.isSuffix ">" s andalso not (String.isPrefix "\092<^" s); |
55033 | 127 |
|
14678 | 128 |
fun is_symbolic s = |
62210 | 129 |
s <> open_ andalso s <> close andalso raw_symbolic s; |
55033 | 130 |
|
131 |
val is_symbolic_char = member (op =) (raw_explode "!#$%&*+-/<=>?@^_|~"); |
|
14678 | 132 |
|
133 |
fun is_printable s = |
|
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
134 |
if is_char s then 32 <= ord s andalso ord s <= Char.ord #"~" |
55033 | 135 |
else is_utf8 s orelse raw_symbolic s; |
26632 | 136 |
|
61470 | 137 |
fun is_control s = |
62877
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
138 |
String.isPrefix "\092<^" s andalso String.isSuffix ">" s; |
61470 | 139 |
|
6272 | 140 |
|
14678 | 141 |
(* input source control *) |
6272 | 142 |
|
14678 | 143 |
val eof = ""; |
6272 | 144 |
fun is_eof s = s = eof; |
145 |
fun not_eof s = s <> eof; |
|
27732 | 146 |
val stopper = Scan.stopper (K eof) is_eof; |
6272 | 147 |
|
48774 | 148 |
fun is_malformed s = |
62877
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
149 |
String.isPrefix "\092<" s andalso not (String.isSuffix ">" s) |
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
150 |
orelse s = "\092<>" orelse s = "\092<^>"; |
48774 | 151 |
|
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
152 |
fun malformed_msg s = "Malformed symbolic character: " ^ quote s; |
14678 | 153 |
|
154 |
||
43418 | 155 |
(* ASCII symbols *) |
14678 | 156 |
|
157 |
fun is_ascii s = is_char s andalso ord s < 128; |
|
158 |
||
159 |
fun is_ascii_letter s = |
|
160 |
is_char s andalso |
|
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
161 |
(Char.ord #"A" <= ord s andalso ord s <= Char.ord #"Z" orelse |
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
162 |
Char.ord #"a" <= ord s andalso ord s <= Char.ord #"z"); |
14678 | 163 |
|
164 |
fun is_ascii_digit s = |
|
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
165 |
is_char s andalso Char.ord #"0" <= ord s andalso ord s <= Char.ord #"9"; |
14678 | 166 |
|
24580
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
wenzelm
parents:
23784
diff
changeset
|
167 |
fun is_ascii_hex s = |
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
wenzelm
parents:
23784
diff
changeset
|
168 |
is_char s andalso |
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
169 |
(Char.ord #"0" <= ord s andalso ord s <= Char.ord #"9" orelse |
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
170 |
Char.ord #"A" <= ord s andalso ord s <= Char.ord #"F" orelse |
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
171 |
Char.ord #"a" <= ord s andalso ord s <= Char.ord #"f"); |
24580
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
wenzelm
parents:
23784
diff
changeset
|
172 |
|
14678 | 173 |
fun is_ascii_quasi "_" = true |
174 |
| is_ascii_quasi "'" = true |
|
175 |
| is_ascii_quasi _ = false; |
|
176 |
||
177 |
val is_ascii_blank = |
|
43845
d89353d17f54
added File.fold_pages for streaming of large files;
wenzelm
parents:
43777
diff
changeset
|
178 |
fn " " => true | "\t" => true | "\n" => true | "\^K" => true | "\f" => true | "\^M" => true |
14678 | 179 |
| _ => false; |
180 |
||
34095
c2f176a38448
robust representation of low ASCII control characters within XML/YXML text;
wenzelm
parents:
33955
diff
changeset
|
181 |
fun is_ascii_control s = is_char s andalso ord s < 32 andalso not (is_ascii_blank s); |
c2f176a38448
robust representation of low ASCII control characters within XML/YXML text;
wenzelm
parents:
33955
diff
changeset
|
182 |
|
50236 | 183 |
fun is_ascii_letdig s = is_ascii_letter s orelse is_ascii_digit s orelse is_ascii_quasi s; |
184 |
||
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
185 |
fun is_ascii_lower s = is_char s andalso (Char.ord #"a" <= ord s andalso ord s <= Char.ord #"z"); |
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
186 |
fun is_ascii_upper s = is_char s andalso (Char.ord #"A" <= ord s andalso ord s <= Char.ord #"Z"); |
20200 | 187 |
|
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
188 |
fun to_ascii_lower s = if is_ascii_upper s then chr (ord s + Char.ord #"a" - Char.ord #"A") else s; |
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
189 |
fun to_ascii_upper s = if is_ascii_lower s then chr (ord s + Char.ord #"A" - Char.ord #"a") else s; |
20200 | 190 |
|
50238
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
wenzelm
parents:
50237
diff
changeset
|
191 |
fun is_ascii_identifier s = |
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
wenzelm
parents:
50237
diff
changeset
|
192 |
size s > 0 andalso is_ascii_letter (String.substring (s, 0, 1)) andalso |
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
wenzelm
parents:
50237
diff
changeset
|
193 |
forall_string is_ascii_letdig s; |
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
wenzelm
parents:
50237
diff
changeset
|
194 |
|
50236 | 195 |
val scan_ascii_id = Scan.one is_ascii_letter ^^ (Scan.many is_ascii_letdig >> implode); |
196 |
||
14678 | 197 |
|
14956
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
198 |
(* diagnostics *) |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
199 |
|
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
200 |
fun beginning n cs = |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
201 |
let |
67522 | 202 |
val drop_blanks = drop_suffix is_ascii_blank; |
14956
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
203 |
val all_cs = drop_blanks cs; |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
204 |
val dots = if length all_cs > n then " ..." else ""; |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
205 |
in |
33955 | 206 |
(drop_blanks (take n all_cs) |
14956
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
207 |
|> map (fn c => if is_ascii_blank c then space else c) |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
208 |
|> implode) ^ dots |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
209 |
end; |
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
210 |
|
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
wenzelm
parents:
14908
diff
changeset
|
211 |
|
14873 | 212 |
(* symbol variants *) |
213 |
||
37533
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
34095
diff
changeset
|
214 |
datatype sym = |
63936 | 215 |
Char of string | UTF8 of string | Sym of string | Control of string | Malformed of string | EOF; |
14873 | 216 |
|
217 |
fun decode s = |
|
43485 | 218 |
if s = "" then EOF |
219 |
else if is_char s then Char s |
|
37533
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
wenzelm
parents:
34095
diff
changeset
|
220 |
else if is_utf8 s then UTF8 s |
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
221 |
else if is_malformed s then Malformed s |
61475 | 222 |
else if is_control s then Control (String.substring (s, 3, size s - 4)) |
40523
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
wenzelm
parents:
40509
diff
changeset
|
223 |
else Sym (String.substring (s, 2, size s - 3)); |
14873 | 224 |
|
67373 | 225 |
fun encode (Char s) = s |
226 |
| encode (UTF8 s) = s |
|
227 |
| encode (Sym s) = "\092<" ^ s ^ ">" |
|
228 |
| encode (Control s) = "\092<^" ^ s ^ ">" |
|
229 |
| encode (Malformed s) = s |
|
230 |
| encode EOF = ""; |
|
231 |
||
14873 | 232 |
|
14678 | 233 |
(* standard symbol kinds *) |
234 |
||
14171
0cab06e3bbd0
Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
13730
diff
changeset
|
235 |
local |
50235 | 236 |
val letter_symbols = |
237 |
Symtab.make_set [ |
|
62529
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
238 |
"\<A>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
239 |
"\<B>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
240 |
"\<C>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
241 |
"\<D>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
242 |
"\<E>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
243 |
"\<F>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
244 |
"\<G>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
245 |
"\<H>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
246 |
"\<I>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
247 |
"\<J>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
248 |
"\<K>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
249 |
"\<L>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
250 |
"\<M>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
251 |
"\<N>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
252 |
"\<O>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
253 |
"\<P>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
254 |
"\<Q>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
255 |
"\<R>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
256 |
"\<S>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
257 |
"\<T>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
258 |
"\<U>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
259 |
"\<V>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
260 |
"\<W>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
261 |
"\<X>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
262 |
"\<Y>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
263 |
"\<Z>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
264 |
"\<a>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
265 |
"\<b>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
266 |
"\<c>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
267 |
"\<d>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
268 |
"\<e>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
269 |
"\<f>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
270 |
"\<g>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
271 |
"\<h>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
272 |
"\<i>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
273 |
"\<j>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
274 |
"\<k>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
275 |
"\<l>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
276 |
"\<m>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
277 |
"\<n>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
278 |
"\<o>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
279 |
"\<p>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
280 |
"\<q>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
281 |
"\<r>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
282 |
"\<s>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
283 |
"\<t>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
284 |
"\<u>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
285 |
"\<v>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
286 |
"\<w>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
287 |
"\<x>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
288 |
"\<y>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
289 |
"\<z>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
290 |
"\<AA>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
291 |
"\<BB>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
292 |
"\<CC>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
293 |
"\<DD>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
294 |
"\<EE>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
295 |
"\<FF>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
296 |
"\<GG>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
297 |
"\<HH>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
298 |
"\<II>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
299 |
"\<JJ>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
300 |
"\<KK>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
301 |
"\<LL>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
302 |
"\<MM>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
303 |
"\<NN>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
304 |
"\<OO>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
305 |
"\<PP>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
306 |
"\<QQ>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
307 |
"\<RR>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
308 |
"\<SS>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
309 |
"\<TT>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
310 |
"\<UU>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
311 |
"\<VV>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
312 |
"\<WW>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
313 |
"\<XX>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
314 |
"\<YY>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
315 |
"\<ZZ>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
316 |
"\<aa>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
317 |
"\<bb>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
318 |
"\<cc>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
319 |
"\<dd>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
320 |
"\<ee>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
321 |
"\<ff>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
322 |
"\<gg>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
323 |
"\<hh>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
324 |
"\<ii>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
325 |
"\<jj>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
326 |
"\<kk>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
327 |
"\<ll>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
328 |
"\<mm>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
329 |
"\<nn>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
330 |
"\<oo>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
331 |
"\<pp>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
332 |
"\<qq>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
333 |
"\<rr>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
334 |
"\<ss>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
335 |
"\<tt>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
336 |
"\<uu>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
337 |
"\<vv>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
338 |
"\<ww>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
339 |
"\<xx>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
340 |
"\<yy>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
341 |
"\<zz>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
342 |
"\<alpha>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
343 |
"\<beta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
344 |
"\<gamma>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
345 |
"\<delta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
346 |
"\<epsilon>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
347 |
"\<zeta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
348 |
"\<eta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
349 |
"\<theta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
350 |
"\<iota>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
351 |
"\<kappa>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
352 |
(*"\<lambda>", sic!*) |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
353 |
"\<mu>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
354 |
"\<nu>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
355 |
"\<xi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
356 |
"\<pi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
357 |
"\<rho>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
358 |
"\<sigma>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
359 |
"\<tau>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
360 |
"\<upsilon>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
361 |
"\<phi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
362 |
"\<chi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
363 |
"\<psi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
364 |
"\<omega>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
365 |
"\<Gamma>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
366 |
"\<Delta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
367 |
"\<Theta>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
368 |
"\<Lambda>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
369 |
"\<Xi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
370 |
"\<Pi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
371 |
"\<Sigma>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
372 |
"\<Upsilon>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
373 |
"\<Phi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
374 |
"\<Psi>", |
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
375 |
"\<Omega>" |
50235 | 376 |
]; |
14171
0cab06e3bbd0
Extended the notion of letter and digit, such that now one may use greek,
skalberg
parents:
13730
diff
changeset
|
377 |
in |
50242
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
378 |
|
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
379 |
val is_letter_symbol = Symtab.defined letter_symbols; |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
380 |
|
14678 | 381 |
end; |
14173 | 382 |
|
50242
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
383 |
datatype kind = Letter | Digit | Quasi | Blank | Other; |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
384 |
|
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
385 |
fun kind s = |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
386 |
if is_ascii_letter s then Letter |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
387 |
else if is_ascii_digit s then Digit |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
388 |
else if is_ascii_quasi s then Quasi |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
389 |
else if is_ascii_blank s then Blank |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
390 |
else if is_char s then Other |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
391 |
else if is_letter_symbol s then Letter |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
392 |
else Other; |
56b9c792a98b
support for sub-structured identifier syntax (inactive);
wenzelm
parents:
50239
diff
changeset
|
393 |
|
14678 | 394 |
fun is_letter s = kind s = Letter; |
395 |
fun is_digit s = kind s = Digit; |
|
396 |
fun is_quasi s = kind s = Quasi; |
|
397 |
fun is_blank s = kind s = Blank; |
|
6272 | 398 |
|
62529
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
399 |
val is_block_ctrl = member (op =) ["\<^bsub>", "\<^esub>", "\<^bsup>", "\<^esup>"]; |
47850
c638127b4653
avoid interference of markup for literal tokens, which may contain slightly odd \<^bsub> \<^esub> counted as pseudo-markup (especially relevant for HTML output, e.g. of thm power3_eq_cube);
wenzelm
parents:
43947
diff
changeset
|
400 |
|
14678 | 401 |
fun is_quasi_letter s = let val k = kind s in k = Letter orelse k = Quasi end; |
402 |
fun is_letdig s = let val k = kind s in k = Letter orelse k = Digit orelse k = Quasi end; |
|
11010 | 403 |
|
6272 | 404 |
|
50237 | 405 |
(* escape *) |
406 |
||
407 |
val esc = fn s => |
|
408 |
if is_char s then s |
|
409 |
else if is_utf8 s then translate_string (fn c => "\\" ^ string_of_int (ord c)) s |
|
410 |
else "\\" ^ s; |
|
411 |
||
63936 | 412 |
val escape = implode o map esc o Symbol.explode; |
50237 | 413 |
|
414 |
||
415 |
||
416 |
(** scanning through symbols **) |
|
417 |
||
418 |
(* scanner *) |
|
419 |
||
420 |
fun scanner msg scan syms = |
|
421 |
let |
|
422 |
fun message (ss, NONE) = (fn () => msg ^ ": " ^ quote (beginning 10 ss)) |
|
423 |
| message (ss, SOME msg') = (fn () => msg ^ ", " ^ msg' () ^ ": " ^ quote (beginning 10 ss)); |
|
424 |
val finite_scan = Scan.error (Scan.finite stopper (!! message scan)); |
|
425 |
in |
|
426 |
(case finite_scan syms of |
|
427 |
(result, []) => result |
|
428 |
| (_, rest) => error (message (rest, NONE) ())) |
|
429 |
end; |
|
430 |
||
431 |
||
50162 | 432 |
(* space-separated words *) |
433 |
||
434 |
val scan_word = |
|
435 |
Scan.many1 is_ascii_blank >> K NONE || |
|
436 |
Scan.many1 (fn s => not (is_ascii_blank s) andalso not_eof s) >> (SOME o implode); |
|
437 |
||
438 |
val split_words = scanner "Bad text" (Scan.repeat scan_word >> map_filter I); |
|
439 |
||
63936 | 440 |
val explode_words = split_words o Symbol.explode; |
50162 | 441 |
|
442 |
||
14678 | 443 |
(* blanks *) |
444 |
||
63936 | 445 |
val trim_blanks = Symbol.explode #> trim is_blank #> implode; |
14678 | 446 |
|
447 |
||
448 |
(* bump string -- treat as base 26 or base 1 numbers *) |
|
449 |
||
62529
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
wenzelm
parents:
62210
diff
changeset
|
450 |
fun symbolic_end (_ :: "\<^sub>" :: _) = true |
53198
06b096cf89ca
ignore trailing primes, e.g. rename \<alpha>' to \<alpha>'' instead of \<alpha>'a;
wenzelm
parents:
53016
diff
changeset
|
451 |
| symbolic_end ("'" :: ss) = symbolic_end ss |
55033 | 452 |
| symbolic_end (s :: _) = raw_symbolic s |
14908 | 453 |
| symbolic_end [] = false; |
14678 | 454 |
|
455 |
fun bump_init str = |
|
63936 | 456 |
if symbolic_end (rev (Symbol.explode str)) then str ^ "'" |
14678 | 457 |
else str ^ "a"; |
12904 | 458 |
|
459 |
fun bump_string str = |
|
460 |
let |
|
461 |
fun bump [] = ["a"] |
|
462 |
| bump ("z" :: ss) = "a" :: bump ss |
|
463 |
| bump (s :: ss) = |
|
64275
ac2abc987cf9
accomodate Poly/ML repository version, which treats singleton strings as boxed;
wenzelm
parents:
63936
diff
changeset
|
464 |
if is_char s andalso Char.ord #"a" <= ord s andalso ord s < Char.ord #"z" |
12904 | 465 |
then chr (ord s + 1) :: ss |
466 |
else "a" :: s :: ss; |
|
14678 | 467 |
|
67522 | 468 |
val (ss, qs) = apfst rev (chop_suffix is_quasi (Symbol.explode str)); |
14908 | 469 |
val ss' = if symbolic_end ss then "'" :: ss else bump ss; |
14678 | 470 |
in implode (rev ss' @ qs) end; |
471 |
||
12904 | 472 |
|
67512 | 473 |
(* styles *) |
474 |
||
475 |
val sub = "\092<^sub>"; |
|
476 |
val sup = "\092<^sup>"; |
|
477 |
val bold = "\092<^bold>"; |
|
478 |
||
479 |
fun make_style sym = |
|
480 |
Symbol.explode #> maps (fn s => [sym, s]) #> implode; |
|
481 |
||
482 |
val make_sub = make_style sub; |
|
483 |
val make_sup = make_style sup; |
|
484 |
val make_bold = make_style bold; |
|
485 |
||
486 |
||
6272 | 487 |
|
29324 | 488 |
(** symbol output **) |
14977
77d88064991a
added escape, export encode_raw, default mode now trivial, tuned;
wenzelm
parents:
14961
diff
changeset
|
489 |
|
29324 | 490 |
(* length *) |
6272 | 491 |
|
14678 | 492 |
fun sym_len s = |
24593
1547ea587f5a
added some int constraints (ML_Parse.fix_ints not active here);
wenzelm
parents:
24580
diff
changeset
|
493 |
if not (is_printable s) then (0: int) |
62877
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
494 |
else if String.isPrefix "\092<long" s then 2 |
741560a5283b
avoid malformed Isabelle symbols during bootstrap;
wenzelm
parents:
62804
diff
changeset
|
495 |
else if String.isPrefix "\092<Long" s then 2 |
14678 | 496 |
else 1; |
497 |
||
19473 | 498 |
fun sym_length ss = fold (fn s => fn n => sym_len s + n) ss 0; |
14678 | 499 |
|
63936 | 500 |
fun output s = (s, sym_length (Symbol.explode s)); |
29324 | 501 |
|
502 |
||
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
503 |
(*final declarations of this structure!*) |
63936 | 504 |
val explode = Symbol.explode; |
6272 | 505 |
val length = sym_length; |
6116
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
506 |
|
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
wenzelm
parents:
diff
changeset
|
507 |
end; |