summaryrefslogtreecommitdiff
path: root/input.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'input.lisp')
-rw-r--r--input.lisp9
1 files changed, 9 insertions, 0 deletions
diff --git a/input.lisp b/input.lisp
index 100baa5..15b8e08 100644
--- a/input.lisp
+++ b/input.lisp
@@ -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~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))))))