diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2022-12-04 23:57:17 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2022-12-04 23:57:17 -0300 |
commit | cdbfa453e870756dc32785b23a934b37e28d071c (patch) | |
tree | c04629d9c30911f2312718fc95212eb10ef7ecee /input.lisp | |
parent | f205d4c5dbd0ccb26cb9020e3ef8ae86d1336403 (diff) | |
download | monparser-cdbfa453e870756dc32785b23a934b37e28d071c.tar.gz monparser-cdbfa453e870756dc32785b23a934b37e28d071c.zip |
First advances to lookahead implementation
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)) |