218 |
218 |
219 val latin = Symbol.is_ascii_letter; |
219 val latin = Symbol.is_ascii_letter; |
220 val digit = Symbol.is_ascii_digit; |
220 val digit = Symbol.is_ascii_digit; |
221 fun underscore s = s = "_"; |
221 fun underscore s = s = "_"; |
222 fun prime s = s = "'"; |
222 fun prime s = s = "'"; |
223 fun script s = s = "\\<^sub>" orelse s = "\\<^isub>" orelse s = "\\<^isup>"; |
223 fun script s = s = "\\<^sub>" orelse s = "\\<^isub>"; |
224 fun special_letter s = Symbol.is_letter_symbol s andalso not (script s); |
224 fun special_letter s = Symbol.is_letter_symbol s andalso not (script s); |
225 |
225 |
226 val scan_plain = Scan.one ((latin orf digit orf prime) o symbol) >> single; |
226 val scan_plain = Scan.one ((latin orf digit orf prime) o symbol) >> single; |
227 val scan_digit = Scan.one (digit o symbol) >> single; |
227 val scan_digit = Scan.one (digit o symbol) >> single; |
228 val scan_prime = Scan.one (prime o symbol) >> single; |
228 val scan_prime = Scan.one (prime o symbol) >> single; |
229 |
229 |
230 val scan_script = |
230 val scan_script = |
231 Scan.one (script o symbol) -- Scan.one ((latin orf digit orf special_letter) o symbol) |
231 Scan.one (script o symbol) -- Scan.one ((latin orf digit orf prime orf special_letter) o symbol) |
232 >> (fn (x, y) => [x, y]); |
232 >> (fn (x, y) => [x, y]); |
233 |
233 |
234 val scan_ident_part1 = |
234 val scan_ident_part1 = |
235 Scan.one (latin o symbol) ::: (Scan.repeat (scan_plain || scan_script) >> flat) || |
235 Scan.one (latin o symbol) ::: (Scan.repeat (scan_plain || scan_script) >> flat) || |
236 Scan.one (special_letter o symbol) ::: |
236 Scan.one (special_letter o symbol) ::: |