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