aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reader.lisp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/reader.lisp b/src/reader.lisp
index 48fd878..e4f15b9 100644
--- a/src/reader.lisp
+++ b/src/reader.lisp
@@ -17,10 +17,25 @@
(in-package :consfigurator)
+(defun read-heredoc (stream char arg)
+ "Like CL-HEREDOC:READ-HEREDOC but treat #>EOF> and #>>EOF>> differently:
+#>>EOF>> skips over the remainder of the current line and its newline.
+For the sake of future extension, the remainder of the line after the #>>EOF>>
+should not contain anything other than a single-line comment."
+ (if (char= (peek-char nil stream t :eof t) char)
+ ;; #>>EOF>> -- ignore the rest of the line.
+ (progn (read-char stream t :eof t)
+ (let* ((delim (make-string 2 :initial-element char))
+ (ender (cl-heredoc:read-until-match stream delim)))
+ (read-line stream t :eof t)
+ (cl-heredoc:read-until-match stream ender)))
+ ;; #>EOF> -- just use the normal READ-HEREDOC.
+ (cl-heredoc:read-heredoc stream char arg)))
+
(named-readtables:defreadtable :consfigurator
(:merge :standard)
(:dispatch-macro-char #\# #\? #'cl-interpol:interpol-reader)
- (:dispatch-macro-char #\# #\> #'cl-heredoc:read-heredoc))
+ (:dispatch-macro-char #\# #\> #'read-heredoc))
(named-readtables:defreadtable :consfigurator.without-read-eval
(:merge :consfigurator)