Permalink
Browse files

Add HOOK?

  • Loading branch information...
1 parent cb7f750 commit 7679c36a0f6d087effeaa7eb8b6c62dbe3b099d6 @Ramarren committed Jan 16, 2011
Showing with 10 additions and 0 deletions.
  1. +1 −0 package.lisp
  2. +5 −0 parsers.lisp
  3. +4 −0 test-parsers.lisp
View
1 package.lisp
@@ -81,6 +81,7 @@
#:find-after*
#:find*
#:find?
+ #:hook?
#:parse-string*
#:find-before?
#:find-before*
View
5 parsers.lisp
@@ -418,6 +418,11 @@ parsers."
(with-parsers (q)
(find-after? (item) q)))
+(defun hook? (function p)
+ "Parser: apply function to result of p"
+ (with-parsers (p)
+ (named-seq? (<- result p) (funcall function result))))
+
(defun expression? (term operators &optional (bracket-left nil) (bracket-right nil))
"Parser: Reduce a sequence of terms with unary/binary operators with precedence.
OPERATORS is a list of (op-parser :left/:right/:unary), where OP-PARSER is a parser consuming
View
4 test-parsers.lisp
@@ -260,3 +260,7 @@
(list a 'b c))
("abc" '(#\a b #\c))
("acb"))
+
+(defparsertest test-hook? (hook? #'1+ (nat*))
+ ("5" 6 "28" 29)
+ ("aa"))

0 comments on commit 7679c36

Please sign in to comment.