diff options
author | colin <colin@cicadas.surf> | 2023-07-30 08:57:24 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-07-30 08:57:24 -0700 |
commit | 4fdd13fd1544117f05482c260033db5759db652a (patch) | |
tree | 1784bfcf28307abdbc470418b6f6bfce05cd6923 /argot.lisp | |
parent | 9289f299cffe96f87483064e71c60fb7da0cb0ad (diff) |
Improved error reporting and handling
Diffstat (limited to 'argot.lisp')
-rw-r--r-- | argot.lisp | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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)) |