diff options
Diffstat (limited to 'parser.lisp')
-rw-r--r-- | parser.lisp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/parser.lisp b/parser.lisp index 2fe6f67..b231f14 100644 --- a/parser.lisp +++ b/parser.lisp @@ -85,14 +85,19 @@ (declare (ignore lazy)) (labels ((one-of-rec (parsers) (let ((intermediate-parsers '()) - (result (make-failure :place input - :message "Exausted options."))) + (result nil)) (dolist (p parsers) (let ((r (funcall p input (> (length parsers) 1)))) (cond ((functionp r) (push r intermediate-parsers)) ((parsing-p r) - (setf result r))))) + (when (or (not (parsing-p result)) + (> (cursor (parsing-input r)) + (cursor (parsing-input result)))) + (setf result r))) + ((failure-p r) + (when (failure-p result) + (setf result r)))))) (if intermediate-parsers (one-of-rec intermediate-parsers) result)))) |