summaryrefslogtreecommitdiff
path: root/main.lisp
blob: 0d890a0d7f6371373b33f7cea6aa11dfc659d89e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(in-package #:monparser)

(defun parse (parser data)
  (let* ((result (funcall parser
                          (make-instance 'parser-input
                                         :cursor 0
                                         :data data))))
    (if (parsing-p result)
      (let ((finished? (not (has-data? (parsing-left result)))))
        (values (parsing-tree result) finished?))
      (error (format nil "~a" result)))))

(defmethod print-object ((obj failure) stream)
  (multiple-value-bind (line column) (line-and-column (failure-place obj))
    (format stream "~a:~a: ~a" line column (failure-message obj))))