X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/dea4d05507e59ab779ed4bb209e05971d87e260c..bf090e021a5c20da452a4841cdfb8eb78e29544e:/src/parser/proto-scanner.lisp diff --git a/src/parser/proto-scanner.lisp b/src/parser/proto-scanner.lisp index 87a382e..966c77c 100644 --- a/src/parser/proto-scanner.lisp +++ b/src/parser/proto-scanner.lisp @@ -44,8 +44,8 @@ (defclass scanner-context () state. So the scanner context is a compile-time context which expands to calls to use the run-time scanner. See? - This class provides common compile-time behaviour for PARSER-AT-EOF-P and - friends by invoking corresponding methods on the scanner object at + This class provides common compile-time behaviour for `parser-at-eof-p' + and friends by invoking corresponding methods on the scanner object at run-time.")) ;;;-------------------------------------------------------------------------- @@ -190,8 +190,8 @@ (defstruct token-scanner-place (next nil :type (or token-scanner-place null)) (type nil :read-only t) (value nil :read-only t) - (line 1 :type fixnum :read-only t) - (column 0 :type fixnum :read-only t)) + (line 1 :type (or fixnum null) :read-only t) + (column 0 :type (or fixnum null) :read-only t)) ;; The token scanner base class and parser context. @@ -201,7 +201,7 @@ (defclass token-scanner () (value :reader token-value) (captures :initform 0 :type fixnum) (tail :initform nil :type (or token-scanner-place null)) - (filename :initarg filename :type string :reader scanner-filename) + (filename :initarg :filename :type string :reader scanner-filename) (line :initarg :line :initform 1 :type fixnum :accessor scanner-line) (column :initarg :column :initform 0 :type fixnum :accessor scanner-column)) @@ -255,4 +255,15 @@ (defclass character-scanner-stream (fundamental-character-input-stream) `stream-read-sequence' and `stream-read-line' in a scanner-specific manner.")) +(export 'make-scanner-stream) +(defgeneric make-scanner-stream (scanner) + (:documentation + "Return a stream which reads from the SCANNER. + + The default method simply constructs a `character-scanner-stream' + instance. Subclasses of `character-scanner' can override this method in + order to return instances of more efficient stream subclasses.") + (:method ((scanner character-scanner)) + (make-instance 'character-scanner-stream :scanner scanner))) + ;;;----- That's all, folks --------------------------------------------------