aboutsummaryrefslogtreecommitdiff
path: root/argot.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-07-30 08:57:24 -0700
committercolin <colin@cicadas.surf>2023-07-30 08:57:24 -0700
commit4fdd13fd1544117f05482c260033db5759db652a (patch)
tree1784bfcf28307abdbc470418b6f6bfce05cd6923 /argot.lisp
parent9289f299cffe96f87483064e71c60fb7da0cb0ad (diff)
Improved error reporting and handling
Diffstat (limited to 'argot.lisp')
-rw-r--r--argot.lisp7
1 files changed, 5 insertions, 2 deletions
diff --git a/argot.lisp b/argot.lisp
index c2b3556..ec5f9b8 100644
--- a/argot.lisp
+++ b/argot.lisp
@@ -19,7 +19,9 @@
:initform "")))
(define-condition invalid-rule-def (error)
- ((rule :reader rule :initarg :rule)))
+ ((rule :reader rule :initarg :rule))
+ (:report (lambda (e stream)
+ (format stream "The rule ~s is malformed." (car (rule e))))))
(defun include-rule (grammar rule)
(setf (gethash (rule-lhs rule) (grammar-rules grammar)) rule))
@@ -140,7 +142,8 @@ and it returns VAR in that case."
:start-rule ',(first (first ruledefs))))
,@(loop
:for ruledef :in ruledefs
- :for (lhs pattern vars check action) := (parse-rule-def ruledef)
+ :for (lhs pattern vars check action) := (handler-case (parse-rule-def ruledef)
+ (invalid-rule-def (e) (invoke-debugger e)))
:for bindings := (collect-let-bindings lhs vars)
:collect (rule-includer name lhs pattern check action bindings))