chickadee » prcc » pred

pred PARSER0 PARSER1procedure

Lookahead predicate PARSER1.

Example:

(parse-string "a" (pred (char #\a) (eof)))
=> "a"
;; If we had used (seq), we would get '("a" "")

;; This also allows us to ensure this is the entire string:
(parse-string "ab" (pred (char #\a) (eof)))
=> #f

;; Without the lookahead, it will simply consume as much as possible:
(parse-string "ab" (char #\a))
=> "a"