diff options
| author | 2024-12-28 22:51:33 -0500 | |
|---|---|---|
| committer | 2024-12-28 22:51:33 -0500 | |
| commit | 641e8ad61257e969ff235b90c163691e2011c5e3 (patch) | |
| tree | b0f2dc83dbbfb2f8beb07d5541195a89775fc01f | |
| parent | more list work (diff) | |
refactor string exceptions
| -rw-r--r-- | container-iterator.egg | 4 | ||||
| -rw-r--r-- | mcgoron.iterator.list.scm | 1 | ||||
| -rw-r--r-- | mcgoron.iterator.string.exceptions.sld | 26 | ||||
| -rw-r--r-- | mcgoron.iterator.string.scm | 20 | ||||
| -rw-r--r-- | mcgoron.iterator.string.sld | 1 |
5 files changed, 12 insertions, 40 deletions
diff --git a/container-iterator.egg b/container-iterator.egg index e7b32c3..0329fa2 100644 --- a/container-iterator.egg +++ b/container-iterator.egg @@ -12,9 +12,6 @@ (source "mcgoron.iterator.base.sld") (component-dependencies mcgoron.iterator.exceptions) (csc-options "-R" "r7rs" "-X" "r7rs")) - (extension mcgoron.iterator.string.exceptions - (source "mcgoron.iterator.string.exceptions.sld") - (csc-options "-R" "r7rs" "-X" "r7rs")) (extension mcgoron.iterator.srfi.128 (source "mcgoron.iterator.srfi.128.sld") (component-dependencies mcgoron.iterator.base) @@ -23,6 +20,5 @@ (source "mcgoron.iterator.string.sld") (component-dependencies mcgoron.iterator.base mcgoron.iterator.exceptions - mcgoron.iterator.string.exceptions mcgoron.iterator.srfi.128) (csc-options "-R" "r7rs" "-X" "r7rs")))) diff --git a/mcgoron.iterator.list.scm b/mcgoron.iterator.list.scm index 21ab4be..b92689f 100644 --- a/mcgoron.iterator.list.scm +++ b/mcgoron.iterator.list.scm @@ -26,6 +26,7 @@ | item. |# +;;; TODO: handle IMPROPER-REST? properly (define (forward num signifier previous idx rest) (cond ((= num 0) diff --git a/mcgoron.iterator.string.exceptions.sld b/mcgoron.iterator.string.exceptions.sld deleted file mode 100644 index 4e85a4b..0000000 --- a/mcgoron.iterator.string.exceptions.sld +++ /dev/null @@ -1,26 +0,0 @@ -#| Copyright 2024 Peter McGoron - | - | Licensed under the Apache License, Version 2.0 (the "License"); - | you may not use this file except in compliance with the License. - | You may obtain a copy of the License at - | - | http://www.apache.org/licenses/LICENSE-2.0 - | - | Unless required by applicable law or agreed to in writing, software - | distributed under the License is distributed on an "AS IS" BASIS, - | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - | See the License for the specific language governing permissions and - | limitations under the License. - |# - -(define-library (mcgoron iterator string exceptions) - (import (scheme base)) - (export string-iterator-constructor-exception - string-iterator-constructor-exception? - string-iterator-constructor-exception:obj) - (begin - (define-record-type <string-iterator-constructor-exception> - (string-iterator-constructor-exception obj) - string-iterator-constructor-exception? - (obj string-iterator-constructor-exception:obj)))) - diff --git a/mcgoron.iterator.string.scm b/mcgoron.iterator.string.scm index 762b79d..62f10c4 100644 --- a/mcgoron.iterator.string.scm +++ b/mcgoron.iterator.string.scm @@ -76,21 +76,23 @@ (string-cursor<? x-cur y-cur))) #f))) +(define (string-constructor-exception obj) + (make-iterator-exception #f + 'string-constructor + (list (cons 'obj obj)))) + (define-syntax define-for-iterator-or-string ;; Define a function such that the first argument can either be a string ;; or a string iterator. The string iterator has its string extracted ;; before use. (syntax-rules () ((_ (name str args ...) body ...) - (define (name object args ...) - (define (internal str args ...) - body ...) - (cond - ((string? object) (internal object args ...)) - ((string-iterator? object) (internal (string-iterator-str object) - args ...)) - (else (raise (string-iterator-constructor-exception - object)))))))) + (define (name str args ...) + (let ((str (cond + ((string? str) str) + ((string-iterator? str) (string-iterator-str str)) + (else (raise (string-constructor-exception str)))))) + body ...))))) (define-for-iterator-or-string (string-iterator-start str) (string-iterator str (string-cursor-start str))) diff --git a/mcgoron.iterator.string.sld b/mcgoron.iterator.string.sld index ae2bb99..c3d4a48 100644 --- a/mcgoron.iterator.string.sld +++ b/mcgoron.iterator.string.sld @@ -18,7 +18,6 @@ (srfi 130) (srfi 128) (srfi 26) (mcgoron iterator base) (mcgoron iterator exceptions) - (mcgoron iterator string exceptions) (mcgoron iterator srfi 128)) (export string-iterator string-iterator? |
