diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-04-26 19:32:50 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-04-26 19:32:50 -0500 |
commit | 7a0b5932c01779df99f3d87175be9b850031f859 (patch) | |
tree | ffbc00cdafb2827a58c1ab8f3ee609f8421103b2 /parzival.lisp | |
parent | 9beb6ee949824c3aa19dc458af0590d0389da680 (diff) |
added <<counting, <<counting+, and <whitespace+<
Diffstat (limited to 'parzival.lisp')
-rw-r--r-- | parzival.lisp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/parzival.lisp b/parzival.lisp index bedc86f..cc88725 100644 --- a/parzival.lisp +++ b/parzival.lisp @@ -425,6 +425,14 @@ the character C." (<<cons parser (<<* parser))) +(defun <<counting (parser) + "runs PARSER zero or more times, resulting in the number of times PARSER succeeded." + (<<map #'length (<<* parser))) + +(defun <<counting+ (parser) + "Runs PARSER one or more times, resulting in the number of times PARSER succeeded." + (<<map #'length (<<+ parser))) + (defun <<times (n parser) "Builds a parser that will run PARSER exactly N times, returning a list of the results." @@ -505,6 +513,8 @@ the character C." (<<def <whitespace< (<<* (<<or <space< <newline< <return< <linefeed< <tab<)) "Parses zero or more whitespace characters, returning them as a list") +(<<def <whitespace+< (<<+ (<<or <space< <newline< <return< <linefeed< <tab<)) + "Parsers at one or more whitespace characters, returning them as a list") (<<def <word< (<<to-string (<<+ <letter<)) "Parses a sequence of one or more letters characters, resulting in |