read-sw

John D. Ramsdell

Date: 90/07/12 08:57:36

read-sw converts SchemeWEB representations of Scheme objects into the objects themselves much as read does. (define (read-sw . rest) ; Returns what read returns. (let ((port (if (pair? rest) ; read-sw arguments are (car rest) ; the same as read's. (current-input-port)))) (letrec ((text-mode-and-saw-newline ; Lines of a SchemeWEB file (lambda () ; beginning with ``('', (let ((ch (peek-char port))) ; start a code section. (cond ((eof-object? ch) ch) ((char=? ch # );Ifcodesection, thenuse(got - code(readport)));readtogetcode,(else;elseskipthislineasit(text - mode - within - a - line))))));isacomment.(text - mode - within - a - line(lambda();Ignorecomments.(let((ch(read - charport)))(cond ((eof - object?ch)ch)((char = ?ch#
)(text - mode - and - saw - newline))(else(text - mode - within - a - line))))))(got - code(lambda(code);Ignoretheremainderofthe(let((ch(read - charport)));lastcodelineandreturn(cond ((eof - object?ch)code);theresultsofread.((char = ?ch#
)code)(else(got - codecode)))))))(text - mode - and - saw - newline);Startbylooking)));foracodeline.