diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-12 04:31:28 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-10-12 04:31:28 -0300 |
commit | 26653bc01c3ed47983d1c618eef03ff5a73672bf (patch) | |
tree | 3c9761cd945c16132681126e72e44133077e7254 /parser.lisp | |
parent | 79d0c7ca053d2eb2dc7df5728e0696bbd11def76 (diff) | |
download | monparser-26653bc01c3ed47983d1c618eef03ff5a73672bf.tar.gz monparser-26653bc01c3ed47983d1c618eef03ff5a73672bf.zip |
Error out on (many (optional x))
Diffstat (limited to 'parser.lisp')
-rw-r--r-- | parser.lisp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/parser.lisp b/parser.lisp index 1c51c33..bfe2614 100644 --- a/parser.lisp +++ b/parser.lisp @@ -111,8 +111,8 @@ (push r intermediate-parsers)) ((parsing-p r) (when (or (not (parsing-p result)) - (> (cursor (parsing-input r)) - (cursor (parsing-input result)))) + (> (cursor (parsing-left r)) + (cursor (parsing-left result)))) (setf result r))) ((failure-p r) (when (or (failure-p result) @@ -164,7 +164,9 @@ (defun many (p) (comp ((x p) - (xs (optional (many p)))) + (xs (if (not x) + (error "Cannot define (many (optional x)). Use (optional (many x)) instead.") + (optional (many p))))) (cons x xs))) (defun repeat (p min &optional (max 0)) @@ -183,7 +185,7 @@ (defparameter whitespace (comp ((_ (optional (many (unit whitespace?))))) - nil)) + :whitespace)) (defun separated-list (p separator &key include-separator) (comp ((v p) |