summaryrefslogtreecommitdiff
path: root/extra.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2024-10-19 20:03:50 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2024-10-19 20:03:50 -0300
commit16169311d2d39d82a799fd90c77c829767842c9d (patch)
treefab553bbf2003ac132b50e41f65326c9d6051489 /extra.lisp
parenta60d9bd972f31a79aa0f0f8b10585187dc418fe8 (diff)
downloadmonparser-16169311d2d39d82a799fd90c77c829767842c9d.tar.gz
monparser-16169311d2d39d82a799fd90c77c829767842c9d.zip
Revert some changes
Diffstat (limited to 'extra.lisp')
-rw-r--r--extra.lisp30
1 files changed, 13 insertions, 17 deletions
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))