From d01cbeefd17d87fc067edaa49038387d4765003e Mon Sep 17 00:00:00 2001 From: Ramarren Date: Fri, 3 Sep 2010 16:14:58 +0200 Subject: [PATCH] Add gather-if*. It just uses gather-if-not* with COMPLEMENT, and changes default value of ACCEPT-KEY key argument. --- greedy.lisp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/greedy.lisp b/greedy.lisp index 3133654..8f2b358 100644 --- a/greedy.lisp +++ b/greedy.lisp @@ -203,6 +203,13 @@ :tree (when result-type (coerce result result-type)) :suffix new-input))))) +(defun gather-if* (predicate &key (result-type 'list) (accept-end t) (accept-empty nil)) + "Non-backtracking parser: Find a sequence of tokens for which predicate returns true." + (gather-if-not* (complement predicate) + :result-type result-type + :accept-end accept-end + :accept-empty accept-empty)) + (defun gather-before-token* (token &key (result-type 'list) (test #'eql) (accept-end nil) (accept-empty nil)) "Non-backtracking parser: Find a sequence of tokens terminated by single token, which is not consumed." (gather-if-not* #'(lambda (input-token)