srfi-14-char-sets.scm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Mike Sperber
  3. ; This constructs the SRFI 14 char sets from thin air and what's defined in
  4. ; srfi-14-base-char-sets.scm.
  5. ; Defined there:
  6. ; lower-case, upper-case, title-case, letter, digit, punctuation, symbol
  7. (define char-set:empty (char-set))
  8. (define char-set:full (char-set-complement char-set:empty))
  9. (define char-set:letter+digit
  10. (char-set-union char-set:letter char-set:digit))
  11. (define char-set:graphic
  12. (char-set-union char-set:mark
  13. char-set:letter
  14. char-set:digit
  15. char-set:symbol
  16. char-set:punctuation))
  17. (define char-set:whitespace
  18. (char-set-union char-set:separator
  19. (list->char-set (map scalar-value->char
  20. '(9 ; tab
  21. 10 ; newline
  22. 11 ; vtab
  23. 12 ; page
  24. 13 ; return
  25. )))))
  26. (define char-set:printing
  27. (char-set-union char-set:whitespace char-set:graphic))
  28. (define char-set:iso-control
  29. (char-set-union (ucs-range->char-set 0 #x20)
  30. (ucs-range->char-set #x7f #xa0)))
  31. (define char-set:blank
  32. (char-set-union char-set:space-separator
  33. (char-set (scalar-value->char 9)))) ; tab
  34. (define char-set:ascii (ucs-range->char-set 0 128))
  35. (define char-set:hex-digit (string->char-set "0123456789abcdefABCDEF"))
  36. (make-char-set-immutable! char-set:empty)
  37. (make-char-set-immutable! char-set:full)
  38. (make-char-set-immutable! char-set:lower-case)
  39. (make-char-set-immutable! char-set:upper-case)
  40. (make-char-set-immutable! char-set:letter)
  41. (make-char-set-immutable! char-set:digit)
  42. (make-char-set-immutable! char-set:hex-digit)
  43. (make-char-set-immutable! char-set:letter+digit)
  44. (make-char-set-immutable! char-set:punctuation)
  45. (make-char-set-immutable! char-set:symbol)
  46. (make-char-set-immutable! char-set:graphic)
  47. (make-char-set-immutable! char-set:whitespace)
  48. (make-char-set-immutable! char-set:printing)
  49. (make-char-set-immutable! char-set:blank)
  50. (make-char-set-immutable! char-set:iso-control)
  51. (make-char-set-immutable! char-set:ascii)