From a484c32ae01c697f002e62d17f513155c1151d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Wed, 7 Dec 2022 02:23:29 -0300 Subject: Expand on alternative parsers and lookahead idea --- input.lisp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'input.lisp') diff --git a/input.lisp b/input.lisp index 1900459..2cdfd84 100644 --- a/input.lisp +++ b/input.lisp @@ -18,11 +18,21 @@ (input-cursor input) (+ window-size (input-cursor input)))) +(defun peek-rest (input) + (subseq (input-data input) + (input-cursor input) + (length (input-data input)))) + (defun advance (input &optional (amount 1)) (let ((new-input (copy-structure input))) (incf (input-cursor new-input) amount) new-input)) +(defun advance-to-end (input) + (let ((new-input (copy-structure input))) + (setf (input-cursor new-input) (length (input-data input))) + new-input)) + (declaim (ftype (function (simple-string) (values input &optional)) from-string)) (defun from-string (str) (make-input :data str)) -- cgit v1.2.3