Skip to content

Commit

Permalink
Add gather-if*.
Browse files Browse the repository at this point in the history
It just uses gather-if-not* with COMPLEMENT, and changes default value of ACCEPT-KEY key argument.
  • Loading branch information
Ramarren committed Sep 3, 2010
1 parent 8c995a0 commit d01cbee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions greedy.lisp
Expand Up @@ -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)
Expand Down

0 comments on commit d01cbee

Please sign in to comment.