Function: c-semi-pp-to-literal
c-semi-pp-to-literal is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-semi-pp-to-literal HERE &optional NOT-IN-DELIMITER)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-semi-pp-to-literal (here &optional not-in-delimiter)
;; Do a parse-partial-sexp from a position in the buffer before HERE which
;; isn't in a literal, and return information about HERE, either:
;; (STATE TYPE BEG) if HERE is in a literal; or
;; (STATE) otherwise,
;; where STATE is the parsing state at HERE, TYPE is the type of the literal
;; enclosing HERE, (one of 'string, 'c, 'c++) and BEG is the starting
;; position of that literal (including the delimiter).
;;
;; 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 10 (in
;; newer Emacsen only, the syntax of a position after a potential first char
;; of a two char construct) of STATE are valid.
(save-excursion
(save-restriction
(widen)
(c-trim-lit-pos-cache)
(c-semi-trim-near-cache)
(save-match-data
(let* ((pos-and-state (c-semi-get-near-cache-entry here))
(pos (car pos-and-state))
(near-pos pos)
(s (cdr pos-and-state))
far-pos-and-state far-pos far-s ty)
(if (or (not pos)
(< pos (- here 100)))
(progn
(setq far-pos-and-state (c-parse-ps-state-below here)
far-pos (car far-pos-and-state)
far-s (cdr far-pos-and-state))
(when (or (not pos) (> far-pos pos))
(setq pos far-pos
s far-s))))
(when
(or
(> here pos)
(null (nth 8 s))
(< here (nth 8 s)) ; Can't happen, can it?
(not
(or
(and (nth 3 s) ; string
(not (eq (char-before here) ?\\)))
(and (nth 4 s) (not (nth 7 s)) ; Block comment
(not (memq (char-before here)
c-block-comment-awkward-chars)))
(and (nth 4 s) (nth 7 s) ; Line comment
(not (memq (char-before here) '(?\\ ?\n)))))))
(setq s (parse-partial-sexp pos here nil nil s)))
(when (not (eq near-pos here))
(c-semi-put-near-cache-entry here s))
(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)))
(list s ty (nth 8 s)))
((and (not not-in-delimiter) ; inside a comment starter
(not (bobp))
(progn (backward-char)
(and (not (and (memq 'category-properties c-emacs-features)
(looking-at "\\s!")))
(looking-at c-comment-start-regexp))))
(setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++))
(list s ty (point)))
(t (list s))))))))