Browse files

Add gather-if*.

It just uses gather-if-not* with COMPLEMENT, and changes default value of ACCEPT-KEY key argument.
  • Loading branch information...
1 parent 8c995a0 commit d01cbeefd17d87fc067edaa49038387d4765003e @Ramarren committed Sep 3, 2010
Showing with 7 additions and 0 deletions.
  1. +7 −0 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)

0 comments on commit d01cbee

Please sign in to comment.