summaryrefslogtreecommitdiff
path: root/input.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-07 02:23:29 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-07 02:23:29 -0300
commita484c32ae01c697f002e62d17f513155c1151d60 (patch)
tree17f9e9c9a8969815917ec402871b0f399f5c1b4f /input.lisp
parent18b36cc11c208c18422a9327abd52861c165d5d3 (diff)
downloadmonparser-a484c32ae01c697f002e62d17f513155c1151d60.tar.gz
monparser-a484c32ae01c697f002e62d17f513155c1151d60.zip
Expand on alternative parsers and lookahead idea
Diffstat (limited to 'input.lisp')
-rw-r--r--input.lisp10
1 files changed, 10 insertions, 0 deletions
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))