mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-10 06:27:32 +02:00
Handle dotted lists
This commit is contained in:
parent
9226403da9
commit
2d5aa2c3b1
1 changed files with 13 additions and 10 deletions
23
read.scm
23
read.scm
|
@ -672,15 +672,6 @@
|
||||||
(parse fp '() '() #f #f 0 (reg-port fp)))))
|
(parse fp '() '() #f #f 0 (reg-port fp)))))
|
||||||
|
|
||||||
|
|
||||||
(define-c reading-from-file?
|
|
||||||
"(void *data, int argc, closure _, object k, object port)"
|
|
||||||
" object result = boolean_f;
|
|
||||||
Cyc_check_port(data, port);
|
|
||||||
if (((port_type *)port)->flags == 1) {
|
|
||||||
result = boolean_t;
|
|
||||||
}
|
|
||||||
return_closcall1(data, k, result);")
|
|
||||||
|
|
||||||
; ;; Test code
|
; ;; Test code
|
||||||
; ;(let ((fp (open-input-file "tests/begin.scm")))
|
; ;(let ((fp (open-input-file "tests/begin.scm")))
|
||||||
; ;(let ((fp (open-input-file "tests/strings.scm")))
|
; ;(let ((fp (open-input-file "tests/strings.scm")))
|
||||||
|
@ -693,6 +684,15 @@
|
||||||
; (repl))
|
; (repl))
|
||||||
;(repl)
|
;(repl)
|
||||||
|
|
||||||
|
(define-c reading-from-file?
|
||||||
|
"(void *data, int argc, closure _, object k, object port)"
|
||||||
|
" object result = boolean_f;
|
||||||
|
Cyc_check_port(data, port);
|
||||||
|
if (((port_type *)port)->flags == 1) {
|
||||||
|
result = boolean_t;
|
||||||
|
}
|
||||||
|
return_closcall1(data, k, result);")
|
||||||
|
|
||||||
(define-c read-token
|
(define-c read-token
|
||||||
"(void *data, int argc, closure _, object k, object port)"
|
"(void *data, int argc, closure _, object k, object port)"
|
||||||
" Cyc_io_read_token(data, k, port);")
|
" Cyc_io_read_token(data, k, port);")
|
||||||
|
@ -762,7 +762,10 @@
|
||||||
((eof-object? t)
|
((eof-object? t)
|
||||||
(error "missing closing parenthesis"))
|
(error "missing closing parenthesis"))
|
||||||
((Cyc-opaque-eq? t #\))
|
((Cyc-opaque-eq? t #\))
|
||||||
(reverse lis))
|
(if (and (> (length lis) 2)
|
||||||
|
(equal? (cadr lis) (string->symbol ".")))
|
||||||
|
(->dotted-list (reverse lis))
|
||||||
|
(reverse lis)))
|
||||||
(else
|
(else
|
||||||
(loop (cons t lis) (parse2 fp))))))
|
(loop (cons t lis) (parse2 fp))))))
|
||||||
((Cyc-opaque-unsafe-eq? token #\')
|
((Cyc-opaque-unsafe-eq? token #\')
|
||||||
|
|
Loading…
Add table
Reference in a new issue