equal
deleted
inserted
replaced
11 val DEL: symbol |
11 val DEL: symbol |
12 val space: symbol |
12 val space: symbol |
13 val is_char: symbol -> bool |
13 val is_char: symbol -> bool |
14 val is_utf8: symbol -> bool |
14 val is_utf8: symbol -> bool |
15 val is_symbolic: symbol -> bool |
15 val is_symbolic: symbol -> bool |
|
16 val is_symbolic_char: symbol -> bool |
16 val is_printable: symbol -> bool |
17 val is_printable: symbol -> bool |
17 val eof: symbol |
18 val eof: symbol |
18 val is_eof: symbol -> bool |
19 val is_eof: symbol -> bool |
19 val not_eof: symbol -> bool |
20 val not_eof: symbol -> bool |
20 val stopper: symbol Scan.stopper |
21 val stopper: symbol Scan.stopper |
96 |
97 |
97 fun is_char s = size s = 1; |
98 fun is_char s = size s = 1; |
98 |
99 |
99 fun is_utf8 s = size s > 0 andalso forall_string (fn c => ord c >= 128) s; |
100 fun is_utf8 s = size s > 0 andalso forall_string (fn c => ord c >= 128) s; |
100 |
101 |
|
102 fun raw_symbolic s = |
|
103 String.isPrefix "\\<" s andalso String.isSuffix ">" s andalso not (String.isPrefix "\\<^" s); |
|
104 |
101 fun is_symbolic s = |
105 fun is_symbolic s = |
102 String.isPrefix "\\<" s andalso String.isSuffix ">" s andalso not (String.isPrefix "\\<^" s); |
106 s <> "\\<open>" andalso s <> "\\<close>" andalso raw_symbolic s; |
|
107 |
|
108 val is_symbolic_char = member (op =) (raw_explode "!#$%&*+-/<=>?@^_|~"); |
103 |
109 |
104 fun is_printable s = |
110 fun is_printable s = |
105 if is_char s then ord space <= ord s andalso ord s <= ord "~" |
111 if is_char s then ord space <= ord s andalso ord s <= ord "~" |
106 else is_utf8 s orelse is_symbolic s; |
112 else is_utf8 s orelse raw_symbolic s; |
107 |
113 |
108 |
114 |
109 (* input source control *) |
115 (* input source control *) |
110 |
116 |
111 val eof = ""; |
117 val eof = ""; |
515 |
521 |
516 (* bump string -- treat as base 26 or base 1 numbers *) |
522 (* bump string -- treat as base 26 or base 1 numbers *) |
517 |
523 |
518 fun symbolic_end (_ :: "\\<^sub>" :: _) = true |
524 fun symbolic_end (_ :: "\\<^sub>" :: _) = true |
519 | symbolic_end ("'" :: ss) = symbolic_end ss |
525 | symbolic_end ("'" :: ss) = symbolic_end ss |
520 | symbolic_end (s :: _) = is_symbolic s |
526 | symbolic_end (s :: _) = raw_symbolic s |
521 | symbolic_end [] = false; |
527 | symbolic_end [] = false; |
522 |
528 |
523 fun bump_init str = |
529 fun bump_init str = |
524 if symbolic_end (rev (sym_explode str)) then str ^ "'" |
530 if symbolic_end (rev (sym_explode str)) then str ^ "'" |
525 else str ^ "a"; |
531 else str ^ "a"; |