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