(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 "^~%")) (defun char-num-pair (ch?) (if (characterp ch?) (list ch? (char-code ch?)) ch?)) (define-condition char-error () ((line :initarg :line :reader line) (col :initarg :col :reader col) (line-num :initarg :line-num :reader line-num) (ch :initarg :ch :reader ch :initform 'yok))) (define-condition char-not-closed (char-error) () (:report (lambda (condition stream) (format stream "Karakterin kapanış sembolü ' (tek tırnak) eksik.~%Okunan karakter: ~s~%" (char-num-pair (ch condition))) (report-line (line-num condition) (line condition) (col condition) stream)))) (define-condition empty-char (char-error) () (:report (lambda (condition stream) (format stream "Boş karakter oluşturulamaz.~%") (report-line (line-num condition) (line condition) (col condition) stream)))) (defun cond-char-not-closed (line-num line token-or-col ch) (make-condition 'char-not-closed :line-num line-num :line line :col token-or-col :ch ch)) (defun cond-empty-char (line-num line token-or-col) (make-condition 'empty-char :line-num line-num :line line :col token-or-col)) (define-condition string-error () ((line :initarg :line :reader line) (col :initarg :col :reader col) (line-num :initarg :line-num :reader line-num) (content :initarg :content :reader content :initform 'yok))) (define-condition string-not-closed (string-error) () (:report (lambda (condition stream) (format stream "Metnin kapanış sembolü \" (çift tırnak) eksik.~%Okunan metin: ~s~%" (list (content condition) (length (content condition)))) (report-line (line-num condition) (line condition) (col condition) stream)))) (defun cond-string-not-closed (line-num line token-or-col &optional (content 'yok)) (make-condition 'string-not-closed :line-num line-num :line line :col token-or-col :content content)) (define-condition empty-string (string-error) () (:report (lambda (condition stream) (format stream "Boş metin oluşturulamaz.~%") (report-line (line-num condition) (line condition) (col condition) stream)))) (defun cond-empty-string (line-num line token-or-col) (make-condition 'empty-string :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)))))