From f753bfdffbd7ce0975b97ad44098b857f25c39a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Thu, 15 Jan 2026 01:55:29 -0300 Subject: Improve usability --- core.lisp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'core.lisp') 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) -- cgit v1.2.3