fixed up the regexp-match contracts to make them more specific

svn: r18030
This commit is contained in:
Robby Findler 2010-02-09 16:03:03 +00:00
parent 419a50860c
commit 8228482d86

View File

@ -204,9 +204,10 @@ case-sensitively.
[start-pos exact-nonnegative-integer? 0] [start-pos exact-nonnegative-integer? 0]
[end-pos (or/c exact-nonnegative-integer? #f) #f] [end-pos (or/c exact-nonnegative-integer? #f) #f]
[output-port (or/c output-port? #f) #f]) [output-port (or/c output-port? #f) #f])
(or/c (cons/c string? (listof (or/c string? #f))) (if (and (or (string? pattern) (regexp? pattern))
(cons/c bytes? (listof (or/c bytes? #f))) (string? input))
#f)]{ (or/c #f (cons/c string? (listof (or/c string? #f))))
(or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{
Attempts to match @scheme[pattern] (a string, byte string, @tech{regexp Attempts to match @scheme[pattern] (a string, byte string, @tech{regexp
value}, or byte-@tech{regexp value}) once to a portion of @scheme[input]. The value}, or byte-@tech{regexp value}) once to a portion of @scheme[input]. The
@ -302,7 +303,10 @@ bytes. To avoid such interleaving, use @scheme[regexp-match-peek]
[input (or/c string? bytes? input-port?)] [input (or/c string? bytes? input-port?)]
[start-pos exact-nonnegative-integer? 0] [start-pos exact-nonnegative-integer? 0]
[end-pos (or/c exact-nonnegative-integer? #f) #f]) [end-pos (or/c exact-nonnegative-integer? #f) #f])
(or/c (listof string?) (listof bytes?))]{ (if (and (or (string? pattern) (regexp? pattern))
(string? input))
(listof string?)
(listof bytes?))]{
Like @scheme[regexp-match], but the result is a list of strings or Like @scheme[regexp-match], but the result is a list of strings or
byte strings corresponding to a sequence of matches of byte strings corresponding to a sequence of matches of
@ -331,15 +335,15 @@ port).
]} ]}
@defproc[(regexp-try-match @defproc[(regexp-try-match [pattern (or/c string? bytes? regexp? byte-regexp?)]
[pattern (or/c string? bytes? regexp? byte-regexp?)] [input input-port?]
[input input-port?] [start-pos exact-nonnegative-integer? 0]
[start-pos exact-nonnegative-integer? 0] [end-pos (or/c exact-nonnegative-integer? #f) #f]
[end-pos (or/c exact-nonnegative-integer? #f) #f] [output-port (or/c output-port? #f) #f])
[output-port (or/c output-port? #f) #f]) (if (and (or (string? pattern) (regexp? pattern))
(or/c (cons/c string? (listof (or/c string? #f))) (string? input))
(cons/c bytes? (listof (or/c bytes? #f))) (or/c #f (cons/c string? (listof (or/c string? #f))))
#f)]{ (or/c #f (cons/c bytes? (listof (or/c bytes? #f)))))]{
Like @scheme[regexp-match] on input ports, except that if the match Like @scheme[regexp-match] on input ports, except that if the match
fails, no characters are read and discarded from @scheme[in]. fails, no characters are read and discarded from @scheme[in].
@ -353,10 +357,10 @@ fails.}
@defproc[(regexp-match-positions [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-positions [pattern (or/c string? bytes? regexp? byte-regexp?)]
[input (or/c string? bytes? input-port?)] [input (or/c string? bytes? input-port?)]
[start-pos exact-nonnegative-integer? 0] [start-pos exact-nonnegative-integer? 0]
[end-pos (or/c exact-nonnegative-integer? #f) #f] [end-pos (or/c exact-nonnegative-integer? #f) #f]
[output-port (or/c output-port? #f) #f]) [output-port (or/c output-port? #f) #f])
(or/c (cons/c (cons/c exact-nonnegative-integer? (or/c (cons/c (cons/c exact-nonnegative-integer?
exact-nonnegative-integer?) exact-nonnegative-integer?)
(listof (or/c (cons/c exact-nonnegative-integer? (listof (or/c (cons/c exact-nonnegative-integer?
@ -386,9 +390,9 @@ positions indicate the number of bytes that were read, including
@defproc[(regexp-match-positions* [pattern (or/c string? bytes? regexp? byte-regexp?)] @defproc[(regexp-match-positions* [pattern (or/c string? bytes? regexp? byte-regexp?)]
[input (or/c string? bytes? input-port?)] [input (or/c string? bytes? input-port?)]
[start-pos exact-nonnegative-integer? 0] [start-pos exact-nonnegative-integer? 0]
[end-pos (or/c exact-nonnegative-integer? #f) #f]) [end-pos (or/c exact-nonnegative-integer? #f) #f])
(listof (cons/c exact-nonnegative-integer? (listof (cons/c exact-nonnegative-integer?
exact-nonnegative-integer?))]{ exact-nonnegative-integer?))]{
@ -524,7 +528,10 @@ Like @scheme[regexp-match-peek-positions], but returns multiple matches like
[input (or/c string? bytes? input-port?)] [input (or/c string? bytes? input-port?)]
[start-pos exact-nonnegative-integer? 0] [start-pos exact-nonnegative-integer? 0]
[end-pos (or/c exact-nonnegative-integer? #f) #f]) [end-pos (or/c exact-nonnegative-integer? #f) #f])
(cons/c (or/c string? bytes?) (listof (or/c string? bytes?)))]{ (if (and (or (string? pattern) (regexp? pattern))
(string? input))
(cons/c string? (listof string?))
(cons/c bytes? (listof bytes?)))]{
The complement of @scheme[regexp-match*]: the result is a list of The complement of @scheme[regexp-match*]: the result is a list of
strings (if @scheme[pattern] is a string or character regexp and strings (if @scheme[pattern] is a string or character regexp and
@ -561,7 +568,10 @@ an end-of-file if @scheme[input] is an input port).
[insert (or/c string? bytes? [insert (or/c string? bytes?
((string?) () #:rest (listof string?) . ->* . string?) ((string?) () #:rest (listof string?) . ->* . string?)
((bytes?) () #:rest (listof bytes?) . ->* . bytes?))]) ((bytes?) () #:rest (listof bytes?) . ->* . bytes?))])
(or/c string? bytes?)]{ (if (and (or (string? pattern) (regexp? pattern))
(string? input))
string?
bytes?)]{
Performs a match using @scheme[pattern] on @scheme[input], and then Performs a match using @scheme[pattern] on @scheme[input], and then
returns a string or byte string in which the matching portion of returns a string or byte string in which the matching portion of