From: Mike D. Lowis Date: Wed, 15 Aug 2012 17:44:18 +0000 (-0400) Subject: Changed charport to return a stream of charobjs that contain position data along... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a7313156d8568551f41c777d1fed193962d1b790;p=archive%2Fdlang-scm.git Changed charport to return a stream of charobjs that contain position data along with the real char --- diff --git a/source/charport.scm b/source/charport.scm new file mode 100644 index 0000000..fc4c975 --- /dev/null +++ b/source/charport.scm @@ -0,0 +1,19 @@ +(declare (unit charport)) +;(define (charport-read chprt) +; (define ch (read-char (charport-port chprt))) +; (cond +; ((eof-object? ch)) ; Do nothing for EOFs +; ((char=? ch #\newline) +; (charport-line-set! chprt (+ 1 (charport-line chprt))) +; (charport-column-set! chprt 1)) +; (else +; (charport-column-set! chprt (+ 1 (charport-column chprt))))) +; (charobj ch (charport-posdata chprt)) +; +;(define (charport-posdata chprt) +; (posdata +; (port-name (charport-port chprt)) +; (charport-line chprt) +; (charport-column chprt))) + + diff --git a/source/parse-utils.scm b/source/parse-utils.scm index 0d82c91..3ee3d51 100644 --- a/source/parse-utils.scm +++ b/source/parse-utils.scm @@ -38,6 +38,9 @@ (syntree=? (car ch1) (car ch2)) (syntree-children=? (cdr ch1) (cdr ch2)))))) +(define-record charobj char pos) +(define charobj make-charobj) + (define (charport-read chprt) (define ch (read-char (charport-port chprt))) (cond @@ -47,7 +50,7 @@ (charport-column-set! chprt 1)) (else (charport-column-set! chprt (+ 1 (charport-column chprt))))) - ch) + (if (eof-object? ch) ch (charobj ch (charport-posdata chprt)))) (define (charport-posdata chprt) (posdata