From da008e637b5bff56fed8dfbacc2adabc4bca18b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Tue, 10 Jun 2025 13:57:22 -0300 Subject: Add better reporting and new features Units report expected results on end of input. Opposite parser helps with the complexity explosion on unit parsers. Input and error printing has context. --- input.lisp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'input.lisp') diff --git a/input.lisp b/input.lisp index 55a72cb..5d6a162 100644 --- a/input.lisp +++ b/input.lisp @@ -28,10 +28,17 @@ (values line column))) (defmethod print-object ((obj parser-input) stream) - (let ((context-length 10)) + (let ((context-length 20)) (let ((begin (max (- (input-cursor obj) context-length) 0)) (end (min (+ (input-cursor obj) context-length) (length (input-data obj))))) - (format stream "...~a~a~a..." - (substitute #\¶ #\Newline (subseq (input-data obj) begin (input-cursor obj))) - (substitute #\¶ #\Newline (subseq (input-data obj) (input-cursor obj) (1+ (input-cursor obj)))) - (substitute #\¶ #\Newline (subseq (input-data obj) (1+ (input-cursor obj)) end)))))) + (when (< 0 begin) + (format stream "...")) + (format stream "~a" + (substitute #\↲ #\Newline (subseq (input-data obj) begin (input-cursor obj)))) + (if (< (input-cursor obj) (length (input-data obj))) + (format stream "~a~a" + (substitute #\↲ #\Newline (subseq (input-data obj) (input-cursor obj) (1+ (input-cursor obj)))) + (substitute #\↲ #\Newline (subseq (input-data obj) (1+ (input-cursor obj)) end))) + (format stream "¬")) + (when (< end (length (input-data obj))) + (format stream "..."))))) -- cgit v1.2.3