aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-03-12 13:50:31 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-03-12 14:02:35 -0700
commit255aadda192c99abdaecb0caebf59a9b5272fcac (patch)
tree50cd0bcf460bf7d50f2cf2cd1898f6ed8815964e /src
parenta72ecfcf529624df02890b73368ea3e2826d1d0d (diff)
downloadconsfigurator-255aadda192c99abdaecb0caebf59a9b5272fcac.tar.gz
new reader macro #>>EOF>>
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
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)