diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-11-08 15:06:17 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-11-08 15:06:17 -0300 |
commit | 688ade34430eb1d4d205698cae810c35c8f44d21 (patch) | |
tree | fe3e043c28eaf9beafe8f0be60c0ad6b43fe84bb /base.lisp | |
parent | 4e25074286e83a9e7b980e931284ad795361de94 (diff) | |
download | monparser-688ade34430eb1d4d205698cae810c35c8f44d21.tar.gz monparser-688ade34430eb1d4d205698cae810c35c8f44d21.zip |
Diffstat (limited to 'base.lisp')
-rw-r--r-- | base.lisp | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -13,18 +13,18 @@ (declare (ignore lazy)) (make-parsing :tree tree :left input))) -(defun bind (parser f) - (lambda (input &key lazy) - (let ((r (funcall parser input))) - (cond ((parsing-p r) - (if lazy - (lambda (ignored-input &key lazy) - (declare (ignore ignored-input)) - (funcall (funcall f (parsing-tree r) input) - (parsing-left r) - :lazy lazy)) - (funcall (funcall f (parsing-tree r) input) - (parsing-left r)))) - ((failure-p r) - r) - (t (error (format nil "Invalid return value: ~a" r))))))) +(defmacro bind (parser f) + `(lambda (input &key lazy) + (let ((r (funcall ,parser input))) + (cond ((parsing-p r) + (if lazy + (lambda (ignored-input &key lazy) + (declare (ignore ignored-input)) + (funcall (funcall ,f (parsing-tree r) input) + (parsing-left r) + :lazy lazy)) + (funcall (funcall ,f (parsing-tree r) input) + (parsing-left r)))) + ((failure-p r) + r) + (t (error (format nil "Invalid return value: ~a" r))))))) |