summaryrefslogtreecommitdiff
path: root/core.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2026-01-15 01:55:29 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2026-01-15 01:55:29 -0300
commitf753bfdffbd7ce0975b97ad44098b857f25c39a9 (patch)
tree1c6e82febdadc583eb86da2f38625d4f508a47c7 /core.lisp
parent9566e92321a1ed29a7f5903a3ba4ab16de3783b9 (diff)
downloadmonparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.tar.gz
monparser-f753bfdffbd7ce0975b97ad44098b857f25c39a9.zip
Improve usability
Diffstat (limited to 'core.lisp')
-rw-r--r--core.lisp28
1 files changed, 15 insertions, 13 deletions
diff --git a/core.lisp b/core.lisp
index 43dd234..9fef78f 100644
--- a/core.lisp
+++ b/core.lisp
@@ -25,19 +25,21 @@
(setf predicate
(normalize 'it predicate))))
(t (error (format nil "Invalid predicate: ~a." predicate))))
- `(the parser
- (lambda (start input)
- (declare (ignore start))
- (if (has-data? input)
- (let ((it (peek input)))
- (if ,predicate
- (make-parsing :tree it
- :start input
- :end (advance input))
- (make-failure :place input
- :message (format nil "Expected: ~a, Got: ~:c." ',predicate it))))
- (make-failure :place input
- :message (format nil "Reached end of input. Expected: ~a." ',predicate))))))
+ (let ((start (gensym))
+ (input (gensym)))
+ `(the parser
+ (lambda (,start ,input)
+ (declare (ignore ,start))
+ (if (has-data? ,input)
+ (let ((it (peek ,input)))
+ (if ,predicate
+ (make-parsing :tree it
+ :start ,input
+ :end (advance ,input))
+ (make-failure :place ,input
+ :message (format nil "Expected: ~a, Got: ~:c." ',predicate it))))
+ (make-failure :place ,input
+ :message (format nil "Reached end of input. Expected: ~a." ',predicate)))))))
(declaim (ftype (function (parser parser &rest parser) parser) one-of))
(defun one-of (first-parser second-parser &rest other-parsers)