| 1 |
;; -*- mode: scheme; coding: utf-8 -*- |
| 2 |
;; Copyright © 2018 Göran Weinholt <[email protected]> |
| 3 |
;; SPDX-License-Identifier: (MIT OR BSD-3-Clause OR LicenseRef-LICENSE) |
| 4 |
#!r6rs |
| 5 |
|
| 6 |
(library (srfi :14 char-sets) |
| 7 |
(export |
| 8 |
; Predicates & comparison |
| 9 |
char-set? char-set= char-set<= char-set-hash |
| 10 |
; Iterating over character sets |
| 11 |
char-set-cursor char-set-ref char-set-cursor-next end-of-char-set? |
| 12 |
char-set-fold char-set-unfold char-set-unfold! |
| 13 |
char-set-for-each char-set-map |
| 14 |
; Creating character sets |
| 15 |
char-set-copy char-set |
| 16 |
list->char-set string->char-set |
| 17 |
list->char-set! string->char-set! |
| 18 |
char-set-filter ucs-range->char-set |
| 19 |
char-set-filter! ucs-range->char-set! |
| 20 |
(rename (x->char-set ->char-set)) |
| 21 |
; Querying character sets |
| 22 |
char-set->list char-set->string |
| 23 |
char-set-size char-set-count char-set-contains? |
| 24 |
char-set-every char-set-any |
| 25 |
; Character-set algebra |
| 26 |
char-set-adjoin char-set-delete |
| 27 |
char-set-adjoin! char-set-delete! |
| 28 |
char-set-complement char-set-union char-set-intersection |
| 29 |
char-set-complement! char-set-union! char-set-intersection! |
| 30 |
char-set-difference char-set-xor char-set-diff+intersection |
| 31 |
char-set-difference! char-set-xor! char-set-diff+intersection! |
| 32 |
; Standard character sets |
| 33 |
char-set:lower-case char-set:upper-case char-set:title-case |
| 34 |
char-set:letter char-set:digit char-set:letter+digit |
| 35 |
char-set:graphic char-set:printing char-set:whitespace |
| 36 |
char-set:iso-control char-set:punctuation char-set:symbol |
| 37 |
char-set:hex-digit char-set:blank char-set:ascii |
| 38 |
char-set:empty char-set:full) |
| 39 |
(import |
| 40 |
(except (rnrs) define-record-type) |
| 41 |
(rnrs mutable-strings) |
| 42 |
(rnrs r5rs) |
| 43 |
(rename (only (srfi :1 lists) partition) |
| 44 |
(partition partition-list)) |
| 45 |
(srfi :9 records) |
| 46 |
(srfi private include) |
| 47 |
(srfi private let-opt) |
| 48 |
(srfi :14 char-sets inversion-list)) |
| 49 |
|
| 50 |
(define-syntax define-record-discloser |
| 51 |
(syntax-rules () |
| 52 |
((_ type discloser) |
| 53 |
(define dummy #f)))) |
| 54 |
|
| 55 |
(define (make-immutable! obj) |
| 56 |
#f) |
| 57 |
|
| 58 |
(define char->scalar-value char->integer) |
| 59 |
(define scalar-value->char integer->char) |
| 60 |
|
| 61 |
(define make-byte-vector make-bytevector) |
| 62 |
(define byte-vector-ref bytevector-u8-ref) |
| 63 |
(define byte-vector-set! bytevector-u8-set!) |
| 64 |
(define byte-vector=? bytevector=?) |
| 65 |
(define copy-bytes! bytevector-copy!) |
| 66 |
(define byte-vector-length bytevector-length) |
| 67 |
|
| 68 |
(define (unspecific) (if #f #f)) |
| 69 |
|
| 70 |
(define-syntax opt-lambda |
| 71 |
(lambda (x) |
| 72 |
(define (split-args args) |
| 73 |
(syntax-case args () |
| 74 |
[(name . rest) |
| 75 |
(identifier? #'name) |
| 76 |
(let-values (((names opt-args) (split-args #'rest))) |
| 77 |
(values (cons #'name names) opt-args))] |
| 78 |
[(opt-args ...) |
| 79 |
(values '() #'(opt-args ...))])) |
| 80 |
|
| 81 |
(syntax-case x () |
| 82 |
[(_ (args ...) body ...) |
| 83 |
(let-values (((fixed-args opt-args) (split-args #'(args ...)))) |
| 84 |
(with-syntax (((fixed-args ...) fixed-args) |
| 85 |
((opt-args ...) opt-args)) |
| 86 |
#'(lambda (fixed-args ... . rest) |
| 87 |
(let-optionals* rest (opt-args ...) body ...))))]))) |
| 88 |
|
| 89 |
(include/resolve ("srfi" "%3a14") "srfi-14.scm") |
| 90 |
(include/resolve ("srfi" "%3a14") "srfi-14-base-char-sets.scm") |
| 91 |
(include/resolve ("srfi" "%3a14") "srfi-14-char-sets.scm")) |