Debian Codegraph @

%3a115/regexp.sls

raw
1 #!r6rs
2 ;; Copyright (c) 2009-2015 Alex Shinn
3 ;; All rights reserved.
4 ;;
5 ;; Redistribution and use in source and binary forms, with or without
6 ;; modification, are permitted provided that the following conditions
7 ;; are met:
8 ;; 1. Redistributions of source code must retain the above copyright
9 ;; notice, this list of conditions and the following disclaimer.
10 ;; 2. Redistributions in binary form must reproduce the above copyright
11 ;; notice, this list of conditions and the following disclaimer in the
12 ;; documentation and/or other materials provided with the distribution.
13 ;; 3. The name of the author may not be used to endorse or promote products
14 ;; derived from this software without specific prior written permission.
15 ;;
16 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ;; IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 ;; Converted from lib/chibi/regexp.sld to R6RS by Göran Weinholt.
28
29 (library (srfi :115 regexp)
30 (export regexp regexp? valid-sre? rx regexp->sre char-set->sre
31 regexp-matches regexp-matches? regexp-search
32 regexp-replace regexp-replace-all
33 regexp-fold regexp-extract regexp-split regexp-partition
34 regexp-match? regexp-match-count
35 regexp-match-submatch regexp-match-submatch/list
36 regexp-match-submatch-start regexp-match-submatch-end
37 regexp-match->list regexp-match->sexp)
38 (import (rename (except (rnrs) define-record-type string-ci-hash string-hash
39 error)
40 (exists any))
41 (only (rnrs r5rs) quotient)
42 (rnrs mutable-pairs)
43 (srfi :9 records)
44 (srfi :14 char-sets)
45 (srfi :23 error)
46 (srfi :69 basic-hash-tables)
47 (srfi :115 regexp boundary)
48 (srfi private include))
49
50 (define %char-set:letter
51 (char-set-intersection char-set:ascii char-set:letter))
52 (define %char-set:lower-case
53 (char-set-intersection char-set:ascii char-set:lower-case))
54 (define %char-set:upper-case
55 (char-set-intersection char-set:ascii char-set:upper-case))
56 (define %char-set:digit
57 (char-set-intersection char-set:ascii char-set:digit))
58 (define %char-set:letter+digit
59 (char-set-intersection char-set:ascii char-set:letter+digit))
60 (define %char-set:punctuation
61 (char-set-intersection char-set:ascii char-set:punctuation))
62 (define %char-set:symbol
63 (char-set-intersection char-set:ascii char-set:symbol))
64 (define %char-set:graphic
65 (char-set-intersection char-set:ascii char-set:graphic))
66 (define %char-set:whitespace
67 (char-set-intersection char-set:ascii char-set:whitespace))
68 (define %char-set:printing
69 (char-set-intersection char-set:ascii char-set:printing))
70 (define %char-set:iso-control
71 (char-set-intersection char-set:ascii char-set:iso-control))
72
73 (define (string-start-arg s o)
74 (if (pair? o) (string-index->cursor s (car o)) 0))
75 (define (string-end-arg s o)
76 (if (pair? o) (string-index->cursor s (car o)) (string-length s)))
77 (define string-cursor? integer?)
78 (define string-cursor=? =)
79 (define string-cursor<? <)
80 (define string-cursor<=? <=)
81 (define string-cursor>? >)
82 (define string-cursor>=? >=)
83 (define string-cursor-ref string-ref)
84 (define (string-cursor-next s i) (+ i 1))
85 (define (string-cursor-prev s i) (- i 1))
86 (define substring-cursor substring)
87 (define (string-cursor->index str off) off)
88 (define (string-index->cursor str i) i)
89 (define (string-concatenate ls) (apply string-append ls))
90 (define (string-concatenate-reverse ls)
91 (string-concatenate (reverse ls)))
92
93 ;; Replaced |\|| with \x7C;.
94 (include/resolve ("srfi" "%3a115") "regexp-impl.scm"))