summaryrefslogtreecommitdiff
path: root/core.lisp
diff options
context:
space:
mode:
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)