Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 57 lines (46 sloc) 1.37 KB
;scanner functions (define char-buffer '()) (define token-buffer '()) (define init-scanner (lambda () (set! char-buffer '()))) (define save-char (lambda (char) (set! char-buffer char))) (define next-char (lambda () (cond [(null? char-buffer) (display-and-return (read-char))] [else (let ((char char-buffer)) (begin (set! char-buffer '()) char))]))) (define display-and-return (lambda (char) (begin (display char) char))) (define space? (lambda (char) (or (eq? char #\space) (eq? char #\newline)))) (define letter? (lambda (char) (and (>= (char->integer char) (char->integer #\A)) (<= (char->integer char) (char->integer #\Z))))) (define digit? (lambda (char) (or (eq? char #\0) (eq? char #\1) (eq? char #\2) (eq? char #\3) (eq? char #\4) (eq? char #\5) (eq? char #\6) (eq? char #\7) (eq? char #\8) (eq? char #\9)))) (define symbol? (lambda (char) (or (eq? char #\~) (eq? char #\;) (eq? char #\+) (eq? char #\-) (eq? char #\*) (eq? char #\/) (eq? char #\&) (eq? char #\|) (eq? char #\>) (eq? char #\<) (eq? char #\=) (eq? char #\() (eq? char #\)) (eq? char #\.)))) (define char->num (lambda (char) (cond [(digit? char) (string->number (make-string 1 char))] [else (error "non-digit argument to char->num")])))
Something went wrong with that request. Please try again.