diff options
Diffstat (limited to 'base.lisp')
-rw-r--r-- | base.lisp | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -6,25 +6,26 @@ (defstruct failure place - message) + (message "") + (priority 0)) + +(defmethod print-object ((obj failure) stream) + (if (failure-place obj) + (multiple-value-bind (line column) (line-and-column (failure-place obj)) + (format stream "~a:~a: ~a~&~a~&" + line column (failure-message obj) (failure-place obj))) + (format stream "~a~&" (failure-message obj)))) (defun new (tree) - (lambda (input &key lazy) - (declare (ignore lazy)) + (lambda (input) (make-parsing :tree tree :left input))) (defun bind (parser f) - (lambda (input &key lazy) + (lambda (input) (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)))) + (funcall (funcall f (parsing-tree r) input) + (parsing-left r))) ((failure-p r) r) (t (error (format nil "Invalid return value: ~a" r))))))) |