Big, buggy commit
:for clauses now have finalizers! This means (in-file "path") now works. This meant I had to do some restructuring of many nasty pieces of code, but I believe it works. cl-next was broken up into cl-next/acc and cl-next/for. Accumulators have to pass :acc to (cl-next/acc ...). I plan for :for clauses to do the same. I fixed tests.scm and README.md to reflect the de-racketification of the for loops.
This commit is contained in:
parent
1a826f86e2
commit
0c110dd080
4 changed files with 175 additions and 126 deletions
|
@ -177,23 +177,21 @@
|
|||
|
||||
;; ;;> \macro{(for ch (in-file [input-port [reader [eof?]]]))}
|
||||
|
||||
;; (define-syntax in-file
|
||||
;; (syntax-rules ()
|
||||
;; ((in-file ((var) source) next . rest)
|
||||
;; (in-file ((var p) source) next . rest))
|
||||
;; ((in-file ((var p) (file)) next . rest)
|
||||
;; (in-file ((var p) (file read-char)) next . rest))
|
||||
;; ((in-file ((var p) (file reader)) next . rest)
|
||||
;; (in-file ((var p) (file reader eof-object?)) next . rest))
|
||||
;; ((in-file ((var p) (file reader eof?)) next . rest)
|
||||
;; (next ((p (open-input-file file)) (r reader) (e? eof?))
|
||||
;; ()
|
||||
;; ((var (r p) (r p)))
|
||||
;; ((e? var))
|
||||
;; ()
|
||||
;; ((dummy (clo
|
||||
;; se-input-port p)))
|
||||
;; . rest))))
|
||||
(define-syntax in-file
|
||||
(syntax-rules ()
|
||||
((in-file ((var) source) next . rest)
|
||||
(in-file ((var p) source) next . rest))
|
||||
((in-file ((var p) (file)) next . rest)
|
||||
(in-file ((var p) (file read-char)) next . rest))
|
||||
((in-file ((var p) (file reader)) next . rest)
|
||||
(in-file ((var p) (file reader eof-object?)) next . rest))
|
||||
((in-file ((var p) (file reader eof?)) next . rest)
|
||||
(next ((p (open-input-file file)) (r reader) (e? eof?))
|
||||
()
|
||||
((var (r p) (r p)))
|
||||
((e? var))
|
||||
()
|
||||
((close-input-port p)) . rest))))
|
||||
|
||||
|
||||
(define-syntax in-generator
|
||||
|
@ -267,7 +265,7 @@
|
|||
((accumulating :acc (kons final init) ((var cursor) ((initial i) . x)) n . rest)
|
||||
(accumulating :acc (kons final i) ((var cursor) x) n . rest))
|
||||
((accumulating :acc (kons final init) ((var cursor) (expr (if check))) n . rest)
|
||||
(n ((tmp-kons kons))
|
||||
(n :acc ((tmp-kons kons))
|
||||
((cursor init (if check (tmp-kons expr cursor) cursor)))
|
||||
()
|
||||
()
|
||||
|
@ -275,7 +273,7 @@
|
|||
((var (final cursor)))
|
||||
. rest))
|
||||
((accumulating :acc (kons final init) ((var cursor) (expr)) n . rest)
|
||||
(n ((tmp-kons kons))
|
||||
(n :acc ((tmp-kons kons))
|
||||
((cursor init (tmp-kons expr cursor)))
|
||||
()
|
||||
()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue