From f91d101dffb51c8eb207914833d1a5241149ae7b Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 23 Jul 2022 22:24:34 -0400 Subject: Move comments to docstrings Just spent an hour implementing my own doc system, just to find out this is built in to guile :( --- bs/re.scm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'bs/re.scm') diff --git a/bs/re.scm b/bs/re.scm index 926aae7..ec5b2ba 100644 --- a/bs/re.scm +++ b/bs/re.scm @@ -27,30 +27,29 @@ ;; (define M regexp/newline) ;; (define MULTILINE regexp/newline) - ;; Compile `pattern` into a regular expression object. (define (compile pattern . flags) + "Compile `pattern` into a regular expression object." (apply make-regexp (cons pattern flags))) - ;; If zero or more characters at the beginning of `string` match the - ;; regular expression `pattern`, return a corresponding match object. + (define (match string pattern) + "If zero or more characters at the beginning of `string` match the regular +expression `pattern`, return a corresponding match object." (regexp-exec pattern string)) - ;; (define (group match-obj n) (if match-obj (match:substring match-obj n) #f)) - ;; Return the string obtained by replacing the leftmost - ;; non-overlapping occurrences of `pattern` in `string` by the - ;; replacement `repl`. If the pattern isn’t found, string is returned - ;; unchanged. (define (sub string pattern repl) + "Return the string obtained by replacing the leftmost non-overlapping +occurrences of `pattern` in `string` by the replacement `repl`. If the pattern +isn’t found, string is returned unchanged." (regexp-replace pattern string repl)) - ;; Scan through `string` looking for the first location where the - ;; regular expression `pattern` produces a match, and return a - ;; corresponding match object. Returns `#f` if no match is found. (define (search string pattern) - (regexp-exec pattern string))) + "Scan through `string` looking for the first location where the regular +expression `pattern` produces a match, and return a corresponding match +object. Returns `#f` if no match is found." + (string-match pattern string))) -- cgit v1.2.3