diff options
-rw-r--r-- | input.lisp | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -29,3 +29,12 @@ (setf column 1)) (t (incf column))))) (values line column))) + +(defmethod print-object ((obj parser-input) stream) + (let ((context-length 10)) + (let ((begin (max (- (input-cursor obj) context-length) 0)) + (end (min (+ (input-cursor obj) context-length) (length (input-data obj))))) + (format stream "...~a[1;33m~a[m~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)))))) |