• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:id +defs:for +defs:key

1 ;;; cc-engine.el --- core syntax guessing engine for CC mode
27 ;; GNU General Public License for more details.
48 ;; Various functions in CC Mode use text properties for caching and
80 ;; Note: This doc is for internal use only. Other packages should not
96 ;; below for further details.
115 ;; recognized simply by looking for a token like ";" or "}".
123 ;; 'c-decl-id-start and 'c-decl-type-start
128 ;; 'c-decl-id-start otherwise.
153 ;; Make declarations for all the `c-lang-defvar' variables in cc-langs.
170 ;; Internal state of hungry delete key feature
171 (defvar c-hungry-delete-key nil)
172 (make-variable-buffer-local 'c-hungry-delete-key)
177 ;; key like `{' is pressed (or an electric keyword like `else').
198 ;; Dynamically bound cache for `c-in-literal'.
232 comment at the start of cc-engine.el for more info."
254 comment at the start of cc-engine.el for more info."
262 (defun c-forward-over-cpp-define-id ()
270 (when (and c-opt-cpp-macro-define-id
271 (looking-at c-opt-cpp-macro-define-id))
379 ;; precisely, the value is the symbol for the keyword in
390 ;; String syntax chars, suitable for skip-syntax-(forward|backward).
404 ;; Holds formatted error strings for the few cases where parse errors
494 ;; Macros used internally in c-beginning-of-statement-1 for the
526 (format "No matching `%s' found for `%s' on line %d"
576 comment at the start of cc-engine.el for more info."
579 ;; boundaries and the tokens (such as "while") in c-opt-block-stmt-key. Its
595 ;; sym: This is either the "while"-like token (e.g. 'for) we've just
601 ;; 'else, for example, means "just gone back over an else".
651 ;; searching for a "do" which would have opened a do-while. If we didn't
683 ;; `c-nonlabel-token-key'. It's `start' if no valid label
696 ;; Regexp which matches "for", "if", etc.
697 (cond-key (or c-opt-block-stmt-key
722 ;; done. Later on we ignore the boundaries for statements that don't
751 (and macro-start ; Always NIL for AWK.
775 (and (looking-at cond-key)
793 ;; "we've just passed an else", NOT "we're looking for an
825 (c-bos-pop-state)))) ; no longer searching for do.
864 ;; c-awk-after-if-for-while-condition-p,
883 ;; for the previous one.
904 ;; The end position of the area to search for statement
986 (when (and c-opt-method-key
998 (if (or (not (looking-at c-nonlabel-token-key)) ; proper label
1002 ; wrong for AWK. 2006/1/14.
1014 (looking-at c-nonlabel-token-key)) ; e.g. "while :"
1025 pos tok))) ; Not nil (for the while loop).
1038 (if (setq saved (if (looking-at c-block-stmt-1-key)
1091 comment at the start of cc-engine.el for more info."
1111 ;; looking for more : and ?.
1138 comment at the start of cc-engine.el for more info."
1166 comment at the start of cc-engine.el for more info."
1188 ;; changing the syntax for backslash doesn't work since we must treat
1226 comment at the start of cc-engine.el for more info."
1255 ;; ending with a comment when moving backwards. This corrects for
1298 comment at the start of cc-engine.el for more info."
1315 ;; odd. Anyway, this is necessary for Emacs.
1324 ;; Tools for skipping over syntactic whitespace.
1344 ;; is marked (it could be clobbered by later changes, for
1358 ;; can occur, and the reason for not extending the `c-in-sws'
1379 ;; The main motivation for this system is to increase the speed in
1630 ;; we need to do this to check if the cache can be used for the
1643 ;; Remove the properties for any nested ws that might be cached.
1644 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set
1667 ;; Set `rung-pos' for the next rung. It's the same thing here as
1683 "c-forward-sws clearing at %s for cache separation"
1693 "c-forward-sws clearing thoroughly at %s for cache separation"
1818 ;; position for the cache. Note that `c-backward-comments'
1871 ;; Remove the properties for any nested ws that might be cached.
1872 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set
1906 "c-backward-sws clearing at %s for cache separation"
1916 "c-backward-sws clearing thoroughly at %s for cache separation"
1929 ;; The motivation for the second bit is to check whether removing this
1933 ;; careful about using this function for, e.g. AWK. (2007/3/7)
1944 ;; A system for finding noteworthy parens before the point.
2001 ;; Return the start position for building `c-state-cache' from
2121 ;; Find the start position for the forward search. (Can't
2203 ;; pair, whichever is applicable for the paren we've
2240 ;; Check for known types of parens that we
2252 ;; scan backward for the start paren and then start over.
2332 ;; expression, it must be impossible for the corresponding
2411 ;; This is used for `font-lock-beginning-of-syntax-function'. It
2447 ;; Tools for scanning identifiers and other tokens.
2454 happen in Pike) then the point for the preceding one is returned.
2457 comment at the start of cc-engine.el for more info."
2466 ;; Check for a normal (non-keyword) identifier.
2479 (looking-at c-symbol-key)
2514 (looking-at c-symbol-key)
2587 LIMIT sets the limit for the movement and defaults to the point limit.
2599 comment at the start of cc-engine.el for more info."
2668 See `c-forward-token-2' for details."
2707 ;; Use `condition-case' to avoid having to check for buffer
2735 for compatibility only; it's only a wrapper over `c-forward-token-2'."
2743 for compatibility only; it's only a wrapper over `c-backward-token-2'."
2749 ;; Tools for doing searches restricted to syntactically relevant text.
2774 position to check for syntactic significance. If LOOKBEHIND-SUBMATCH
2792 comment at the start of cc-engine.el for more info."
2801 ;; Start position for the last search.
2991 comment at the start of cc-engine.el for more info."
3144 ;; ;; '/' for block comment endings (not covered by comment end
3179 ;;comment at the start of cc-engine.el for more info."
3250 ;; Tools for handling comments and string literals.
3264 comment at the start of cc-engine.el for more info."
3304 ;; The workaround for this is for the AWK Mode initialisation to switch the
3305 ;; defalias for c-in-literal to c-slow-in-literal. This will slow down other
3333 spaces and tabs between point and the literal. The search for such a
3336 recognized. This only has effect for comments, which have starting
3340 comment at the start of cc-engine.el for more info."
3369 ;; Search forward for a literal.
3415 comment at the start of cc-engine.el for more info."
3451 comment at the start of cc-engine.el for more info."
3468 ;; Variables used in `c-find-decl-spots' to cache the search done for
3473 ;; macros, which would be repeated for each changed character when
3475 ;; current line for each change. Thus it's worthwhile to cache the
3598 ;; Call CFD-FUN for each possible spot for a declaration, cast or
3622 ;; preceding the spot, or 0 for the implicit match at bob. The
3660 ;; match. If searching for the property isn't needed then we
3664 ;; `c-find-decl-prefix-search'. 0 for the implicit match at
3683 ;; Must back up a bit since we look for the end of the previous
3712 ;; start of it at all, for instance) so check that we have
3800 ;; only done to search for a `c-decl-end' spot.
3890 ;; good start position for the search, so do it.
3901 ;; aren't open parens, for the sake of languages
3917 ;; we're still searching for declarations embedded in
3984 ;; A cache for found types.
3999 ;; arglist replaced with "<>" in references or "<" for the one in the
4080 (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka) " "o")
4090 ((eq (car c-maybe-stale-found-type) 'c-decl-id-start)
4139 ;; 'found for) as actual types (and always return 'found for them).
4150 ;; all arglists for side effects (i.e. recording types), otherwise it
4155 ;; depends on a proper value for `c-restricted-<>-arglists'.
4206 (defmacro c-record-type-id (range)
4216 (defmacro c-record-ref-id (range)
4231 (defmacro c-forward-keyword-prefixed-id (type)
4252 (c-record-ref-id c-last-identifier-range)))
4255 (defmacro c-forward-id-comma-list (type update-safe-pos)
4258 ;; `c-forward-keyword-prefixed-id'.
4268 (c-forward-keyword-prefixed-id ,type)))))
4285 ;; Note that for `c-colon-type-list-kwds', which doesn't necessary
4309 (c-forward-keyword-prefixed-id type))
4311 (c-forward-id-comma-list type t))
4314 (c-forward-keyword-prefixed-id ref))
4316 (c-forward-id-comma-list ref t))
4332 (looking-at c-symbol-key) ; Always matches.
4358 (when (c-forward-keyword-prefixed-id type)
4359 (c-forward-id-comma-list type t)))
4373 (c-forward-keyword-prefixed-id type))
4376 (c-forward-id-comma-list type nil))))
4490 ;; Must check for '>' at the very start separately,
4543 (let (id-start id-end subres keyword-match)
4556 (setq id-end (point))
4559 (looking-at c-opt-<>-sexp-key))
4561 (setq id-start (point))))
4584 (if (and c-opt-identifier-concat-key
4587 (looking-at c-opt-identifier-concat-key)))
4588 (c-record-ref-id (cons id-start id-end))
4589 (c-record-type-id (cons id-start id-end))))))
4621 ;; function for more details.
4694 (let ((pos (point)) (start (point)) res id-start id-end
4704 (looking-at c-identifier-key)
4707 ;; Check for keyword. We go to the last symbol in
4708 ;; `c-identifier-key' first.
4709 (goto-char (setq id-end (match-end 0)))
4711 (setq id-start (point))
4718 "\\(" (c-lang-const c-nonsymbol-key c++)
4730 (goto-char id-end)
4732 (cond ((eq (char-before id-end) ?e)
4747 ;; of `c-opt-type-modifier-key'.
4764 (looking-at c-opt-type-modifier-key))
4778 ;; `id-start' is equal to `id-end' if we've jumped over
4780 ;; That can occur e.g. for Java import directives on the
4782 (when (and id-start (/= id-start id-end))
4784 (cons id-start id-end)))
4785 (goto-char id-end)
4792 (when (or c-opt-identifier-concat-key
4796 ((and c-opt-identifier-concat-key
4797 (looking-at c-opt-identifier-concat-key))
4800 ;; covered in `c-identifier-key'.
4818 (if (and c-opt-identifier-concat-key
4819 (looking-at c-opt-identifier-concat-key))
4824 (when (and c-record-type-identifiers id-start)
4825 (c-record-ref-id (cons id-start id-end)))
4830 (when (and c-record-type-identifiers id-start)
4831 (c-record-type-id (cons id-start id-end)))
4860 (let ((start (point)) pos res name-res id-start id-end id-range)
4864 (when c-opt-type-modifier-key
4865 (while (looking-at c-opt-type-modifier-key)
4871 ((looking-at c-type-prefix-key)
4885 (c-record-type-id c-last-identifier-range)))
4895 (setq id-start (point)
4898 (setq id-end (point)
4899 id-range c-last-identifier-range))))
4900 (and (cond ((looking-at c-primitive-type-key)
4903 (looking-at c-known-type-key))
4905 (or (not id-end)
4911 id-end)
4914 ;; checked for a name first so that we don't go here if the
4917 (setq id-end (match-end 1))
4921 (c-record-type-id (cons (match-beginning 1) (match-end 1))))
4923 (if (and c-opt-type-component-key
4925 (looking-at c-opt-type-component-key)))
4926 ;; There might be more keywords for the type.
4931 (looking-at c-opt-type-component-key))
4933 (looking-at c-primitive-type-key))
4934 (c-record-type-id (cons (match-beginning 1)
4937 (if (looking-at c-primitive-type-key)
4940 (c-record-type-id (cons (match-beginning 1)
4955 (goto-char id-end)
4958 (c-add-type id-start id-end)
4959 (when (and c-record-type-identifiers id-range)
4960 (c-record-type-id id-range))
4963 (setq res (if (c-check-type id-start id-end)
4971 (goto-char id-end)
4981 (when c-opt-type-modifier-key
4982 (while (looking-at c-opt-type-modifier-key)
4991 (when c-opt-type-suffix-key
4992 (while (looking-at c-opt-type-suffix-key)
4996 (when c-opt-type-concat-key
4997 ;; Look for a trailing operator that concatenates the type
5011 (if (and (looking-at c-opt-type-concat-key)
5025 (c-add-type id-start id-end))
5026 (when (and c-record-type-identifiers id-range)
5027 (c-record-type-id id-range))
5050 (when (and c-record-found-types (memq res '(known found)) id-range)
5052 (cons id-range c-record-found-types))))
5079 got-suffix-after-parens id-start
5086 id-start backup-id-start)
5088 id-start start-pos))
5100 '(setq start id-start))))
5184 ;; believe is the declarator for the first identifier. Set
5188 id-start
5189 ;; These store `at-type', `type-start' and `id-start' of the
5195 backup-at-type backup-type-start backup-id-start
5226 ;; Check for a type. Unknown symbols are treated as possible
5233 ;; Look for a specifier keyword clause.
5251 ;; alias for a prefix like "unsigned".
5259 backup-id-start id-start
5262 id-start (point)
5282 (setq id-start kwd-clause-end)
5318 ;; to do this for a known type prefix is to make things
5327 (while (looking-at c-decl-hangon-key)
5329 (setq id-start (point)))
5340 (setq id-start start-pos))
5349 (goto-char id-start)
5371 id-start type-start))))))
5373 ;; Check for and step over a type decl expression after the thing
5375 ;; need the correct end position of the declarator for
5379 ;; `c-type-decl-prefix-key'.
5386 ;; `c-type-decl-suffix-key'.
5409 (goto-char id-start)
5413 (while (and (looking-at c-type-decl-prefix-key)
5421 ;; We only check for a trailing "::" and
5448 (while (if (looking-at c-type-decl-suffix-key)
5469 ;; continue searching for suffix operators.
5620 c-after-suffixed-type-maybe-decl-key))))))
5624 ;; "backtracking" done inside the `c-type-decl-suffix-key' loop
5629 ;; looking at either `c-after-suffixed-type-decl-key' or "[;,]".
5668 (looking-at c-after-suffixed-type-decl-key)
5678 ;; `c-after-suffixed-type-decl-key' has matched.
5681 ;; A declaration according to `c-after-suffixed-type-decl-key'.
5695 ;; the effort to look for them.)
5699 ;; should start here, so check for allowed separation tokens. Note
5703 ;; *) Don't check for C++ style initializers using parens
5727 ;; `at-type' probably won't be 'found for
5737 (looking-at c-known-type-key)))
5797 ;; Check for a cast.
5851 (looking-at c-simple-stmt-key)
5887 (cons id-start at-type-decl))
5898 ;; specific symbols (see below) for interesting situations), otherwise don't
5911 ;; (v) One of the keywords matched by `c-opt-extra-label-key' (without any
5919 ;; the first submatch in `c-opt-extra-label-key'. The point is directly
5933 ;; The optional LIMIT limits the forward scan for the colon.
5950 ;; Record only the keyword itself for fontification, since in
5954 (c-record-ref-id (cons (match-beginning 1) kwd-end)))
5980 ((and c-opt-extra-label-key
5981 (looking-at c-opt-extra-label-key))
5982 ;; For a `c-opt-extra-label-key' match, we record the whole
5983 ;; thing for fontification. That's to get the leading '@' in
5987 (c-record-ref-id (cons (match-beginning 1) (point))))
5992 ((and c-recognize-colon-labels ; nil for AWK and IDL, otherwise t.
6021 (looking-at c-block-stmt-1-key)))
6031 (looking-at c-block-stmt-1-key)))
6055 ;; If the caller turned on recording for us,
6059 ;; A label can't start at a cpp directive. Check for
6068 ;; of QT's "slots" declarations. Allow '(' for the sake of macro
6112 ;; Check that `c-nonlabel-token-key' doesn't match anywhere.
6116 (when (looking-at c-nonlabel-token-key)
6125 ;; Record the identifiers in the label for fontification, unless
6132 (while (c-syntactic-re-search-forward c-symbol-key nil t)
6133 (c-record-ref-id (cons (match-beginning 0)
6192 ;; Look for ": superclass-name" or "( category-name )".
6203 ;; Look for a protocol reference list.
6239 (and c-opt-method-key
6240 (looking-at c-opt-method-key)
6250 ;; Only one level of enclosing parentheses is considered, so for
6256 (and c-opt-asm-stmt-key
6261 (looking-at c-opt-asm-stmt-key))))
6278 comment at the start of cc-engine.el for more info."
6281 (c-search-uplist-for-classkey paren-state))))
6287 ;; that region, the point has to be inside the first one for this
6291 ;; function header (see `c-forward-decl-or-cast-1' for details) and
6297 ;; LIM is used as bound for backward buffer searches.
6301 (let ((beg (point)) end id-start)
6308 (setq id-start
6310 (< id-start beg)
6321 (goto-char id-start)
6339 ;; position that bounds the backward search for the argument list.
6356 ;; Search backwards for the defun's argument list. We give up if we
6359 ;; The criterion for a paren structure being the arg list is:
6418 (catch 'id-list
6421 (unless (c-on-identifier) (throw 'id-list nil))
6453 ;; for, if, while, switch, catch, synchronized, foreach
6463 (or (looking-at c-block-stmt-1-key)
6466 (looking-at c-block-stmt-2-key)))
6469 (defun c-after-special-operator-id (&optional lim)
6489 ;; kind, move to the proper anchor point for that block. It might
6491 ;; position at return is suitable as start position for that
6502 ;; declaration of some kind, move to the proper anchor point for
6510 ;; Search forward for the end of the "header" of the current
6513 ;; semicolon. I.e. search forward for the closest following
6577 ;; Must check with c-opt-method-key in ObjC mode.
6578 (not (and c-opt-method-key
6579 (looking-at c-opt-method-key)))
6688 (if (or (not c-opt-block-decls-with-vars-key)
6694 ;; Check for `c-opt-block-decls-with-vars-key'
6698 c-opt-block-decls-with-vars-key
6727 ;; what `c-decl-block-key' matched. Also, if GOTO-START is set then
6736 ;; The optional LIMIT limits the backward search for the start of
6764 ;; If `goto-start' is set we begin by searching for the
6766 ;; The `c-decl-block-key' search continues from there since
6776 ((c-syntactic-re-search-forward c-decl-block-key open-brace t t t)
6791 ;; then we should be at the declarator now, so check for a
6799 (looking-at c-type-decl-prefix-key)))))
6808 (looking-at c-specifier-key)
6826 (if (looking-at c-symbol-key)
6854 (defun c-search-uplist-for-classkey (paren-state)
6857 ;; contains the bufpos at boi of the class key line, and aref 1
6859 ;; obsolete wrapper for `c-looking-at-decl-block'.
6881 ;; placed in inconvenient locations. It's a trade-off we make for
6892 (if (and (or (looking-at c-brace-list-key)
6894 (looking-at c-brace-list-key)))
6901 (let ((class-key
6903 ;; check for the class key here.
6905 c-decl-block-key))
6922 ;; doesn't check for an identifier before it.
6925 ;; this statement, but watch out for operator=
6929 (when (and c-opt-inexpr-brace-list-key
6932 ;; directly after "new Foo[]", so check for a "new"
6937 ((looking-at c-opt-inexpr-brace-list-key) t)
6949 ((and class-key
6950 (looking-at class-key))
6960 ;; Check for operator =
6964 ;; Check for `<opchar>= in Pike.
6967 ;; Special case for Pikes
7014 ;; LIM is the limit for forward search. The point may either be at
7125 (or (not (looking-at c-class-key))
7162 ;; Accept several square bracket sexps for
7211 ;; implements the main decision tree for determining the syntactic
7248 ;; Point is assumed to be at the prospective anchor point for the
7253 ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the
7363 ;; from and add the right syntactic element for it.
7421 ;; Fill in the current point as the anchor for all the symbols
7447 ;; here, but we have to do like this for compatibility.
7473 ;; CASE B: open braces for class or brace-lists
7496 ;; brace-list-open for brace lists as top-level constructs,
7503 ;; for the auto newline feature.
7511 ;; extensions, but watch out for macros followed by blocks.
7555 ;; Note that we do a forward search for something ahead
7599 ;; The following record some positions for the containing
7666 ;; exception of the "for" clause). This difference is
7695 ;; This is a kludge for XEmacs where we use
7774 (and c-opt-block-stmt-key
7792 (not (looking-at c-opt-block-stmt-key)))
7805 (if (looking-at c-block-stmt-2-key)
7812 (looking-at c-opt-block-stmt-key))))
7939 (looking-at c-symbol-key))
7946 ;; Special case for extern-lang-open.
7963 (while (looking-at c-specifier-key)
7974 (and c-opt-inexpr-brace-list-key
7976 (looking-at c-opt-inexpr-brace-list-key)
7979 (looking-at c-brace-list-key))
8036 ;; for the topmost-intro line that contains the
8071 (looking-at c-opt-postfix-decl-spec-key)))
8073 ;; watch out for scope operator
8086 (looking-at c-class-key)))
8087 ;; for Java
8095 (cond ((looking-at c-opt-postfix-decl-spec-key)
8165 (when (setq placeholder (c-after-special-operator-id lim))
8181 ;; NB: No c-after-special-operator-id stuff in this
8219 (and (looking-at c-class-key)
8241 ;; topmost-intro-cont for it, for consistency with
8257 ;; Special case for compatibility with the
8287 (not (and c-opt-block-stmt-key
8288 (looking-at c-opt-block-stmt-key)))))
8294 ((and c-opt-method-key
8295 (looking-at c-opt-method-key))
8299 ;; thing in the buffer. Can't look for a 'same return
8387 ;; Special case for compatibility with the
8408 ((and c-opt-method-key
8412 (when (looking-at c-opt-method-key)
8421 (c-after-special-operator-id lim))))
8518 (looking-at "\\<for\\>[^_]")))
8529 ((and c-opt-method-key
8534 (if (not (looking-at c-symbol-key))
8542 ;; for-list continuation line. C.f. case 7A.
8572 (looking-at c-opt-postfix-decl-spec-key)))
8617 (while (looking-at c-specifier-key)
8649 ;; Prepare for the rest of the cases below by going to the
8754 (looking-at c-other-decl-block-key))
8760 ;; extensions, but watch out for macros followed by
8903 ;; e.g. the gcc extensions, but watch out for macros
8953 (when (and c-opt-friend-key
8954 (looking-at c-opt-friend-key))
9037 (c-benign-error "The offset %S for %s was mistakenly quoted"
9053 Error evaluating offset %S for %s: \
9060 Error evaluating offset %S for %s: \
9084 Error evaluating offset %S for %s: \
9104 (c-benign-error "Unknown offset format %S for %s" offset symbol)
9110 (c-benign-error "Error evaluating offset %S for %s: Got invalid value %S"
9129 (c-benign-error "No offset found for syntactic symbol %s" symbol))
9139 ;; This is a compatibility wrapper for `c-calc-offset' in case
9154 ;; Note that topmost-intro always has an anchor position at bol, for
9170 ;; indentation we might get for the nested structures