#-:triple-quoted-typedoc (defun read-tdl-type-comment (istream name) ;;; enclosed in """..."""s as in Python - called when we've just peeked a " (let ((start-position (file-position istream))) ; record in case the comment isn't closed ;; first read the peeked double quote, and then the only legal following characters are ;; two more double quotes (read-char istream) (cond ((and (eql (read-char istream nil 'eof) #\") (eql (read-char istream nil 'eof) #\"))) (t (lkb-read-cerror istream "Need three double-quote marks for type comment for ~A (comment start at ~A)" name start-position))) ;; accumulate characters until encountering 3 consecutive non-escaped double quotes ;; !!! this is not a general Python string reader: only \newline, \\, \' and \" are ;; recognised as escape sequences (loop for c = (read-char istream nil 'eof) with ndouble = 0 with chars = nil do (block do (case c (eof (lkb-read-cerror istream "File ended in middle of type comment for ~A (comment start at ~A)" name start-position) (return "")) (#\\ (setq ndouble 0) (let ((next (peek-char nil istream nil 'eof))) (case next (#\newline (read-char istream nil 'eof) (return-from do)) ((#\\ #\" #\') (setq c (read-char istream nil 'eof))) (t nil)))) (#\" (incf ndouble) (when (= ndouble 3) (loop-finish))) (t (setq ndouble 0))) (push c chars)) finally (return (coerce (nreverse (cddr chars)) 'string))))) ; last 2 chars were the pre-final "s