src/Pure/General/symbol.ML
changeset 13559 51c3ac47d127
parent 12904 c208d71702d1
child 13730 09aeb7346d3f
equal deleted inserted replaced
13558:18acbbd4d225 13559:51c3ac47d127
    24   val is_digit: symbol -> bool
    24   val is_digit: symbol -> bool
    25   val is_quasi: symbol -> bool
    25   val is_quasi: symbol -> bool
    26   val is_quasi_letter: symbol -> bool
    26   val is_quasi_letter: symbol -> bool
    27   val is_letdig: symbol -> bool
    27   val is_letdig: symbol -> bool
    28   val is_blank: symbol -> bool
    28   val is_blank: symbol -> bool
       
    29   val is_identifier: symbol -> bool
    29   val is_symbolic: symbol -> bool
    30   val is_symbolic: symbol -> bool
    30   val is_printable: symbol -> bool
    31   val is_printable: symbol -> bool
    31   val length: symbol list -> int
    32   val length: symbol list -> int
    32   val strip_blanks: string -> string
    33   val strip_blanks: string -> string
    33   val beginning: symbol list -> string
    34   val beginning: symbol list -> string
   109 
   110 
   110 fun is_printable s =
   111 fun is_printable s =
   111   size s = 1 andalso ord space <= ord s andalso ord s <= ord "~" orelse
   112   size s = 1 andalso ord space <= ord s andalso ord s <= ord "~" orelse
   112   is_symbolic s;
   113   is_symbolic s;
   113 
   114 
       
   115 fun is_identifier s =
       
   116   case (explode s) of
       
   117       [] => false
       
   118     | c::cs => is_letter c andalso forall is_letdig cs;
   114 
   119 
   115 fun sym_length ss = foldl (fn (n, s) =>
   120 fun sym_length ss = foldl (fn (n, s) =>
   116   (if not (is_printable s) then 0 else
   121   (if not (is_printable s) then 0 else
   117     (case Library.try String.substring (s, 2, 4) of
   122     (case Library.try String.substring (s, 2, 4) of
   118       Some s' => if s' = "long" orelse s' = "Long" then 2 else 1
   123       Some s' => if s' = "long" orelse s' = "Long" then 2 else 1