diff options
-rw-r--r-- | parser.lisp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/parser.lisp b/parser.lisp index b231f14..5495f74 100644 --- a/parser.lisp +++ b/parser.lisp @@ -70,15 +70,13 @@ `(new (progn ,@body)) (let ((v (first (car bindings))) (p (second (car bindings)))) - (if (eq 'symbol (type-of v)) + (if (symbolp v) (if (string= (symbol-name v) "_") `(discarding-bind ,p (lambda () (comp ,(cdr bindings) ,@body))) `(bind ,p (lambda (,v) (comp ,(cdr bindings) ,@body)))) - (if (and (eq 'cons (type-of v)) - (eq 'symbol (type-of (car v))) - (eq 'symbol (type-of (cdr v)))) + (if (and (consp v) (symbolp (car v)) (symbolp (cdr v))) `(bind-with-input ,p (lambda (,(car v) ,(cdr v)) (comp ,(cdr bindings) ,@body))) - (error "Binding name/(name,input) must be either a symbol or a cons of symbols.")))))) + (error "Binding must be either a symbol or a cons of symbols.")))))) (defun one-of (first-parser second-parser &rest other-parsers) (lambda (input &optional lazy) @@ -96,7 +94,8 @@ (cursor (parsing-input result)))) (setf result r))) ((failure-p r) - (when (failure-p result) + (when (or (failure-p result) + (= (length parsers) 1)) (setf result r)))))) (if intermediate-parsers (one-of-rec intermediate-parsers) |