diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2022-12-26 22:05:47 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2022-12-26 22:05:47 -0300 |
commit | d63d9d6d881a67bd132b1f55000fe4dc54491173 (patch) | |
tree | 4dbd115c473f7d9659c6bbe2dc206c400ae179fb /parser.lisp | |
parent | 6b8e45d89b22ed51751dc976068a0e0350edff4d (diff) | |
download | monparser-d63d9d6d881a67bd132b1f55000fe4dc54491173.tar.gz monparser-d63d9d6d881a67bd132b1f55000fe4dc54491173.zip |
Fix crash where mutually recursive parsers are involved
Diffstat (limited to 'parser.lisp')
-rw-r--r-- | parser.lisp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/parser.lisp b/parser.lisp index 7567b1f..c07120d 100644 --- a/parser.lisp +++ b/parser.lisp @@ -29,11 +29,11 @@ (funcall (funcall f (parsing-tree r)) (parsing-left r)) r)))) -(defun discarding-bind (p q) +(defun discarding-bind (p f) (lambda (input) (let ((r (funcall p input))) (if (parsing-p r) - (funcall q (parsing-left r)) + (funcall (funcall f) (parsing-left r)) r)))) (defmacro comp (bindings &body body) @@ -42,7 +42,7 @@ (let ((v (first (car bindings))) (p (second (car bindings)))) (if (string= (symbol-name v) "_") - `(discarding-bind ,p (comp ,(cdr bindings) ,@body)) + `(discarding-bind ,p (lambda () (comp ,(cdr bindings) ,@body))) `(bind ,p (lambda (,v) (comp ,(cdr bindings) ,@body))))))) (defun fail (&optional (message "Unknown error.")) |