Function: c-state-pp-to-literal
c-state-pp-to-literal is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-state-pp-to-literal FROM TO &optional NOT-IN-DELIMITER)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
;; An upper limit on valid entries in `c-state-nonlit-pos-cache'. This is
;; reduced by buffer changes, and increased by invocations of
;; `c-state-literal-at'.
(defun c-state-pp-to-literal (from to &optional not-in-delimiter)
;; Do a parse-partial-sexp from FROM to TO, returning either
;; (STATE TYPE (BEG . END)) if TO is in a literal; or
;; (STATE) otherwise,
;; where STATE is the parsing state at TO, TYPE is the type of the literal
;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the literal,
;; including the delimiters.
;;
;; Unless NOT-IN-DELIMITER is non-nil, when TO is inside a two-character
;; comment opener, this is recognized as being in a comment literal.
;;
;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote),
;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of
;; STATE are valid.
(save-excursion
(save-match-data
(let ((s (parse-partial-sexp from to))
ty co-st)
(cond
((or (nth 3 s)
(and (nth 4 s)
(not (eq (nth 7 s) 'syntax-table)))) ; in a string or comment
(setq ty (cond
((nth 3 s) 'string)
((nth 7 s) 'c++)
(t 'c)))
(parse-partial-sexp (point) (point-max)
nil ; TARGETDEPTH
nil ; STOPBEFORE
s ; OLDSTATE
'syntax-table) ; stop at end of literal
`(,s ,ty (,(nth 8 s) . ,(point))))
((and (not not-in-delimiter) ; inside a comment starter
(not (bobp))
(progn (backward-char)
(and (not (looking-at "\\s!"))
(looking-at c-comment-start-regexp))))
(setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++)
co-st (point))
(forward-comment 1)
`(,s ,ty (,co-st . ,(point))))
(t `(,s)))))))