diff --git a/functional-tests/regex.scm b/functional-tests/regex.scm index 16aeecd..8486a9c 100644 --- a/functional-tests/regex.scm +++ b/functional-tests/regex.scm @@ -6,7 +6,8 @@ (loops) (prefix (parser-combinators) p:) (srfi s8 receive) - (matchable)) + (matchable) + (utils)) ;; Simple regex library, because it's friday and I'm bored. ;; Playing with the ideas in: https://swtch.com/~rsc/regexp/regexp2.html @@ -183,13 +184,6 @@ (define (no-threads? y) (zero? (yarn-size y))) - (define-syntax swap - (syntax-rules () - ((_ x y) - (let ((tmp x)) - (set! x y) - (set! y tmp))))) - ;; FIXME: hack (define end-of-string #\x0) @@ -244,7 +238,7 @@ (if (no-threads? next-threads) #f (begin - (swap threads next-threads) + (swap! threads next-threads) (clear-yarn! next-threads) (c-loop (+ 1 c-index))))) (eq? 'match (step end-of-string)))))))) diff --git a/functional-tests/utils.scm b/functional-tests/utils.scm index a019a12..c47b43b 100644 --- a/functional-tests/utils.scm +++ b/functional-tests/utils.scm @@ -1,7 +1,8 @@ (library (utils) (export inc! - dec!) + dec! + swap!) (import (rnrs)) (define-syntax inc! @@ -13,4 +14,11 @@ (syntax-rules () ((_ v) (set! v (- v 1))) ((_ v n) (set! v (- v n))))) + + (define-syntax swap! + (syntax-rules () + ((_ x y) + (let ((tmp x)) + (set! x y) + (set! y tmp))))) )