| author | steckerm | 
| Sat, 20 Sep 2014 10:42:08 +0200 | |
| changeset 58401 | b8ca69d9897b | 
| parent 55033 | 8e8243975860 | 
| child 58854 | b979c781c2db | 
| permissions | -rw-r--r-- | 
| 6118 | 1 | (* Title: Pure/General/symbol.ML | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 2 | Author: Markus Wenzel, TU Muenchen | 
| 
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 | 
| 26524 | 10 | val STX: symbol | 
| 11 | val DEL: symbol | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 12 | val space: symbol | 
| 14678 | 13 | val is_char: symbol -> bool | 
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 14 | val is_utf8: symbol -> bool | 
| 14678 | 15 | val is_symbolic: symbol -> bool | 
| 55033 | 16 | val is_symbolic_char: symbol -> bool | 
| 14678 | 17 | val is_printable: symbol -> bool | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 18 | val eof: symbol | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 19 | val is_eof: symbol -> bool | 
| 27766 | 20 | val not_eof: symbol -> bool | 
| 27732 | 21 | val stopper: symbol Scan.stopper | 
| 14678 | 22 | val sync: symbol | 
| 23 | val is_sync: symbol -> bool | |
| 23784 
75e6b9dd5336
Symbol.not_eof/sync is superceded by Symbol.is_regular (rules out further control symbols);
 wenzelm parents: 
23728diff
changeset | 24 | val is_regular: symbol -> bool | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 25 | val is_malformed: symbol -> bool | 
| 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 26 | val malformed_msg: symbol -> string | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 27 | val is_ascii: symbol -> bool | 
| 14678 | 28 | val is_ascii_letter: symbol -> bool | 
| 29 | val is_ascii_digit: symbol -> bool | |
| 24580 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 30 | val is_ascii_hex: symbol -> bool | 
| 14678 | 31 | val is_ascii_quasi: symbol -> bool | 
| 32 | val is_ascii_blank: symbol -> bool | |
| 34095 
c2f176a38448
robust representation of low ASCII control characters within XML/YXML text;
 wenzelm parents: 
33955diff
changeset | 33 | val is_ascii_control: symbol -> bool | 
| 50236 | 34 | val is_ascii_letdig: symbol -> bool | 
| 20200 | 35 | val is_ascii_lower: symbol -> bool | 
| 36 | val is_ascii_upper: symbol -> bool | |
| 37 | val to_ascii_lower: symbol -> symbol | |
| 38 | val to_ascii_upper: symbol -> symbol | |
| 50238 
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
 wenzelm parents: 
50237diff
changeset | 39 | val is_ascii_identifier: string -> bool | 
| 50236 | 40 | val scan_ascii_id: string list -> string * string list | 
| 14834 | 41 | val is_raw: symbol -> bool | 
| 42 | val decode_raw: symbol -> string | |
| 14977 
77d88064991a
added escape, export encode_raw, default mode now trivial, tuned;
 wenzelm parents: 
14961diff
changeset | 43 | val encode_raw: string -> string | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 44 | datatype sym = | 
| 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 45 | Char of string | UTF8 of string | Sym of string | Ctrl of string | Raw of string | | 
| 43485 | 46 | 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: 
43947diff
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 | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 58 | val source: (string, 'a) Source.source -> (symbol, (string, 'a) Source.source) Source.source | 
| 6272 | 59 | val explode: string -> symbol list | 
| 50237 | 60 | val esc: symbol -> string | 
| 61 | val escape: string -> string | |
| 62 | val scanner: string -> (string list -> 'a * string list) -> symbol list -> 'a | |
| 50162 | 63 | val split_words: symbol list -> string list | 
| 64 | val explode_words: string -> string list | |
| 14678 | 65 | val strip_blanks: string -> string | 
| 66 | val bump_init: string -> string | |
| 12904 | 67 | val bump_string: string -> string | 
| 14678 | 68 | val length: symbol list -> int | 
| 6692 | 69 | val xsymbolsN: string | 
| 40131 
7cbebd636e79
explicitly qualify type Output.output, which is a slightly odd internal feature;
 wenzelm parents: 
37728diff
changeset | 70 | 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 | 71 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 72 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 73 | structure Symbol: SYMBOL = | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 74 | struct | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 75 | |
| 14678 | 76 | (** type symbol **) | 
| 6272 | 77 | |
| 14678 | 78 | (*Symbols, which are considered the smallest entities of any Isabelle | 
| 6272 | 79 | string, may be of the following form: | 
| 14678 | 80 | |
| 14834 | 81 | (1) ASCII symbols: a | 
| 17823 | 82 | (2) regular symbols: \<ident> | 
| 14834 | 83 | (3) control symbols: \<^ident> | 
| 84 | (4) raw control symbols: \<^raw:...>, where "..." may be any printable | |
| 20205 
7b2958d3d575
raw symbols: disallow dot to avoid confusion in NameSpace.unpack;
 wenzelm parents: 
20200diff
changeset | 85 | character (excluding ".", ">"), or \<^raw000> | 
| 6272 | 86 | |
| 14678 | 87 | Output is subject to the print_mode variable (default: verbatim), | 
| 88 | actual interpretation in display is up to front-end tools. | |
| 6272 | 89 | *) | 
| 90 | ||
| 91 | type symbol = string; | |
| 92 | ||
| 26524 | 93 | val STX = chr 2; | 
| 94 | val DEL = chr 127; | |
| 95 | ||
| 96 | val space = chr 32; | |
| 17063 | 97 | |
| 14678 | 98 | fun is_char s = size s = 1; | 
| 99 | ||
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 100 | 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: 
34095diff
changeset | 101 | |
| 55033 | 102 | fun raw_symbolic s = | 
| 103 | String.isPrefix "\\<" s andalso String.isSuffix ">" s andalso not (String.isPrefix "\\<^" s); | |
| 104 | ||
| 14678 | 105 | fun is_symbolic s = | 
| 55033 | 106 | s <> "\\<open>" andalso s <> "\\<close>" andalso raw_symbolic s; | 
| 107 | ||
| 108 | val is_symbolic_char = member (op =) (raw_explode "!#$%&*+-/<=>?@^_|~"); | |
| 14678 | 109 | |
| 110 | fun is_printable s = | |
| 111 | if is_char s then ord space <= ord s andalso ord s <= ord "~" | |
| 55033 | 112 | else is_utf8 s orelse raw_symbolic s; | 
| 26632 | 113 | |
| 6272 | 114 | |
| 14678 | 115 | (* input source control *) | 
| 6272 | 116 | |
| 14678 | 117 | val eof = ""; | 
| 6272 | 118 | fun is_eof s = s = eof; | 
| 119 | fun not_eof s = s <> eof; | |
| 27732 | 120 | val stopper = Scan.stopper (K eof) is_eof; | 
| 6272 | 121 | |
| 53403 
c09f4005d6bd
some explicit indication of Proof General legacy;
 wenzelm parents: 
53198diff
changeset | 122 | (*Proof General legacy*) | 
| 14678 | 123 | val sync = "\\<^sync>"; | 
| 124 | fun is_sync s = s = sync; | |
| 125 | ||
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 126 | fun is_regular s = not_eof s andalso s <> sync; | 
| 25641 | 127 | |
| 48774 | 128 | fun is_malformed s = | 
| 129 | String.isPrefix "\\<" s andalso not (String.isSuffix ">" s) | |
| 130 | orelse s = "\\<>" orelse s = "\\<^>"; | |
| 131 | ||
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 132 | fun malformed_msg s = "Malformed symbolic character: " ^ quote s; | 
| 14678 | 133 | |
| 134 | ||
| 43418 | 135 | (* ASCII symbols *) | 
| 14678 | 136 | |
| 137 | fun is_ascii s = is_char s andalso ord s < 128; | |
| 138 | ||
| 139 | fun is_ascii_letter s = | |
| 140 | is_char s andalso | |
| 141 | (ord "A" <= ord s andalso ord s <= ord "Z" orelse | |
| 142 | ord "a" <= ord s andalso ord s <= ord "z"); | |
| 143 | ||
| 144 | fun is_ascii_digit s = | |
| 145 | is_char s andalso ord "0" <= ord s andalso ord s <= ord "9"; | |
| 146 | ||
| 24580 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 147 | fun is_ascii_hex s = | 
| 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 148 | is_char s andalso | 
| 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 149 | (ord "0" <= ord s andalso ord s <= ord "9" orelse | 
| 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 150 | ord "A" <= ord s andalso ord s <= ord "F" orelse | 
| 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 151 | ord "a" <= ord s andalso ord s <= ord "f"); | 
| 
916259859344
replaced Symbol.is_hex_letter to Symbol.is_ascii_hex;
 wenzelm parents: 
23784diff
changeset | 152 | |
| 14678 | 153 | fun is_ascii_quasi "_" = true | 
| 154 | | is_ascii_quasi "'" = true | |
| 155 | | is_ascii_quasi _ = false; | |
| 156 | ||
| 157 | val is_ascii_blank = | |
| 43845 
d89353d17f54
added File.fold_pages for streaming of large files;
 wenzelm parents: 
43777diff
changeset | 158 | fn " " => true | "\t" => true | "\n" => true | "\^K" => true | "\f" => true | "\^M" => true | 
| 14678 | 159 | | _ => false; | 
| 160 | ||
| 34095 
c2f176a38448
robust representation of low ASCII control characters within XML/YXML text;
 wenzelm parents: 
33955diff
changeset | 161 | 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: 
33955diff
changeset | 162 | |
| 50236 | 163 | fun is_ascii_letdig s = is_ascii_letter s orelse is_ascii_digit s orelse is_ascii_quasi s; | 
| 164 | ||
| 20200 | 165 | fun is_ascii_lower s = is_char s andalso (ord "a" <= ord s andalso ord s <= ord "z"); | 
| 166 | fun is_ascii_upper s = is_char s andalso (ord "A" <= ord s andalso ord s <= ord "Z"); | |
| 167 | ||
| 168 | fun to_ascii_lower s = if is_ascii_upper s then chr (ord s + ord "a" - ord "A") else s; | |
| 169 | fun to_ascii_upper s = if is_ascii_lower s then chr (ord s + ord "A" - ord "a") else s; | |
| 170 | ||
| 50238 
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
 wenzelm parents: 
50237diff
changeset | 171 | fun is_ascii_identifier s = | 
| 
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
 wenzelm parents: 
50237diff
changeset | 172 | 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: 
50237diff
changeset | 173 | forall_string is_ascii_letdig s; | 
| 
98d35a7368bd
more uniform Symbol.is_ascii_identifier in ML/Scala;
 wenzelm parents: 
50237diff
changeset | 174 | |
| 50236 | 175 | val scan_ascii_id = Scan.one is_ascii_letter ^^ (Scan.many is_ascii_letdig >> implode); | 
| 176 | ||
| 14678 | 177 | |
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 178 | (* encode_raw *) | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 179 | |
| 20205 
7b2958d3d575
raw symbols: disallow dot to avoid confusion in NameSpace.unpack;
 wenzelm parents: 
20200diff
changeset | 180 | fun raw_chr c = | 
| 48773 
0e1bab274672
more liberal scanning of potentially malformed symbols;
 wenzelm parents: 
48704diff
changeset | 181 | is_char c andalso | 
| 
0e1bab274672
more liberal scanning of potentially malformed symbols;
 wenzelm parents: 
48704diff
changeset | 182 | (ord space <= ord c andalso ord c <= ord "~" andalso c <> "." andalso c <> ">" | 
| 
0e1bab274672
more liberal scanning of potentially malformed symbols;
 wenzelm parents: 
48704diff
changeset | 183 | orelse ord c >= 128); | 
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 184 | |
| 29324 | 185 | fun encode_raw "" = "" | 
| 186 | | encode_raw str = | |
| 187 | let | |
| 188 | val raw0 = enclose "\\<^raw:" ">"; | |
| 189 | val raw1 = raw0 o implode; | |
| 190 | val raw2 = enclose "\\<^raw" ">" o string_of_int o ord; | |
| 50162 | 191 | |
| 33955 | 192 | fun encode cs = enc (take_prefix raw_chr cs) | 
| 29324 | 193 | and enc ([], []) = [] | 
| 194 | | enc (cs, []) = [raw1 cs] | |
| 195 | | enc ([], d :: ds) = raw2 d :: encode ds | |
| 196 | | enc (cs, d :: ds) = raw1 cs :: raw2 d :: encode ds; | |
| 197 | in | |
| 40627 
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
 wenzelm parents: 
40523diff
changeset | 198 | if exists_string (not o raw_chr) str then implode (encode (raw_explode str)) | 
| 29324 | 199 | else raw0 str | 
| 200 | end; | |
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 201 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 202 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 203 | (* diagnostics *) | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 204 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 205 | fun beginning n cs = | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 206 | let | 
| 33955 | 207 | val drop_blanks = #1 o take_suffix is_ascii_blank; | 
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 208 | val all_cs = drop_blanks cs; | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 209 | val dots = if length all_cs > n then " ..." else ""; | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 210 | in | 
| 33955 | 211 | (drop_blanks (take n all_cs) | 
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 212 | |> map (fn c => if is_ascii_blank c then space else c) | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 213 | |> implode) ^ dots | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 214 | end; | 
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 215 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 216 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 217 | (* decode_raw *) | 
| 14834 | 218 | |
| 219 | fun is_raw s = | |
| 17063 | 220 | String.isPrefix "\\<^raw" s andalso String.isSuffix ">" s; | 
| 14834 | 221 | |
| 222 | fun decode_raw s = | |
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 223 | if not (is_raw s) then error (malformed_msg s) | 
| 14834 | 224 | else if String.isPrefix "\\<^raw:" s then String.substring (s, 7, size s - 8) | 
| 40627 
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
 wenzelm parents: 
40523diff
changeset | 225 | else chr (#1 (Library.read_int (raw_explode (String.substring (s, 6, size s - 7))))); | 
| 14834 | 226 | |
| 227 | ||
| 14873 | 228 | (* symbol variants *) | 
| 229 | ||
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 230 | datatype sym = | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 231 | Char of string | UTF8 of string | Sym of string | Ctrl of string | Raw of string | | 
| 43485 | 232 | Malformed of string | EOF; | 
| 14873 | 233 | |
| 234 | fun decode s = | |
| 43485 | 235 | if s = "" then EOF | 
| 236 | else if is_char s then Char s | |
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 237 | else if is_utf8 s then UTF8 s | 
| 14873 | 238 | else if is_raw s then Raw (decode_raw s) | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 239 | else if is_malformed s then Malformed s | 
| 14873 | 240 | else if String.isPrefix "\\<^" s then Ctrl (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: 
40509diff
changeset | 241 | else Sym (String.substring (s, 2, size s - 3)); | 
| 14873 | 242 | |
| 243 | ||
| 14678 | 244 | (* standard symbol kinds *) | 
| 245 | ||
| 14171 
0cab06e3bbd0
Extended the notion of letter and digit, such that now one may use greek,
 skalberg parents: 
13730diff
changeset | 246 | local | 
| 50235 | 247 | val letter_symbols = | 
| 248 | Symtab.make_set [ | |
| 249 | "\\<A>", | |
| 250 | "\\<B>", | |
| 251 | "\\<C>", | |
| 252 | "\\<D>", | |
| 253 | "\\<E>", | |
| 254 | "\\<F>", | |
| 255 | "\\<G>", | |
| 256 | "\\<H>", | |
| 257 | "\\<I>", | |
| 258 | "\\<J>", | |
| 259 | "\\<K>", | |
| 260 | "\\<L>", | |
| 261 | "\\<M>", | |
| 262 | "\\<N>", | |
| 263 | "\\<O>", | |
| 264 | "\\<P>", | |
| 265 | "\\<Q>", | |
| 266 | "\\<R>", | |
| 267 | "\\<S>", | |
| 268 | "\\<T>", | |
| 269 | "\\<U>", | |
| 270 | "\\<V>", | |
| 271 | "\\<W>", | |
| 272 | "\\<X>", | |
| 273 | "\\<Y>", | |
| 274 | "\\<Z>", | |
| 275 | "\\<a>", | |
| 276 | "\\<b>", | |
| 277 | "\\<c>", | |
| 278 | "\\<d>", | |
| 279 | "\\<e>", | |
| 280 | "\\<f>", | |
| 281 | "\\<g>", | |
| 282 | "\\<h>", | |
| 283 | "\\<i>", | |
| 284 | "\\<j>", | |
| 285 | "\\<k>", | |
| 286 | "\\<l>", | |
| 287 | "\\<m>", | |
| 288 | "\\<n>", | |
| 289 | "\\<o>", | |
| 290 | "\\<p>", | |
| 291 | "\\<q>", | |
| 292 | "\\<r>", | |
| 293 | "\\<s>", | |
| 294 | "\\<t>", | |
| 295 | "\\<u>", | |
| 296 | "\\<v>", | |
| 297 | "\\<w>", | |
| 298 | "\\<x>", | |
| 299 | "\\<y>", | |
| 300 | "\\<z>", | |
| 301 | "\\<AA>", | |
| 302 | "\\<BB>", | |
| 303 | "\\<CC>", | |
| 304 | "\\<DD>", | |
| 305 | "\\<EE>", | |
| 306 | "\\<FF>", | |
| 307 | "\\<GG>", | |
| 308 | "\\<HH>", | |
| 309 | "\\<II>", | |
| 310 | "\\<JJ>", | |
| 311 | "\\<KK>", | |
| 312 | "\\<LL>", | |
| 313 | "\\<MM>", | |
| 314 | "\\<NN>", | |
| 315 | "\\<OO>", | |
| 316 | "\\<PP>", | |
| 317 | "\\<QQ>", | |
| 318 | "\\<RR>", | |
| 319 | "\\<SS>", | |
| 320 | "\\<TT>", | |
| 321 | "\\<UU>", | |
| 322 | "\\<VV>", | |
| 323 | "\\<WW>", | |
| 324 | "\\<XX>", | |
| 325 | "\\<YY>", | |
| 326 | "\\<ZZ>", | |
| 327 | "\\<aa>", | |
| 328 | "\\<bb>", | |
| 329 | "\\<cc>", | |
| 330 | "\\<dd>", | |
| 331 | "\\<ee>", | |
| 332 | "\\<ff>", | |
| 333 | "\\<gg>", | |
| 334 | "\\<hh>", | |
| 335 | "\\<ii>", | |
| 336 | "\\<jj>", | |
| 337 | "\\<kk>", | |
| 338 | "\\<ll>", | |
| 339 | "\\<mm>", | |
| 340 | "\\<nn>", | |
| 341 | "\\<oo>", | |
| 342 | "\\<pp>", | |
| 343 | "\\<qq>", | |
| 344 | "\\<rr>", | |
| 345 | "\\<ss>", | |
| 346 | "\\<tt>", | |
| 347 | "\\<uu>", | |
| 348 | "\\<vv>", | |
| 349 | "\\<ww>", | |
| 350 | "\\<xx>", | |
| 351 | "\\<yy>", | |
| 352 | "\\<zz>", | |
| 353 | "\\<alpha>", | |
| 354 | "\\<beta>", | |
| 355 | "\\<gamma>", | |
| 356 | "\\<delta>", | |
| 357 | "\\<epsilon>", | |
| 358 | "\\<zeta>", | |
| 359 | "\\<eta>", | |
| 360 | "\\<theta>", | |
| 361 | "\\<iota>", | |
| 362 | "\\<kappa>", | |
| 363 | (*"\\<lambda>", sic!*) | |
| 364 | "\\<mu>", | |
| 365 | "\\<nu>", | |
| 366 | "\\<xi>", | |
| 367 | "\\<pi>", | |
| 368 | "\\<rho>", | |
| 369 | "\\<sigma>", | |
| 370 | "\\<tau>", | |
| 371 | "\\<upsilon>", | |
| 372 | "\\<phi>", | |
| 373 | "\\<chi>", | |
| 374 | "\\<psi>", | |
| 375 | "\\<omega>", | |
| 376 | "\\<Gamma>", | |
| 377 | "\\<Delta>", | |
| 378 | "\\<Theta>", | |
| 379 | "\\<Lambda>", | |
| 380 | "\\<Xi>", | |
| 381 | "\\<Pi>", | |
| 382 | "\\<Sigma>", | |
| 383 | "\\<Upsilon>", | |
| 384 | "\\<Phi>", | |
| 385 | "\\<Psi>", | |
| 52616 
3ac2878764f9
more robust identifier syntax: sub/superscript counts as modifier of LETDIG part instead of LETTER, both isub/isup and sub/sup are allowed;
 wenzelm parents: 
50242diff
changeset | 386 | "\\<Omega>" | 
| 50235 | 387 | ]; | 
| 14171 
0cab06e3bbd0
Extended the notion of letter and digit, such that now one may use greek,
 skalberg parents: 
13730diff
changeset | 388 | in | 
| 50242 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 389 | |
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 390 | val is_letter_symbol = Symtab.defined letter_symbols; | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 391 | |
| 14678 | 392 | end; | 
| 14173 | 393 | |
| 50242 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 394 | datatype kind = Letter | Digit | Quasi | Blank | Other; | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 395 | |
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 396 | fun kind s = | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 397 | if is_ascii_letter s then Letter | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 398 | else if is_ascii_digit s then Digit | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 399 | else if is_ascii_quasi s then Quasi | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 400 | else if is_ascii_blank s then Blank | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 401 | else if is_char s then Other | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 402 | else if is_letter_symbol s then Letter | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 403 | else Other; | 
| 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 404 | |
| 14678 | 405 | fun is_letter s = kind s = Letter; | 
| 406 | fun is_digit s = kind s = Digit; | |
| 407 | fun is_quasi s = kind s = Quasi; | |
| 408 | fun is_blank s = kind s = Blank; | |
| 6272 | 409 | |
| 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: 
43947diff
changeset | 410 | val is_block_ctrl = member (op =) ["\\<^bsub>", "\\<^esub>", "\\<^bsup>", "\\<^esup>"]; | 
| 
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: 
43947diff
changeset | 411 | |
| 14678 | 412 | fun is_quasi_letter s = let val k = kind s in k = Letter orelse k = Quasi end; | 
| 413 | fun is_letdig s = let val k = kind s in k = Letter orelse k = Digit orelse k = Quasi end; | |
| 11010 | 414 | |
| 6272 | 415 | |
| 416 | ||
| 14678 | 417 | (** symbol input **) | 
| 418 | ||
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 419 | (* source *) | 
| 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 420 | |
| 14678 | 421 | local | 
| 14561 
c53396af770e
* raw control symbols are of the form \<^raw:...> now.
 schirmer parents: 
14559diff
changeset | 422 | |
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 423 | fun is_plain s = is_ascii s andalso s <> "\^M" andalso s <> "\\"; | 
| 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 424 | |
| 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 425 | fun is_utf8_trailer s = is_char s andalso 128 <= ord s andalso ord s < 192; | 
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 426 | |
| 37728 
5d2b3e827371
implode pseudo utf8, i.e. decode byte-stuffed low ASCII characters;
 wenzelm parents: 
37534diff
changeset | 427 | fun implode_pseudo_utf8 (cs as ["\192", c]) = | 
| 
5d2b3e827371
implode pseudo utf8, i.e. decode byte-stuffed low ASCII characters;
 wenzelm parents: 
37534diff
changeset | 428 | if ord c < 160 then chr (ord c - 128) else implode cs | 
| 
5d2b3e827371
implode pseudo utf8, i.e. decode byte-stuffed low ASCII characters;
 wenzelm parents: 
37534diff
changeset | 429 | | implode_pseudo_utf8 cs = implode cs; | 
| 
5d2b3e827371
implode pseudo utf8, i.e. decode byte-stuffed low ASCII characters;
 wenzelm parents: 
37534diff
changeset | 430 | |
| 14678 | 431 | val scan_encoded_newline = | 
| 17756 | 432 | $$ "\^M" -- $$ "\n" >> K "\n" || | 
| 54734 
b91afc3aa3e6
clarified Proof General legacy: special treatment of \<^newline> only in TTY mode;
 wenzelm parents: 
54732diff
changeset | 433 | $$ "\^M" >> K "\n"; | 
| 14956 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 434 | |
| 
70ec4b8aef8d
prevent looping of error messages involving malformed symbols;
 wenzelm parents: 
14908diff
changeset | 435 | val scan_raw = | 
| 21858 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
21495diff
changeset | 436 | Scan.this_string "raw:" ^^ (Scan.many raw_chr >> implode) || | 
| 
05f57309170c
avoid conflict with Alice keywords: renamed pack -> implode, unpack -> explode, any -> many, avoided assert;
 wenzelm parents: 
21495diff
changeset | 437 | Scan.this_string "raw" ^^ (Scan.many1 is_ascii_digit >> implode); | 
| 14678 | 438 | |
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 439 | val scan_total = | 
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 440 | Scan.one is_plain || | 
| 37728 
5d2b3e827371
implode pseudo utf8, i.e. decode byte-stuffed low ASCII characters;
 wenzelm parents: 
37534diff
changeset | 441 | Scan.one is_utf8 ::: Scan.many is_utf8_trailer >> implode_pseudo_utf8 || | 
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 442 | scan_encoded_newline || | 
| 48773 
0e1bab274672
more liberal scanning of potentially malformed symbols;
 wenzelm parents: 
48704diff
changeset | 443 | ($$ "\\" ^^ $$ "<" ^^ | 
| 50236 | 444 | (($$ "^" ^^ Scan.optional (scan_raw || scan_ascii_id) "" || Scan.optional scan_ascii_id "") ^^ | 
| 48774 | 445 | Scan.optional ($$ ">") "")) || | 
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 446 | Scan.one not_eof; | 
| 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 447 | |
| 14678 | 448 | in | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 449 | |
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 450 | fun source src = Source.source stopper (Scan.bulk scan_total) NONE src; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 451 | |
| 14678 | 452 | end; | 
| 453 | ||
| 14562 
980da32f4617
proper handling of lines terminated by CRLF or CR;
 wenzelm parents: 
14561diff
changeset | 454 | |
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 455 | (* explode *) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 456 | |
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 457 | local | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 458 | |
| 14562 
980da32f4617
proper handling of lines terminated by CRLF or CR;
 wenzelm parents: 
14561diff
changeset | 459 | fun no_explode [] = true | 
| 
980da32f4617
proper handling of lines terminated by CRLF or CR;
 wenzelm parents: 
14561diff
changeset | 460 |   | no_explode ("\\" :: "<" :: _) = false
 | 
| 17756 | 461 |   | no_explode ("\^M" :: _) = false
 | 
| 37533 
d775bd70f571
explicit treatment of UTF8 character sequences as Isabelle symbols;
 wenzelm parents: 
34095diff
changeset | 462 | | no_explode (c :: cs) = is_ascii c andalso no_explode cs; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 463 | |
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 464 | in | 
| 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 465 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 466 | fun sym_explode str = | 
| 40627 
becf5d5187cc
renamed raw "explode" function to "raw_explode" to emphasize its meaning;
 wenzelm parents: 
40523diff
changeset | 467 | let val chs = raw_explode str in | 
| 14562 
980da32f4617
proper handling of lines terminated by CRLF or CR;
 wenzelm parents: 
14561diff
changeset | 468 | if no_explode chs then chs | 
| 40523 
1050315f6ee2
simplified/robustified treatment of malformed symbols, which are now fully internalized (total Symbol.explode etc.);
 wenzelm parents: 
40509diff
changeset | 469 | else Source.exhaust (source (Source.of_list chs)) | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 470 | end; | 
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 471 | |
| 23676 
ea9b7e9c2301
scan: changed treatment of malformed symbols, passed to next stage;
 wenzelm parents: 
23618diff
changeset | 472 | end; | 
| 14994 | 473 | |
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 474 | |
| 50237 | 475 | (* escape *) | 
| 476 | ||
| 477 | val esc = fn s => | |
| 478 | if is_char s then s | |
| 479 | else if is_utf8 s then translate_string (fn c => "\\" ^ string_of_int (ord c)) s | |
| 480 | else "\\" ^ s; | |
| 481 | ||
| 482 | val escape = implode o map esc o sym_explode; | |
| 483 | ||
| 484 | ||
| 485 | ||
| 486 | (** scanning through symbols **) | |
| 487 | ||
| 488 | (* scanner *) | |
| 489 | ||
| 490 | fun scanner msg scan syms = | |
| 491 | let | |
| 492 | fun message (ss, NONE) = (fn () => msg ^ ": " ^ quote (beginning 10 ss)) | |
| 493 | | message (ss, SOME msg') = (fn () => msg ^ ", " ^ msg' () ^ ": " ^ quote (beginning 10 ss)); | |
| 494 | val finite_scan = Scan.error (Scan.finite stopper (!! message scan)); | |
| 495 | in | |
| 496 | (case finite_scan syms of | |
| 497 | (result, []) => result | |
| 498 | | (_, rest) => error (message (rest, NONE) ())) | |
| 499 | end; | |
| 500 | ||
| 501 | ||
| 50162 | 502 | (* space-separated words *) | 
| 503 | ||
| 504 | val scan_word = | |
| 505 | Scan.many1 is_ascii_blank >> K NONE || | |
| 506 | Scan.many1 (fn s => not (is_ascii_blank s) andalso not_eof s) >> (SOME o implode); | |
| 507 | ||
| 508 | val split_words = scanner "Bad text" (Scan.repeat scan_word >> map_filter I); | |
| 509 | ||
| 510 | val explode_words = split_words o sym_explode; | |
| 511 | ||
| 512 | ||
| 14678 | 513 | (* blanks *) | 
| 514 | ||
| 515 | fun strip_blanks s = | |
| 516 | sym_explode s | |
| 33955 | 517 | |> take_prefix is_blank |> #2 | 
| 518 | |> take_suffix is_blank |> #1 | |
| 14678 | 519 | |> implode; | 
| 520 | ||
| 521 | ||
| 522 | (* bump string -- treat as base 26 or base 1 numbers *) | |
| 523 | ||
| 50242 
56b9c792a98b
support for sub-structured identifier syntax (inactive);
 wenzelm parents: 
50239diff
changeset | 524 | fun symbolic_end (_ :: "\\<^sub>" :: _) = true | 
| 53198 
06b096cf89ca
ignore trailing primes, e.g. rename \<alpha>' to \<alpha>'' instead of \<alpha>'a;
 wenzelm parents: 
53016diff
changeset | 525 |   | symbolic_end ("'" :: ss) = symbolic_end ss
 | 
| 55033 | 526 | | symbolic_end (s :: _) = raw_symbolic s | 
| 14908 | 527 | | symbolic_end [] = false; | 
| 14678 | 528 | |
| 529 | fun bump_init str = | |
| 14908 | 530 | if symbolic_end (rev (sym_explode str)) then str ^ "'" | 
| 14678 | 531 | else str ^ "a"; | 
| 12904 | 532 | |
| 533 | fun bump_string str = | |
| 534 | let | |
| 535 | fun bump [] = ["a"] | |
| 536 |       | bump ("z" :: ss) = "a" :: bump ss
 | |
| 537 | | bump (s :: ss) = | |
| 14678 | 538 | if is_char s andalso ord "a" <= ord s andalso ord s < ord "z" | 
| 12904 | 539 | then chr (ord s + 1) :: ss | 
| 540 | else "a" :: s :: ss; | |
| 14678 | 541 | |
| 33955 | 542 | val (ss, qs) = apfst rev (take_suffix is_quasi (sym_explode str)); | 
| 14908 | 543 | val ss' = if symbolic_end ss then "'" :: ss else bump ss; | 
| 14678 | 544 | in implode (rev ss' @ qs) end; | 
| 545 | ||
| 12904 | 546 | |
| 6272 | 547 | |
| 29324 | 548 | (** symbol output **) | 
| 14977 
77d88064991a
added escape, export encode_raw, default mode now trivial, tuned;
 wenzelm parents: 
14961diff
changeset | 549 | |
| 29324 | 550 | (* length *) | 
| 6272 | 551 | |
| 14678 | 552 | fun sym_len s = | 
| 24593 
1547ea587f5a
added some int constraints (ML_Parse.fix_ints not active here);
 wenzelm parents: 
24580diff
changeset | 553 | if not (is_printable s) then (0: int) | 
| 14678 | 554 | else if String.isPrefix "\\<long" s then 2 | 
| 555 | else if String.isPrefix "\\<Long" s then 2 | |
| 556 | else 1; | |
| 557 | ||
| 19473 | 558 | fun sym_length ss = fold (fn s => fn n => sym_len s + n) ss 0; | 
| 14678 | 559 | |
| 29324 | 560 | |
| 561 | (* print mode *) | |
| 562 | ||
| 563 | val xsymbolsN = "xsymbols"; | |
| 564 | ||
| 565 | fun output s = (s, sym_length (sym_explode s)); | |
| 566 | ||
| 567 | ||
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 568 | (*final declarations of this structure!*) | 
| 29324 | 569 | val explode = sym_explode; | 
| 6272 | 570 | val length = sym_length; | 
| 6116 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 571 | |
| 
8ba2f25610f7
files scan.ML, source.ML, symbol.ML, pretty.ML moved to Pure/General;
 wenzelm parents: diff
changeset | 572 | end; |