*** empty log message ***

original commit: 12d65914f68bdb255ee8071688a246f0b404b893
tokens
Scott Owens 23 years ago
parent 7c6dde5a62
commit 19559b74b4

@ -84,6 +84,7 @@
;; run the calculator on the given input-port ;; run the calculator on the given input-port
(define (calc ip) (define (calc ip)
(port-count-lines! ip)
(letrec ((one-line (letrec ((one-line
(lambda () (lambda ()
(let ((result (calcp (lambda () (calcl ip))))) (let ((result (calcp (lambda () (calcl ip)))))
@ -91,4 +92,4 @@
(begin (begin
(printf "~a~n" result) (printf "~a~n" result)
(one-line))))))) (one-line)))))))
(one-line)))) (one-line)))

@ -12,7 +12,7 @@
(define-tokens data (DATUM)) (define-tokens data (DATUM))
(define-empty-tokens delim (OP CP HASHOP QUOTE QUASIQUOTE UNQUOTE UNQUOTE-SPLICING DOT EOF)) (define-empty-tokens delim (OP CP HASHOP QUOTE QUASIQUOTE UNQUOTE UNQUOTE-SPLICING DOT EOF))
(define scheme-lexer (define scheme-lexer
(lexer-src-pos (lexer-src-pos
@ -53,10 +53,10 @@
(define-lex-abbrevs (define-lex-abbrevs
[any (- #\000 #\377)] [any (- #\000 #\377)]
[letter (: (- a z) (- A Z))] [letter (: (- a z) (- #\A #\Z))]
[digit (- #\0 #\9)] [digit (- #\0 #\9)]
[whitespace (: #\newline #\return #\tab #\space #\vtab)] [whitespace (: #\newline #\return #\tab #\space #\vtab)]
[initial (: (letter) ! $ % & * / : < = > ? ^ _ ~)] [initial (: (letter) ! $ % & * / : < = > ? ^ _ ~ @)]
[subsequent (: (initial) (digit) + - #\. @)] [subsequent (: (initial) (digit) + - #\. @)]
[comment (@ #\; (* (^ #\newline)) #\newline)] [comment (@ #\; (* (^ #\newline)) #\newline)]
@ -191,8 +191,8 @@
#f #f
value value
(list source (list source
(position-line start-pos) (add1 (position-line start-pos))
(position-col start-pos) (add1 (position-col start-pos))
(position-offset start-pos) (position-offset start-pos)
(- (position-offset end-pos) (- (position-offset end-pos)
(position-offset start-pos))) (position-offset start-pos)))
@ -233,12 +233,13 @@
[(sexp-list sexp) (cons $2 $1)])))) [(sexp-list sexp) (cons $2 $1)]))))
(define (rs sn ip off) (define (rs sn ip off)
((scheme-parser sn) (lambda () (scheme-lexer ip))))) (port-count-lines! ip)
((scheme-parser sn) (lambda () (scheme-lexer ip))))
(define readsyntax (define readsyntax
(case-lambda ((sn) (rs sn (current-input-port) (list 0 0 0))) (case-lambda ((sn) (rs sn (current-input-port) (list 0 0 0)))
((sn ip) (rs sn ip (list 0 0 0))) ((sn ip) (rs sn ip (list 0 0 0)))
((sn ip off) (rs sn ip off)))) ((sn ip off) (rs sn ip off))))
(provide (rename readsyntax read-syntax)) (provide (rename readsyntax read-syntax))

Loading…
Cancel
Save