Mercurial > emacs
comparison lisp/progmodes/cc-engine.el @ 98693:69a04789c5f0
Amend several doc strings and comments.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Mon, 13 Oct 2008 19:10:11 +0000 |
parents | 598aca8e5d9d |
children | c6c533f20c51 |
comparison
equal
deleted
inserted
replaced
98692:51d93fabb7cf | 98693:69a04789c5f0 |
---|---|
527 "Move to the start of the current statement or declaration, or to | 527 "Move to the start of the current statement or declaration, or to |
528 the previous one if already at the beginning of one. Only | 528 the previous one if already at the beginning of one. Only |
529 statements/declarations on the same level are considered, i.e. don't | 529 statements/declarations on the same level are considered, i.e. don't |
530 move into or out of sexps (not even normal expression parentheses). | 530 move into or out of sexps (not even normal expression parentheses). |
531 | 531 |
532 If point is already at the earliest statment within braces or parens, | |
533 this function doesn't move back into any whitespace preceding it; it | |
534 returns 'same in this case. | |
535 | |
532 Stop at statement continuation tokens like \"else\", \"catch\", | 536 Stop at statement continuation tokens like \"else\", \"catch\", |
533 \"finally\" and the \"while\" in \"do ... while\" if the start point | 537 \"finally\" and the \"while\" in \"do ... while\" if the start point |
534 is within the continuation. If starting at such a token, move to the | 538 is within the continuation. If starting at such a token, move to the |
535 corresponding statement start. If at the beginning of a statement, | 539 corresponding statement start. If at the beginning of a statement, |
536 move to the closest containing statement if there is any. This might | 540 move to the closest containing statement if there is any. This might |
546 from any normal statement starts found in it, stop at the first token | 550 from any normal statement starts found in it, stop at the first token |
547 of the content in the macro, i.e. the expression of an \"#if\" or the | 551 of the content in the macro, i.e. the expression of an \"#if\" or the |
548 start of the definition in a \"#define\". Also stop at start of | 552 start of the definition in a \"#define\". Also stop at start of |
549 macros before leaving them. | 553 macros before leaving them. |
550 | 554 |
551 Return 'label if stopped at a label, 'same if stopped at the beginning | 555 Return: |
552 of the current statement, 'up if stepped to a containing statement, | 556 'label if stopped at a label; |
553 'previous if stepped to a preceding statement, 'beginning if stepped | 557 'same if stopped at the beginning of the current statement; |
554 from a statement continuation clause to its start clause, or 'macro if | 558 'up if stepped to a containing statement; |
555 stepped to a macro start. Note that 'same and not 'label is returned | 559 'previous if stepped to a preceding statement; |
556 if stopped at the same label without crossing the colon character. | 560 'beginning if stepped from a statement continuation clause to |
561 its start clause; or | |
562 'macro if stepped to a macro start. | |
563 Note that 'same and not 'label is returned if stopped at the same | |
564 label without crossing the colon character. | |
557 | 565 |
558 LIM may be given to limit the search. If the search hits the limit, | 566 LIM may be given to limit the search. If the search hits the limit, |
559 point will be left at the closest following token, or at the start | 567 point will be left at the closest following token, or at the start |
560 position if that is less ('same is returned in this case). | 568 position if that is less ('same is returned in this case). |
561 | 569 |
2507 | 2515 |
2508 (defun c-beginning-of-current-token (&optional back-limit) | 2516 (defun c-beginning-of-current-token (&optional back-limit) |
2509 ;; Move to the beginning of the current token. Do not move if not | 2517 ;; Move to the beginning of the current token. Do not move if not |
2510 ;; in the middle of one. BACK-LIMIT may be used to bound the | 2518 ;; in the middle of one. BACK-LIMIT may be used to bound the |
2511 ;; backward search; if given it's assumed to be at the boundary | 2519 ;; backward search; if given it's assumed to be at the boundary |
2512 ;; between two tokens. Return non-nil if the point is move, nil | 2520 ;; between two tokens. Return non-nil if the point is moved, nil |
2513 ;; otherwise. | 2521 ;; otherwise. |
2514 ;; | 2522 ;; |
2515 ;; This function might do hidden buffer changes. | 2523 ;; This function might do hidden buffer changes. |
2516 (let ((start (point))) | 2524 (let ((start (point))) |
2517 (if (looking-at "\\w\\|\\s_") | 2525 (if (looking-at "\\w\\|\\s_") |
3317 to start parsing from. If NEAR is non-nil, then the limits of any | 3325 to start parsing from. If NEAR is non-nil, then the limits of any |
3318 literal next to point is returned. \"Next to\" means there's only | 3326 literal next to point is returned. \"Next to\" means there's only |
3319 spaces and tabs between point and the literal. The search for such a | 3327 spaces and tabs between point and the literal. The search for such a |
3320 literal is done first in forward direction. If NOT-IN-DELIMITER is | 3328 literal is done first in forward direction. If NOT-IN-DELIMITER is |
3321 non-nil, the case when point is inside a starting delimiter won't be | 3329 non-nil, the case when point is inside a starting delimiter won't be |
3322 recognized. This only has effect for comments, which have starting | 3330 recognized. This only has effect for comments which have starting |
3323 delimiters with more than one character. | 3331 delimiters with more than one character. |
3324 | 3332 |
3325 Note that this function might do hidden buffer changes. See the | 3333 Note that this function might do hidden buffer changes. See the |
3326 comment at the start of cc-engine.el for more info." | 3334 comment at the start of cc-engine.el for more info." |
3327 | 3335 |
3427 range) | 3435 range) |
3428 (error range)))) | 3436 (error range)))) |
3429 | 3437 |
3430 (defun c-literal-type (range) | 3438 (defun c-literal-type (range) |
3431 "Convenience function that given the result of `c-literal-limits', | 3439 "Convenience function that given the result of `c-literal-limits', |
3432 returns nil or the type of literal that the range surrounds. It's | 3440 returns nil or the type of literal that the range surrounds, one |
3433 much faster than using `c-in-literal' and is intended to be used when | 3441 of the symbols 'c, 'c++ or 'string. It's much faster than using |
3434 you need both the type of a literal and its limits. | 3442 `c-in-literal' and is intended to be used when you need both the |
3443 type of a literal and its limits. | |
3435 | 3444 |
3436 Note that this function might do hidden buffer changes. See the | 3445 Note that this function might do hidden buffer changes. See the |
3437 comment at the start of cc-engine.el for more info." | 3446 comment at the start of cc-engine.el for more info." |
3438 | 3447 |
3439 (if (consp range) | 3448 (if (consp range) |
3579 (min cfd-prop-match (point)) | 3588 (min cfd-prop-match (point)) |
3580 (point)))))) | 3589 (point)))))) |
3581 | 3590 |
3582 (defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun) | 3591 (defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun) |
3583 ;; Call CFD-FUN for each possible spot for a declaration, cast or | 3592 ;; Call CFD-FUN for each possible spot for a declaration, cast or |
3584 ;; label from the point to CFD-LIMIT. Such a spot is: | 3593 ;; label from the point to CFD-LIMIT. |
3585 ;; | 3594 ;; |
3595 ;; CFD-FUN is called with point at the start of the spot. It's | |
3596 ;; passed two arguments: The first is the end position of the token | |
3597 ;; preceding the spot, or 0 for the implicit match at bob. The | |
3598 ;; second is a flag that is t when the match is inside a macro. If | |
3599 ;; CFD-FUN adds `c-decl-end' properties somewhere below the current | |
3600 ;; spot, it should return non-nil to ensure that the next search | |
3601 ;; will find them. | |
3602 ;; | |
3603 ;; Such a spot is: | |
3586 ;; o The first token after bob. | 3604 ;; o The first token after bob. |
3587 ;; o The first token after the end of submatch 1 in | 3605 ;; o The first token after the end of submatch 1 in |
3588 ;; `c-decl-prefix-or-start-re' when that submatch matches. | 3606 ;; `c-decl-prefix-or-start-re' when that submatch matches. |
3589 ;; o The start of each `c-decl-prefix-or-start-re' match when | 3607 ;; o The start of each `c-decl-prefix-or-start-re' match when |
3590 ;; submatch 1 doesn't match. | 3608 ;; submatch 1 doesn't match. |
3599 ;; If the match is inside a macro then the buffer is narrowed to the | 3617 ;; If the match is inside a macro then the buffer is narrowed to the |
3600 ;; end of it, so that CFD-FUN can investigate the following tokens | 3618 ;; end of it, so that CFD-FUN can investigate the following tokens |
3601 ;; without matching something that begins inside a macro and ends | 3619 ;; without matching something that begins inside a macro and ends |
3602 ;; outside it. It's to avoid this work that the CFD-DECL-RE and | 3620 ;; outside it. It's to avoid this work that the CFD-DECL-RE and |
3603 ;; CFD-FACE-CHECKLIST checks exist. | 3621 ;; CFD-FACE-CHECKLIST checks exist. |
3604 ;; | |
3605 ;; CFD-FUN is called with point at the start of the spot. It's | |
3606 ;; passed two arguments: The first is the end position of the token | |
3607 ;; preceding the spot, or 0 for the implicit match at bob. The | |
3608 ;; second is a flag that is t when the match is inside a macro. If | |
3609 ;; CFD-FUN adds `c-decl-end' properties somewhere below the current | |
3610 ;; spot, it should return non-nil to ensure that the next search | |
3611 ;; will find them. | |
3612 ;; | 3622 ;; |
3613 ;; The spots are visited approximately in order from top to bottom. | 3623 ;; The spots are visited approximately in order from top to bottom. |
3614 ;; It's however the positions where `c-decl-prefix-or-start-re' | 3624 ;; It's however the positions where `c-decl-prefix-or-start-re' |
3615 ;; matches and where `c-decl-end' properties are found that are in | 3625 ;; matches and where `c-decl-end' properties are found that are in |
3616 ;; order. Since the spots often are at the following token, they | 3626 ;; order. Since the spots often are at the following token, they |
5137 ;; CONTEXT is a symbol that describes the context at the point: | 5147 ;; CONTEXT is a symbol that describes the context at the point: |
5138 ;; 'decl In a comma-separated declaration context (typically | 5148 ;; 'decl In a comma-separated declaration context (typically |
5139 ;; inside a function declaration arglist). | 5149 ;; inside a function declaration arglist). |
5140 ;; '<> In an angle bracket arglist. | 5150 ;; '<> In an angle bracket arglist. |
5141 ;; 'arglist Some other type of arglist. | 5151 ;; 'arglist Some other type of arglist. |
5142 ;; nil Some other context or unknown context. | 5152 ;; nil Some other context or unknown context. Includes |
5153 ;; within the parens of an if, for, ... construct. | |
5143 ;; | 5154 ;; |
5144 ;; LAST-CAST-END is the first token after the closing paren of a | 5155 ;; LAST-CAST-END is the first token after the closing paren of a |
5145 ;; preceding cast, or nil if none is known. If | 5156 ;; preceding cast, or nil if none is known. If |
5146 ;; `c-forward-decl-or-cast-1' is used in succession, it should be | 5157 ;; `c-forward-decl-or-cast-1' is used in succession, it should be |
5147 ;; the position after the closest preceding call where a cast was | 5158 ;; the position after the closest preceding call where a cast was |
5485 | 5496 |
5486 (setq | 5497 (setq |
5487 at-decl-or-cast | 5498 at-decl-or-cast |
5488 (catch 'at-decl-or-cast | 5499 (catch 'at-decl-or-cast |
5489 | 5500 |
5501 ;; CASE 1 | |
5490 (when (> paren-depth 0) | 5502 (when (> paren-depth 0) |
5491 ;; Encountered something inside parens that isn't matched by | 5503 ;; Encountered something inside parens that isn't matched by |
5492 ;; the `c-type-decl-*' regexps, so it's not a type decl | 5504 ;; the `c-type-decl-*' regexps, so it's not a type decl |
5493 ;; expression. Try to skip out to the same paren depth to | 5505 ;; expression. Try to skip out to the same paren depth to |
5494 ;; not confuse the cast check below. | 5506 ;; not confuse the cast check below. |
5508 ;; signs before less certain ones. | 5520 ;; signs before less certain ones. |
5509 | 5521 |
5510 (if got-identifier | 5522 (if got-identifier |
5511 (progn | 5523 (progn |
5512 | 5524 |
5525 ;; CASE 2 | |
5513 (when (and (or at-type maybe-typeless) | 5526 (when (and (or at-type maybe-typeless) |
5514 (not (or got-prefix got-parens))) | 5527 (not (or got-prefix got-parens))) |
5515 ;; Got another identifier directly after the type, so it's a | 5528 ;; Got another identifier directly after the type, so it's a |
5516 ;; declaration. | 5529 ;; declaration. |
5517 (throw 'at-decl-or-cast t)) | 5530 (throw 'at-decl-or-cast t)) |
5534 ;; Found no identifier. | 5547 ;; Found no identifier. |
5535 | 5548 |
5536 (if backup-at-type | 5549 (if backup-at-type |
5537 (progn | 5550 (progn |
5538 | 5551 |
5552 ;; CASE 3 | |
5539 (when (= (point) start) | 5553 (when (= (point) start) |
5540 ;; Got a plain list of identifiers. If a colon follows it's | 5554 ;; Got a plain list of identifiers. If a colon follows it's |
5541 ;; a valid label. Otherwise the last one probably is the | 5555 ;; a valid label. Otherwise the last one probably is the |
5542 ;; declared identifier and we should back up to the previous | 5556 ;; declared identifier and we should back up to the previous |
5543 ;; type, providing it isn't a cast. | 5557 ;; type, providing it isn't a cast. |
5546 ;; declaration regardless. | 5560 ;; declaration regardless. |
5547 (throw 'at-decl-or-cast (eq at-decl-or-cast t)) | 5561 (throw 'at-decl-or-cast (eq at-decl-or-cast t)) |
5548 (setq backup-if-not-cast t) | 5562 (setq backup-if-not-cast t) |
5549 (throw 'at-decl-or-cast t))) | 5563 (throw 'at-decl-or-cast t))) |
5550 | 5564 |
5565 ;; CASE 4 | |
5551 (when (and got-suffix | 5566 (when (and got-suffix |
5552 (not got-prefix) | 5567 (not got-prefix) |
5553 (not got-parens)) | 5568 (not got-parens)) |
5554 ;; Got a plain list of identifiers followed by some suffix. | 5569 ;; Got a plain list of identifiers followed by some suffix. |
5555 ;; If this isn't a cast then the last identifier probably is | 5570 ;; If this isn't a cast then the last identifier probably is |
5556 ;; the declared one and we should back up to the previous | 5571 ;; the declared one and we should back up to the previous |
5557 ;; type. | 5572 ;; type. |
5558 (setq backup-if-not-cast t) | 5573 (setq backup-if-not-cast t) |
5559 (throw 'at-decl-or-cast t))) | 5574 (throw 'at-decl-or-cast t))) |
5560 | 5575 |
5576 ;; CASE 5 | |
5561 (when (eq at-type t) | 5577 (when (eq at-type t) |
5562 ;; If the type is known we know that there can't be any | 5578 ;; If the type is known we know that there can't be any |
5563 ;; identifier somewhere else, and it's only in declarations in | 5579 ;; identifier somewhere else, and it's only in declarations in |
5564 ;; e.g. function prototypes and in casts that the identifier may | 5580 ;; e.g. function prototypes and in casts that the identifier may |
5565 ;; be left out. | 5581 ;; be left out. |
5566 (throw 'at-decl-or-cast t)) | 5582 (throw 'at-decl-or-cast t)) |
5567 | 5583 |
5568 (when (= (point) start) | 5584 (when (= (point) start) |
5569 ;; Only got a single identifier (parsed as a type so far). | 5585 ;; Only got a single identifier (parsed as a type so far). |
5586 ;; CASE 6 | |
5570 (if (and | 5587 (if (and |
5571 ;; Check that the identifier isn't at the start of an | 5588 ;; Check that the identifier isn't at the start of an |
5572 ;; expression. | 5589 ;; expression. |
5573 at-decl-end | 5590 at-decl-end |
5574 (cond | 5591 (cond |
5585 ;; Inside a template arglist. Accept known and found | 5602 ;; Inside a template arglist. Accept known and found |
5586 ;; types; other identifiers could just as well be | 5603 ;; types; other identifiers could just as well be |
5587 ;; constants in C++. | 5604 ;; constants in C++. |
5588 (memq at-type '(known found))))) | 5605 (memq at-type '(known found))))) |
5589 (throw 'at-decl-or-cast t) | 5606 (throw 'at-decl-or-cast t) |
5607 ;; CASE 7 | |
5590 ;; Can't be a valid declaration or cast, but if we've found a | 5608 ;; Can't be a valid declaration or cast, but if we've found a |
5591 ;; specifier it can't be anything else either, so treat it as | 5609 ;; specifier it can't be anything else either, so treat it as |
5592 ;; an invalid/unfinished declaration or cast. | 5610 ;; an invalid/unfinished declaration or cast. |
5593 (throw 'at-decl-or-cast at-decl-or-cast)))) | 5611 (throw 'at-decl-or-cast at-decl-or-cast)))) |
5594 | 5612 |
5618 ;; recognize it at all, so it's better to try it as an abstract | 5636 ;; recognize it at all, so it's better to try it as an abstract |
5619 ;; declarator instead. | 5637 ;; declarator instead. |
5620 (c-fdoc-shift-type-backward) | 5638 (c-fdoc-shift-type-backward) |
5621 | 5639 |
5622 ;; Still no identifier. | 5640 ;; Still no identifier. |
5623 | 5641 ;; CASE 8 |
5624 (when (and got-prefix (or got-parens got-suffix)) | 5642 (when (and got-prefix (or got-parens got-suffix)) |
5625 ;; Require `got-prefix' together with either `got-parens' or | 5643 ;; Require `got-prefix' together with either `got-parens' or |
5626 ;; `got-suffix' to recognize it as an abstract declarator: | 5644 ;; `got-suffix' to recognize it as an abstract declarator: |
5627 ;; `got-parens' only is probably an empty function call. | 5645 ;; `got-parens' only is probably an empty function call. |
5628 ;; `got-suffix' only can build an ordinary expression together | 5646 ;; `got-suffix' only can build an ordinary expression together |
5631 ;; easily occur temporarily while writing an expression so we | 5649 ;; easily occur temporarily while writing an expression so we |
5632 ;; avoid that case anyway. We could do a better job if we knew | 5650 ;; avoid that case anyway. We could do a better job if we knew |
5633 ;; the point when the fontification was invoked. | 5651 ;; the point when the fontification was invoked. |
5634 (throw 'at-decl-or-cast t)) | 5652 (throw 'at-decl-or-cast t)) |
5635 | 5653 |
5654 ;; CASE 9 | |
5636 (when (and at-type | 5655 (when (and at-type |
5637 (not got-prefix) | 5656 (not got-prefix) |
5638 (not got-parens) | 5657 (not got-parens) |
5639 got-suffix-after-parens | 5658 got-suffix-after-parens |
5640 (eq (char-after got-suffix-after-parens) ?\()) | 5659 (eq (char-after got-suffix-after-parens) ?\()) |
5641 ;; Got a type, no declarator but a paren suffix. I.e. it's a | 5660 ;; Got a type, no declarator but a paren suffix. I.e. it's a |
5642 ;; normal function call afterall (or perhaps a C++ style object | 5661 ;; normal function call afterall (or perhaps a C++ style object |
5643 ;; instantiation expression). | 5662 ;; instantiation expression). |
5644 (throw 'at-decl-or-cast nil)))) | 5663 (throw 'at-decl-or-cast nil)))) |
5645 | 5664 |
5665 ;; CASE 10 | |
5646 (when at-decl-or-cast | 5666 (when at-decl-or-cast |
5647 ;; By now we've located the type in the declaration that we know | 5667 ;; By now we've located the type in the declaration that we know |
5648 ;; we're in. | 5668 ;; we're in. |
5649 (throw 'at-decl-or-cast t)) | 5669 (throw 'at-decl-or-cast t)) |
5650 | 5670 |
5671 ;; CASE 11 | |
5651 (when (and got-identifier | 5672 (when (and got-identifier |
5652 (not context) | 5673 (not context) |
5653 (looking-at c-after-suffixed-type-decl-key) | 5674 (looking-at c-after-suffixed-type-decl-key) |
5654 (if (and got-parens | 5675 (if (and got-parens |
5655 (not got-prefix) | 5676 (not got-prefix) |
5664 (progn (c-fdoc-shift-type-backward) t) | 5685 (progn (c-fdoc-shift-type-backward) t) |
5665 got-suffix-after-parens)) | 5686 got-suffix-after-parens)) |
5666 ;; A declaration according to `c-after-suffixed-type-decl-key'. | 5687 ;; A declaration according to `c-after-suffixed-type-decl-key'. |
5667 (throw 'at-decl-or-cast t)) | 5688 (throw 'at-decl-or-cast t)) |
5668 | 5689 |
5690 ;; CASE 12 | |
5669 (when (and (or got-prefix (not got-parens)) | 5691 (when (and (or got-prefix (not got-parens)) |
5670 (memq at-type '(t known))) | 5692 (memq at-type '(t known))) |
5671 ;; It's a declaration if a known type precedes it and it can't be a | 5693 ;; It's a declaration if a known type precedes it and it can't be a |
5672 ;; function call. | 5694 ;; function call. |
5673 (throw 'at-decl-or-cast t)) | 5695 (throw 'at-decl-or-cast t)) |
5694 (throw 'at-decl-or-cast at-decl-or-cast)) | 5716 (throw 'at-decl-or-cast at-decl-or-cast)) |
5695 | 5717 |
5696 ;; Below are tests that only should be applied when we're certain to | 5718 ;; Below are tests that only should be applied when we're certain to |
5697 ;; not have parsed halfway through an expression. | 5719 ;; not have parsed halfway through an expression. |
5698 | 5720 |
5721 ;; CASE 14 | |
5699 (when (memq at-type '(t known)) | 5722 (when (memq at-type '(t known)) |
5700 ;; The expression starts with a known type so treat it as a | 5723 ;; The expression starts with a known type so treat it as a |
5701 ;; declaration. | 5724 ;; declaration. |
5702 (throw 'at-decl-or-cast t)) | 5725 (throw 'at-decl-or-cast t)) |
5703 | 5726 |
5727 ;; CASE 15 | |
5704 (when (and (c-major-mode-is 'c++-mode) | 5728 (when (and (c-major-mode-is 'c++-mode) |
5705 ;; In C++ we check if the identifier is a known type, since | 5729 ;; In C++ we check if the identifier is a known type, since |
5706 ;; (con|de)structors use the class name as identifier. | 5730 ;; (con|de)structors use the class name as identifier. |
5707 ;; We've always shifted over the identifier as a type and | 5731 ;; We've always shifted over the identifier as a type and |
5708 ;; then backed up again in this case. | 5732 ;; then backed up again in this case. |
5732 (point)))))))) | 5756 (point)))))))) |
5733 (throw 'at-decl-or-cast t)) | 5757 (throw 'at-decl-or-cast t)) |
5734 | 5758 |
5735 (if got-identifier | 5759 (if got-identifier |
5736 (progn | 5760 (progn |
5761 ;; CASE 16 | |
5737 (when (and got-prefix-before-parens | 5762 (when (and got-prefix-before-parens |
5738 at-type | 5763 at-type |
5739 (or at-decl-end (looking-at "=[^=]")) | 5764 (or at-decl-end (looking-at "=[^=]")) |
5740 (not context) | 5765 (not context) |
5741 (not got-suffix)) | 5766 (not got-suffix)) |
5744 ;; result isn't used. We therefore choose to recognize it as | 5769 ;; result isn't used. We therefore choose to recognize it as |
5745 ;; a declaration. Do not allow a suffix since it could then | 5770 ;; a declaration. Do not allow a suffix since it could then |
5746 ;; be a function call. | 5771 ;; be a function call. |
5747 (throw 'at-decl-or-cast t)) | 5772 (throw 'at-decl-or-cast t)) |
5748 | 5773 |
5774 ;; CASE 17 | |
5749 (when (and (or got-suffix-after-parens | 5775 (when (and (or got-suffix-after-parens |
5750 (looking-at "=[^=]")) | 5776 (looking-at "=[^=]")) |
5751 (eq at-type 'found) | 5777 (eq at-type 'found) |
5752 (not (eq context 'arglist))) | 5778 (not (eq context 'arglist))) |
5753 ;; Got something like "a (*b) (c);" or "a (b) = c;". It could | 5779 ;; Got something like "a (*b) (c);" or "a (b) = c;". It could |
5754 ;; be an odd expression or it could be a declaration. Treat | 5780 ;; be an odd expression or it could be a declaration. Treat |
5755 ;; it as a declaration if "a" has been used as a type | 5781 ;; it as a declaration if "a" has been used as a type |
5756 ;; somewhere else (if it's a known type we won't get here). | 5782 ;; somewhere else (if it's a known type we won't get here). |
5757 (throw 'at-decl-or-cast t))) | 5783 (throw 'at-decl-or-cast t))) |
5758 | 5784 |
5785 ;; CASE 18 | |
5759 (when (and context | 5786 (when (and context |
5760 (or got-prefix | 5787 (or got-prefix |
5761 (and (eq context 'decl) | 5788 (and (eq context 'decl) |
5762 (not c-recognize-paren-inits) | 5789 (not c-recognize-paren-inits) |
5763 (or got-parens got-suffix)))) | 5790 (or got-parens got-suffix)))) |
6243 (backward-up-list 1) | 6270 (backward-up-list 1) |
6244 (c-beginning-of-statement-1 (point-min) nil t) | 6271 (c-beginning-of-statement-1 (point-min) nil t) |
6245 (looking-at c-opt-asm-stmt-key)))) | 6272 (looking-at c-opt-asm-stmt-key)))) |
6246 | 6273 |
6247 (defun c-at-toplevel-p () | 6274 (defun c-at-toplevel-p () |
6248 "Return a determination as to whether point is at the `top-level'. | 6275 "Return a determination as to whether point is \"at the top level\". |
6249 Being at the top-level means that point is either outside any | 6276 Informally, \"at the top level\" is anywhere where you can write |
6250 enclosing block (such function definition), or only inside a class, | 6277 a function. |
6251 namespace or other block that contains another declaration level. | 6278 |
6279 More precisely, being at the top-level means that point is either | |
6280 outside any enclosing block (such as a function definition), or | |
6281 directly inside a class, namespace or other block that contains | |
6282 another declaration level. | |
6252 | 6283 |
6253 If point is not at the top-level (e.g. it is inside a method | 6284 If point is not at the top-level (e.g. it is inside a method |
6254 definition), then nil is returned. Otherwise, if point is at a | 6285 definition), then nil is returned. Otherwise, if point is at a |
6255 top-level not enclosed within a class definition, t is returned. | 6286 top-level not enclosed within a class definition, t is returned. |
6256 Otherwise, a 2-vector is returned where the zeroth element is the | 6287 Otherwise, a 2-vector is returned where the zeroth element is the |
8176 | 8207 |
8177 ;; CASE 5D: this could be a top-level initialization, a | 8208 ;; CASE 5D: this could be a top-level initialization, a |
8178 ;; member init list continuation, or a template argument | 8209 ;; member init list continuation, or a template argument |
8179 ;; list continuation. | 8210 ;; list continuation. |
8180 ((save-excursion | 8211 ((save-excursion |
8181 ;; Note: We use the fact that lim always is after any | 8212 ;; Note: We use the fact that lim is always after any |
8182 ;; preceding brace sexp. | 8213 ;; preceding brace sexp. |
8183 (if c-recognize-<>-arglists | 8214 (if c-recognize-<>-arglists |
8184 (while (and | 8215 (while (and |
8185 (progn | 8216 (progn |
8186 (c-syntactic-skip-backward "^;,=<>" lim t) | 8217 (c-syntactic-skip-backward "^;,=<>" lim t) |