summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-06 18:03:14 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-06 18:03:14 -0300
commit18b36cc11c208c18422a9327abd52861c165d5d3 (patch)
treebe6618440d0129fe45f84f5bb715206bbe51f2b3
parent1d6874e060fce727616017f73149bef197f69d7b (diff)
downloadmonparser-18b36cc11c208c18422a9327abd52861c165d5d3.tar.gz
monparser-18b36cc11c208c18422a9327abd52861c165d5d3.zip
Reduce iterators with optional and many
-rw-r--r--parser.lisp10
1 files changed, 2 insertions, 8 deletions
diff --git a/parser.lisp b/parser.lisp
index 2da9975..989938b 100644
--- a/parser.lisp
+++ b/parser.lisp
@@ -84,15 +84,9 @@
(defun optional (p)
(either p nothing))
-(defun zero-or-more (p)
- (either (comp ((x p)
- (xs (zero-or-more p)))
- (cons x xs))
- nothing))
-
-(defun one-or-more (p)
+(defun many (p)
(comp ((x p)
- (xs (zero-or-more p)))
+ (xs (optional (many p))))
(cons x xs)))
(defun separated-list (p separator)