-(defun skip-comment (stream)
- "Skip to the end of a comment, that is, to the end of the line.
+;;--- Collect the comment so we can attach it to its associated object
+(defun maybe-skip-comments (stream)
+ "If what appears next in the stream is a comment, skip it and any following comments,
+ then skip any following whitespace."
+ (loop
+ (unless (eql (peek-char nil stream nil) #\/)
+ (return)
+ (read-char stream)
+ (case (peek-char nil stream nil)
+ ((#\/)
+ (skip-line-comment stream))
+ ((#\*)
+ (skip-block-comment stream))
+ (otherwise
+ (error "Found a '~C' at position ~D to start a comment, but no following '~C' or '~C'"
+ #\/ (file-position stream) #\/ #\*)))))
+ (skip-whitespace stream))
+
+(defun skip-line-comment (stream)
+ "Skip to the end of a line comment, that is, to the end of the line.