From 4fdd13fd1544117f05482c260033db5759db652a Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 30 Jul 2023 08:57:24 -0700 Subject: Improved error reporting and handling --- argot.lisp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'argot.lisp') 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)) -- cgit v1.2.3