Function: c-cache-to-parse-ps-state
c-cache-to-parse-ps-state is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-cache-to-parse-ps-state ELT)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
;; An upper limit on valid entries in `c-lit-pos-cache'. This
;; is reduced by buffer changes, and increased by invocations of
;; `c-parse-ps-state-below'.
;; Note that as of 2019-05-27, the forms involving CHAR-1 are no longer used.
(defun c-cache-to-parse-ps-state (elt)
;; Create a list suitable to use as the old-state parameter to
;; `parse-partial-sexp', out of ELT, a member of
;; `c-lit-pos-cache'. ELT is either just a number, or a list
;; with 2, 3, or 4 members (See `c-parse-ps-state-to-cache'). That number
;; or the car of the list is the "position element" of ELT, the position
;; where ELT is valid.
;;
;; POINT is left at the position for which the returned state is valid. It
;; will be either the position element of ELT, or one character before
;; that. (The latter happens in Emacs <= 25 and XEmacs, when ELT indicates
;; its position element directly follows a potential first character of a
;; two char construct (such as a comment opener or an escaped character).)
(if (and (consp elt) (>= (length elt) 3))
;; Inside a string or comment
(let ((depth 0) (containing nil)
in-string in-comment
(min-depth 0) com-style com-str-start
(char-1 (nth 3 elt)) ; first char of poss. 2-char construct
(pos (car elt))
(type (cadr elt)))
(setq com-str-start (car (cddr elt)))
(cond
((or (numberp type) (eq type t)) ; A string
(setq in-string type))
((memq type '(c c++)) ; A comment
(setq in-comment t
com-style (if (eq type 'c++) 1 nil)))
(t (c-benign-error "Invalid type %s in c-cache-to-parse-ps-state"
elt)))
(goto-char (if char-1
(1- pos)
pos))
(if (memq 'pps-extended-state c-emacs-features)
(list depth containing nil
in-string in-comment nil
min-depth com-style com-str-start
nil nil)
(list depth containing nil
in-string in-comment nil
min-depth com-style com-str-start nil)))
;; Not in a string or comment.
(if (memq 'pps-extended-state c-emacs-features)
(progn
(goto-char (if (consp elt) (car elt) elt))
(list 0 nil nil nil nil
(and (consp elt) (eq (nth 1 elt) 9)) ; 9 is syntax code for "escape".
0 nil nil nil
(and (consp elt) (nth 1 elt))))
(goto-char (if (consp elt) (car elt) elt))
(if (and (consp elt) (cdr elt)) (backward-char))
(copy-tree '(0 nil nil nil nil
nil
0 nil nil nil)))))