lib/keyword.c (kw_parseempty): Use correct variable scanning `kwval' list.
[sod] / src / parser / streams-impl.lisp
index 6094b56..b3bb424 100644 (file)
@@ -7,7 +7,7 @@
 
 ;;;----- Licensing notice ---------------------------------------------------
 ;;;
-;;; This file is part of the Sensble Object Design, an object system for C.
+;;; This file is part of the Sensible Object Design, an object system for C.
 ;;;
 ;;; SOD is free software; you can redistribute it and/or modify
 ;;; it under the terms of the GNU General Public License as published by
     (clear-input ustream)))
 
 (defmethod stream-read-sequence
-    ((stream proxy-input-stream) seq &optional (start 0) end)
+    ((stream proxy-input-stream) seq
+     #+clisp &key #-clisp &optional (start 0) end)
   (with-slots (ustream) stream
     (read-sequence seq ustream :start start :end end)))
 
     (force-output ustream)))
 
 (defmethod stream-write-sequence
-    ((stream proxy-output-stream) seq &optional (start 0) end)
+    ((stream proxy-output-stream) seq
+     #+clisp &key #-clisp &optional (start 0) end)
   (with-slots (ustream) stream
     (write-sequence seq ustream :start start :end end)))
 
 
 ;; Base class.
 
-(export '(position-aware-stream
-         position-aware-stream-line position-aware-stream-column))
-(defclass position-aware-stream (proxy-stream)
-  ((file :initarg :file :initform nil
-        :type pathname :accessor position-aware-stream-file)
-   (line :initarg :line :initform 1
-        :type fixnum :accessor position-aware-stream-line)
-   (column :initarg :column :initform 0
-          :type fixnum :accessor position-aware-stream-column))
-  (:documentation
-   "Character stream which keeps track of the line and column position.
-
-   A position-aware-stream wraps an existing character stream and tracks the
-   line and column position of the current stream position.  A newline
-   character increases the line number by one and resets the column number to
-   zero; most characters advance the column number by one, but tab advances
-   to the next multiple of eight.  (This is consistent with Emacs, at least.)
-   The position can be read using STREAM-LINE-AND-COLUMN.
-
-   This is a base class; you probably want POSITION-AWARE-INPUT-STREAM or
-   POSITION-AWARE-OUTPUT-STREAM."))
-
-(defgeneric stream-line-and-column (stream)
-  (:documentation
-   "Returns the current stream position of STREAM as line/column numbers.
-
-   Returns two values: the line and column numbers of STREAM's input
-   position.")
-  (:method ((stream stream))
-    (values nil nil))
-  (:method ((stream position-aware-stream))
-    (with-slots (line column) stream
-      (values line column))))
+(defmethod stream-line-and-column ((stream position-aware-stream))
+  (with-slots (line column) stream
+    (values line column)))
 
 (defmethod stream-pathname ((stream position-aware-stream))
-  "Return the pathname corresponding to a POSITION-AWARE-STREAM.
+  "Return the pathname corresponding to a `position-aware-stream'.
 
-   A POSITION-AWARE-STREAM can be given an explicit pathname, which is
+   A `position-aware-stream' can be given an explicit pathname, which is
    returned in preference to the pathname of the underlying stream.  This is
    useful in two circumstances.  Firstly, the pathname associated with a file
-   stream will have been subjected to TRUENAME, and may be less pleasant to
+   stream will have been subjected to `truename', and may be less pleasant to
    present back to a user.  Secondly, a name can be attached to a stream
    which doesn't actually have a file backing it."
 
-  (with-slots (file) stream
-    (or file (call-next-method))))
+  (or (position-aware-stream-file stream)
+      (call-next-method)))
 
 (defmethod file-location ((stream position-aware-stream))
   (multiple-value-bind (line column) (stream-line-and-column stream)
 
    The position is actually cached in local variables, but will be written
    back to the stream even in the case of non-local control transfer from the
-   BODY.  What won't work well is dynamically nesting WITH-POSITION forms."
+   BODY.  What won't work well is dynamically nesting `with-position' forms."
 
   (with-gensyms (line column char)
     (once-only (stream)
 
 ;; Input stream.
 
-(export 'position-aware-input-stream)
-(defclass position-aware-input-stream
-    (position-aware-stream proxy-character-input-stream)
-  ()
-  (:documentation
-   "A character input stream which tracks the input position.
-
-   This is particularly useful for parsers and suchlike, which want to
-   produce accurate error-location information."))
-
 (defmethod stream-unread-char ((stream position-aware-input-stream) char)
 
   ;; I could have written this as a :before or :after method, but I think
   (call-next-method))
 
 (defmethod stream-read-sequence
-    ((stream position-aware-input-stream) seq &optional (start 0) end)
+    ((stream position-aware-input-stream) seq
+     #+clisp &key #-clisp &optional (start 0) end)
   (declare (ignore end))
   (let ((pos (call-next-method)))
     (with-position (stream)
 
 ;; Output stream.
 
-(export 'position-aware-output-stream)
-(defclass position-aware-output-stream
-    (position-aware-stream proxy-character-output-stream)
-  ()
-  (:documentation
-   "A character output stream which tracks the output position.
-
-   This is particularly useful when generating C code: the position can be
-   used to generate `#line' directives referring to the generated code after
-   insertion of some user code."))
-
 (defmethod stream-write-sequence
-    ((stream position-aware-output-stream) seq &optional (start 0) end)
+    ((stream position-aware-output-stream) seq
+     #+clisp &key #-clisp &optional (start 0) end)
   (with-position (stream)
     (dosequence (ch seq :start start :end end)
       (update ch))