summaryrefslogtreecommitdiff
path: root/extra.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'extra.lisp')
-rw-r--r--extra.lisp23
1 files changed, 12 insertions, 11 deletions
diff --git a/extra.lisp b/extra.lisp
index 9451ce8..20a13b1 100644
--- a/extra.lisp
+++ b/extra.lisp
@@ -11,7 +11,7 @@
(push name name-list)
(push `(,name (unit ,c)) binding-list))))
`(comp ,(reverse binding-list)
- (coerce ,(cons 'list (reverse name-list)) 'string))))
+ ,(cons 'list (reverse name-list)))))
(defparameter nothing
(new nil))
@@ -19,27 +19,28 @@
(defun optional (p)
(one-of p nothing))
-(defun many (p)
+(defun many (p &key all)
(comp ((x p)
- (xs (optional (many p))))
- (if x (cons x xs) xs)))
+ (xs (if all
+ (one-of end
+ (many p :all all))
+ (optional (many p)))))
+ (if x (cons x xs) xs)))
(defun repeat (p min &optional (max 0))
(if (> min 0)
(comp ((x p)
(xs (repeat p (1- min) (1- max))))
- (cons x xs))
+ (cons x xs))
(if (> max 0)
(comp ((x (optional p))
(xs (repeat p 0 (if x (1- max) 0))))
- (if x (cons x xs) x))
+ (if x (cons x xs) x))
nothing)))
(defun whitespace? (x)
- (some (lambda (y) (char= x y)) '(#\Space #\Newline #\Return #\Tab)))
-
-(defparameter whitespace
- (optional (many (unit whitespace?))))
+ (or (char= x #\Space)
+ (not (graphic-char-p x))))
(defun separated-list (p separator)
(comp ((v p)
@@ -47,4 +48,4 @@
(vn (if sep
(separated-list p separator)
nothing)))
- (cons v vn)))
+ (cons v vn)))