I am trying to make a reader macro that would convert @this into "this". This is what I currently have:
(defun string-reader (stream char)
(declare (ignore char))
(format nil "\"~a\"" (read-line stream t nil t))
)
(set-macro-character #\@ #'string-reader )
The problem is that this requires that I put a newline after ever @this. I've also tried it with (read), but that just returns the variable test, which has not been set. I can't just hard-code the number of characters after the @ symbol, because I don't know how many there would be. Is there any way to fix this?
Edit: is the only way to do this to loop over read-char and peek-char, reading until I get to #),#\space, or #\Newline?
You can try to use
read
and then look at what it returns:Above would allow
@This
and@"This"
, but not@333
.This version just reads a string until whitespace:
Example: