]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Changed charport to return a stream of charobjs that contain position data along...
authorMike D. Lowis <mike@mdlowis.com>
Wed, 15 Aug 2012 17:44:18 +0000 (13:44 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Wed, 15 Aug 2012 17:44:18 +0000 (13:44 -0400)
source/charport.scm [new file with mode: 0644]
source/parse-utils.scm

diff --git a/source/charport.scm b/source/charport.scm
new file mode 100644 (file)
index 0000000..fc4c975
--- /dev/null
@@ -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)))
+
+
index 0d82c91654aa7964cb881cc0a605572f21bd52ee..3ee3d51cb851727f9b00129a47db95851da13ac1 100644 (file)
@@ -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