From 255aadda192c99abdaecb0caebf59a9b5272fcac Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 12 Mar 2023 13:50:31 -0700 Subject: new reader macro #>>EOF>> Signed-off-by: Sean Whitton --- src/reader.lisp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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) -- cgit v1.2.3