summaryrefslogtreecommitdiff
path: root/errors.lisp
diff options
context:
space:
mode:
authormRnea <akannemre@gmail.com>2024-08-24 00:43:43 +0300
committermRnea <akannemre@gmail.com>2024-08-24 00:43:43 +0300
commit0f953a0a2fc0abf6b27b283fe2e28c091bfc3e99 (patch)
tree4be394dbf61dfb5f3e570bc42db8179860447c81 /errors.lisp
parent3fc13bcdddd09065a9dae1ec054ab8af56c95109 (diff)
basic error reporting to character and string literalsHEADmaster
Diffstat (limited to 'errors.lisp')
-rw-r--r--errors.lisp54
1 files changed, 49 insertions, 5 deletions
diff --git a/errors.lisp b/errors.lisp
index 2f955ca..efff1d5 100644
--- a/errors.lisp
+++ b/errors.lisp
@@ -8,16 +8,60 @@
(write-char #\Space stream))
(format stream "^~%"))
-(define-condition char-not-closed ()
+(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))
+ (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 "Karakterin kapanış sembolü ' eksik.~%")
+ (format stream "Boş karakter oluşturulamaz.~%")
(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))
+(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))