diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-19 20:03:50 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-19 20:03:50 -0300 |
commit | 16169311d2d39d82a799fd90c77c829767842c9d (patch) | |
tree | fab553bbf2003ac132b50e41f65326c9d6051489 /core.lisp | |
parent | a60d9bd972f31a79aa0f0f8b10585187dc418fe8 (diff) | |
download | monparser-16169311d2d39d82a799fd90c77c829767842c9d.tar.gz monparser-16169311d2d39d82a799fd90c77c829767842c9d.zip |
Revert some changes
Diffstat (limited to 'core.lisp')
-rw-r--r-- | core.lisp | 34 |
1 files changed, 14 insertions, 20 deletions
@@ -1,7 +1,7 @@ (in-package #:monparser) (defun fail (message) - (lambda (input &key limit lazy) + (lambda (input &key lazy) (make-failure :place input :message message))) (defmacro unit (&optional predicate) @@ -20,20 +20,18 @@ (and (symbolp x) (string-equal (symbol-name x) "IT"))) predicate)))) (t (error (format nil "Invalid predicate: ~a." predicate)))) - `(lambda (input &key limit lazy) + `(lambda (input &key lazy) (declare (ignore lazy)) - (if (and limit (<= limit 0)) - (make-failure :place input :message "Reached established limit.") - (if (has-data? input) - (let ((it (peek input))) - (if ,predicate - (make-parsing :tree it :left (advance input) :limit (if limit (1- limit))) - (make-failure :place input - :message (format nil "Expected: ~a, Got: ~a" ',predicate it)))) - (make-failure :place input :message "Reached end of input."))))) + (if (has-data? input) + (let ((it (peek input))) + (if ,predicate + (make-parsing :tree it :left (advance input)) + (make-failure :place input + :message (format nil "Expected: ~a, Got: ~a" ',predicate it)))) + (make-failure :place input :message "Reached end of input.")))) (defun one-of (first-parser second-parser &rest other-parsers) - (lambda (input &key limit lazy) + (lambda (input &key lazy) (declare (ignore lazy)) (labels ((one-of-rec (parsers) (let ((intermediate-parsers '()) @@ -42,8 +40,7 @@ (dolist (p parsers) (let ((r (funcall p input - :lazy (> (length parsers) 1) - :limit limit))) + :lazy (> (length parsers) 1)))) (cond ((functionp r) (push r intermediate-parsers)) ((parsing-p r) @@ -73,17 +70,14 @@ `(bind ,parser (lambda (&rest ,unused) (declare (ignore ,unused)) - (comp ,(cdr bindings) ,@body)) - :greedy ,(not lazy)) + (comp ,(cdr bindings) ,@body))) `(bind ,parser (lambda (,var &rest ,unused) (declare (ignore ,unused)) - (comp ,(cdr bindings) ,@body)) - :greedy ,(not lazy))) + (comp ,(cdr bindings) ,@body)))) (if (and (consp var) (symbolp (car var)) (symbolp (cdr var))) `(bind ,parser (lambda (,(car var) ,(cdr var) &rest ,unused) (declare (ignore ,unused)) - (comp ,(cdr bindings) ,@body)) - :greedy ,(not lazy)) + (comp ,(cdr bindings) ,@body))) (error "Binding must be either a symbol or a cons of symbols.")))))) |