diff options
Diffstat (limited to 'input.lisp')
-rw-r--r-- | input.lisp | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -5,17 +5,22 @@ (file nil :read-only t) (data nil :read-only t)) -(defun has-data? (input) - (< (input-cursor input) +(defun has-data? (input &optional (window-size 1)) + (< (+ window-size -1 (input-cursor input)) (length (input-data input)))) -(defun element (input) +(defun peek-1 (input) (char (input-data input) (input-cursor input))) -(defun advance (input) +(defun peek-n (input window-size) + (subseq (input-data input) + (input-cursor input) + window-size)) + +(defun advance (input &optional (amount 1)) (let ((new-input (copy-structure input))) - (incf (input-cursor new-input)) + (incf (input-cursor new-input) amount) new-input)) (declaim (ftype (function (simple-string) (values input &optional)) from-string)) |