diff options
Diffstat (limited to 'core.lisp')
| -rw-r--r-- | core.lisp | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -69,13 +69,15 @@ (defun optional (p) (one-of p nothing)) -(declaim (ftype (function (parser &key (:all t)) parser) many)) -(defun many (p &key all) +(declaim (ftype (function (parser &key (:all t) (:until parser)) parser) many)) +(defun many (p &key all until) (lambda (input) (let ((result '())) - (do ((r (funcall p (cursor-rebase input)) (funcall p (result-place r)))) + (do ((end? (if until (funcall until (cursor-rebase input))) (if until (funcall until (result-place r)))) + (r (funcall p (cursor-rebase input)) (funcall p (result-place r)))) ((or (failure-p r) - (cursor-at-start? (result-place r))) + (cursor-at-start? (result-place r)) + (parsing-p end?)) (cond ((or (null result) (and all (cursor-has-data? (result-place (first result))))) (if (failure-p r) |
