From 16169311d2d39d82a799fd90c77c829767842c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sat, 19 Oct 2024 20:03:50 -0300 Subject: Revert some changes --- extra.lisp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'extra.lisp') diff --git a/extra.lisp b/extra.lisp index 2963e94..67d057c 100644 --- a/extra.lisp +++ b/extra.lisp @@ -21,9 +21,9 @@ (defun many (p) (comp ((x p) - (xs (if (not x) - (fail "Parsing result is empty.") - (optional (many p))))) + (xs (if x + (optional (many p)) + (fail "Parsing result is empty.")))) (cons x xs))) (defun repeat (p min &optional (max 0)) @@ -38,25 +38,21 @@ nothing))) (defun whitespace? (x) - (some (lambda (y) (char= x y)) '(#\Space #\Newline #\Tab))) + (some (lambda (y) (char= x y)) '(#\Space #\Newline #\Return #\Tab))) (defparameter whitespace - (comp ((_ (optional (many (unit whitespace?))))))) + (optional (many (unit whitespace?)))) -(defun separated-list (p separator &key include-separator) +(defun separated-list (p separator) (comp ((v p) (sep (optional separator)) (vn (if sep (separated-list p separator) nothing))) - (if include-separator - (cons v (cons sep vn)) - (cons v vn)))) - -(defun surrounded (left p right &key include-surrounding) - (comp ((l left) - (body p :lazy) - (r right)) - (if include-surrounding - (list l body r) - body))) + (cons v vn))) + +(defun surrounded (p left right) + (comp ((_ left) + (body p) + (_ right)) + body)) -- cgit v1.2.3