summaryrefslogtreecommitdiff
path: root/errors.lisp
blob: 2f955ca24e51122f5b35440189dac075d8b43e0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(in-package :kurt)

(defun report-line (line-num line col? &optional (stream t))
  (format stream "~5a:~a~%" line-num line)
  (iter (for i from 0 below (+ 6 (if (consp col?)
                                     (getf (cdr col?) :col) ;; if token get col
                                     col?)))
        (write-char #\Space stream))
  (format stream "^~%"))

(define-condition char-not-closed ()
  ((line :initarg :line :reader line)
   (col :initarg :col :reader col)
   (line-num :initarg :line-num :reader line-num))
  (:report (lambda (condition stream)
             (format stream "Karakterin kapanış sembolü ' eksik.~%")
             (report-line (line-num condition) (line condition) (col condition) stream))))

(defun handle-char-not-closed (line-num line token-or-col)
  (make-condition 'char-not-closed :line-num line-num :line line :col token-or-col))

;; (define-condition op-not-implemented (style-warning)
;;   ((undef-ops :initarg :ops :reader undef-ops))
;;   (:report (lambda (condition stream)
;;              (format stream "These ops are not defined in op-case: ~s"
;;                      (undef-ops condition)))))