Annotation of OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el, Revision 1.1
1.1 ! takayama 1: ;; -*- mode: emacs-lisp -*-
! 2: ;;
! 3: ;; asir-mode.el -- asir mode
! 4: ;;
! 5: ;; $OpenXM$
! 6:
! 7: ;; This program is free software: you can redistribute it and/or modify
! 8: ;; it under the terms of the GNU General Public License as published by
! 9: ;; the Free Software Foundation, either version 3 of the License, or
! 10: ;; (at your option) any later version.
! 11:
! 12: ;;;; AsirGUI for Windows
! 13: (defconst asir-exec-path-default '("~/Desktop/asir/bin" "c:/Program Files/asir/bin" "c:/Program Files (x64)/asir/bin" "c:/asir/bin")
! 14: "Default Search path for asir binary in Windows")
! 15:
! 16: (defvar asir-exec-path asir-exec-path-default
! 17: "Search path for asir binary")
! 18:
! 19: (defun asir-effective-exec-path ()
! 20: "Search path for command"
! 21: (let* ((dir (getenv "ASIR_ROOTDIR"))
! 22: (path (append asir-exec-path exec-path)))
! 23: (if dir (cons (concat dir "/bin") path) path)))
! 24:
! 25: (defun asir-executable-find (command)
! 26: "Search for command"
! 27: (let* ((exec-path (asir-effective-exec-path)))
! 28: (executable-find command)))
! 29:
! 30: (defun asir-start-asirgui ()
! 31: "Run asirgui"
! 32: (interactive)
! 33: (let ((exec-path (asir-effective-exec-path)))
! 34: (start-process "asir-proc-asirgui" nil "asirgui")))
! 35:
! 36: (defun asir-terminate-asirgui ()
! 37: "Execute the current buffer on asir"
! 38: (interactive)
! 39: (let ((exec-path (asir-effective-exec-path)))
! 40: (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit")))
! 41:
! 42: (defun asir-execute-current-buffer-on-asir ()
! 43: "Execute the current buffer on asir"
! 44: (interactive)
! 45: (let ((exec-path (asir-effective-exec-path)))
! 46: (start-process "asir-proc-cmdasir" nil "cmdasir" (buffer-file-name))))
! 47:
! 48: (defun asir-execute-region-on-asir ()
! 49: "Execute the region on asir"
! 50: (interactive)
! 51: (save-excursion
! 52: (if mark-active
! 53: (let ((exec-path (asir-effective-exec-path))
! 54: (temp-file (make-temp-file (format "%s/cmdasir-" (getenv "TEMP")))))
! 55: (write-region (region-beginning) (region-end) temp-file)
! 56: (start-process "asir-proc-cmdasir" nil "cmdasir" temp-file)))))
! 57:
! 58: ;;;; Extension for CC-mode.
! 59:
! 60: (require 'cc-mode)
! 61:
! 62: (eval-when-compile
! 63: (require 'cc-langs)
! 64: (require 'cc-engine)
! 65: (require 'cc-fonts))
! 66:
! 67: (eval-and-compile
! 68: ;; Make our mode known to the language constant system. Use Java
! 69: ;; mode as the fallback for the constants we don't change here.
! 70: ;; This needs to be done also at compile time since the language
! 71: ;; constants are evaluated then.
! 72: (c-add-language 'asir-mode 'c++-mode))
! 73:
! 74: (c-lang-defconst c-stmt-delim-chars asir "^;${}?:")
! 75: (c-lang-defconst c-stmt-delim-chars-with-comma asir "^;$,{}?:")
! 76: (c-lang-defconst c-other-op-syntax-tokens
! 77: asir (cons "$" (c-lang-const c-other-op-syntax-tokens c)))
! 78: (c-lang-defconst c-identifier-syntax-modifications
! 79: asir (remove '(?$ . "w") (c-lang-const c-identifier-syntax-modifications c)))
! 80: (c-lang-defconst c-symbol-chars asir (concat c-alnum "_"))
! 81:
! 82: (c-lang-defconst c-primitive-type-kwds asir '("def" "extern" "static" "localf" "function"))
! 83: (c-lang-defconst c-primitive-type-prefix-kwds asir nil)
! 84: (c-lang-defconst c-type-list-kwds asir nil)
! 85: (c-lang-defconst c-class-decl-kwds asir '("module"))
! 86: (c-lang-defconst c-othe-decl-kwds asir '("endmodule" "end"))
! 87: (c-lang-defconst c-type-modifier-kwds asir nil)
! 88: (c-lang-defconst c-modifier-kwds asir nil)
! 89:
! 90: (c-lang-defconst c-mode-menu
! 91: asir
! 92: (append (c-lang-const c-mode-menu c)
! 93: '("----"
! 94: ["Start asirgui" asir-start-asirgui (eq system-type 'windows-nt)]
! 95: ["Terminate asirgui" asir-terminate-asirgui (eq system-type 'windows-nt)]
! 96: ["Execute the current buffer on asir" asir-execute-current-buffer-on-asir
! 97: (and (eq system-type 'windows-nt) (buffer-file-name))]
! 98: ["Execute the region on asir" asir-execute-region-on-asir
! 99: (and (eq system-type 'windows-nt) mark-active)]
! 100: )))
! 101:
! 102: (defvar asir-font-lock-extra-types nil
! 103: "*List of extra types (aside from the type keywords) to recognize in asir mode.
! 104: Each list item should be a regexp matching a single identifier.")
! 105:
! 106: (defconst asir-font-lock-keywords-1 (c-lang-const c-matchers-1 asir)
! 107: "Minimal highlighting for asir mode.")
! 108:
! 109: (defconst asir-font-lock-keywords-2 (c-lang-const c-matchers-2 asir)
! 110: "Fast normal highlighting for asir mode.")
! 111:
! 112: (defconst asir-font-lock-keywords-3 (c-lang-const c-matchers-3 asir)
! 113: "Accurate normal highlighting for asir mode.")
! 114:
! 115: (defvar asir-font-lock-keywords asir-font-lock-keywords-3
! 116: "Default expressions to highlight in asir mode.")
! 117:
! 118: (defvar asir-mode-syntax-table nil
! 119: "Syntax table used in asir-mode buffers.")
! 120: (or asir-mode-syntax-table
! 121: (setq asir-mode-syntax-table
! 122: (funcall (c-lang-const c-make-mode-syntax-table asir))))
! 123:
! 124: (defvar asir-mode-abbrev-table nil
! 125: "Abbreviation table used in asir-mode buffers.")
! 126:
! 127: (defvar asir-mode-map (let ((map (c-make-inherited-keymap)))
! 128: ;; Add bindings which are only useful for asir
! 129: map)
! 130: "Keymap used in asir-mode buffers.")
! 131:
! 132: (easy-menu-define asir-menu asir-mode-map "asir Mode Commands"
! 133: ;; Can use `asir' as the language for `c-mode-menu'
! 134: ;; since its definition covers any language. In
! 135: ;; this case the language is used to adapt to the
! 136: ;; nonexistence of a cpp pass and thus removing some
! 137: ;; irrelevant menu alternatives.
! 138: (cons "Asir" (c-lang-const c-mode-menu asir)))
! 139:
! 140: (defun asir-mode ()
! 141: "Major mode for editing asir code.
! 142: This is a simple example of a separate mode derived from CC Mode to
! 143: support a language with syntax similar to C/C++/ObjC/Java/IDL/Pike.
! 144:
! 145: The hook `c-mode-common-hook' is run with no args at mode
! 146: initialization, then `asir-mode-hook'.
! 147:
! 148: Key bindings:
! 149: \\{asir-mode-map}"
! 150: (interactive)
! 151: (kill-all-local-variables)
! 152: (c-initialize-cc-mode t)
! 153: (set-syntax-table asir-mode-syntax-table)
! 154: (setq major-mode 'asir-mode
! 155: mode-name "asir"
! 156: local-abbrev-table asir-mode-abbrev-table
! 157: abbrev-mode t)
! 158: (use-local-map asir-mode-map)
! 159: ;; `c-init-language-vars' is a macro that is expanded at compile
! 160: ;; time to a large `setq' with all the language variables and their
! 161: ;; customized values for our language.
! 162: (c-init-language-vars asir-mode)
! 163: ;; `c-common-init' initializes most of the components of a CC Mode
! 164: ;; buffer, including setup of the mode menu, font-lock, etc.
! 165: ;; There's also a lower level routine `c-basic-common-init' that
! 166: ;; only makes the necessary initialization to get the syntactic
! 167: ;; analysis and similar things working.
! 168: (c-common-init 'asir-mode)
! 169: ;;(easy-menu-add asir-menu)
! 170: (run-hooks 'c-mode-common-hook)
! 171: (run-hooks 'asir-mode-hook)
! 172: (c-update-modeline))
! 173:
! 174: (if (fboundp 'asir-backup:c-guess-basic-syntax)
! 175: nil
! 176: (fset 'asir-backup:c-guess-basic-syntax (symbol-function 'c-guess-basic-syntax))
! 177: (defun c-guess-basic-syntax ()
! 178: "A modified c-guess-basic-syntax for asir-mode"
! 179: (if (eq major-mode 'asir-mode)
! 180: (asir-c-guess-basic-syntax)
! 181: (asir-backup:c-guess-basic-syntax))))
! 182:
! 183: ;; Meadow 3 does not have `c-brace-anchor-point'
! 184: ;; This function was copied from cc-engine.el of Emacs 23.4
! 185: (if (and (featurep 'meadow) (not (fboundp 'c-brace-anchor-point)))
! 186: (defun c-brace-anchor-point (bracepos)
! 187: ;; BRACEPOS is the position of a brace in a construct like "namespace
! 188: ;; Bar {". Return the anchor point in this construct; this is the
! 189: ;; earliest symbol on the brace's line which isn't earlier than
! 190: ;; "namespace".
! 191: ;;
! 192: ;; Currently (2007-08-17), "like namespace" means "matches
! 193: ;; c-other-block-decl-kwds". It doesn't work with "class" or "struct"
! 194: ;; or anything like that.
! 195: (save-excursion
! 196: (let ((boi (c-point 'boi bracepos)))
! 197: (goto-char bracepos)
! 198: (while (and (> (point) boi)
! 199: (not (looking-at c-other-decl-block-key)))
! 200: (c-backward-token-2))
! 201: (if (> (point) boi) (point) boi))))
! 202: )
! 203:
! 204: ;; The function `c-guess-basic-syntax' was copied from cc-engine.el of Emacs 23.4 and
! 205: ;; was modified for Risa/Asir.
! 206: ;; CASE 5D, 5J, 18 are corrected.
! 207:
! 208: ;;;; Beginning of `asir-c-guess-basic-syntax'
! 209: (defun asir-c-guess-basic-syntax ()
! 210: "Return the syntactic context of the current line."
! 211: (save-excursion
! 212: (beginning-of-line)
! 213: (c-save-buffer-state
! 214: ((indent-point (point))
! 215: (case-fold-search nil)
! 216: ;; A whole ugly bunch of various temporary variables. Have
! 217: ;; to declare them here since it's not possible to declare
! 218: ;; a variable with only the scope of a cond test and the
! 219: ;; following result clauses, and most of this function is a
! 220: ;; single gigantic cond. :P
! 221: literal char-before-ip before-ws-ip char-after-ip macro-start
! 222: in-macro-expr c-syntactic-context placeholder c-in-literal-cache
! 223: step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos
! 224: containing-<
! 225: ;; The following record some positions for the containing
! 226: ;; declaration block if we're directly within one:
! 227: ;; `containing-decl-open' is the position of the open
! 228: ;; brace. `containing-decl-start' is the start of the
! 229: ;; declaration. `containing-decl-kwd' is the keyword
! 230: ;; symbol of the keyword that tells what kind of block it
! 231: ;; is.
! 232: containing-decl-open
! 233: containing-decl-start
! 234: containing-decl-kwd
! 235: ;; The open paren of the closest surrounding sexp or nil if
! 236: ;; there is none.
! 237: containing-sexp
! 238: ;; The position after the closest preceding brace sexp
! 239: ;; (nested sexps are ignored), or the position after
! 240: ;; `containing-sexp' if there is none, or (point-min) if
! 241: ;; `containing-sexp' is nil.
! 242: lim
! 243: ;; The paren state outside `containing-sexp', or at
! 244: ;; `indent-point' if `containing-sexp' is nil.
! 245: (paren-state (c-parse-state))
! 246: ;; There's always at most one syntactic element which got
! 247: ;; an anchor pos. It's stored in syntactic-relpos.
! 248: syntactic-relpos
! 249: (c-stmt-delim-chars c-stmt-delim-chars))
! 250:
! 251: ;; Check if we're directly inside an enclosing declaration
! 252: ;; level block.
! 253: (when (and (setq containing-sexp
! 254: (c-most-enclosing-brace paren-state))
! 255: (progn
! 256: (goto-char containing-sexp)
! 257: (eq (char-after) ?{))
! 258: (setq placeholder
! 259: (c-looking-at-decl-block
! 260: (c-most-enclosing-brace paren-state
! 261: containing-sexp)
! 262: t)))
! 263: (setq containing-decl-open containing-sexp
! 264: containing-decl-start (point)
! 265: containing-sexp nil)
! 266: (goto-char placeholder)
! 267: (setq containing-decl-kwd (and (looking-at c-keywords-regexp)
! 268: (c-keyword-sym (match-string 1)))))
! 269:
! 270: ;; Init some position variables.
! 271: (if c-state-cache
! 272: (progn
! 273: (setq containing-sexp (car paren-state)
! 274: paren-state (cdr paren-state))
! 275: (if (consp containing-sexp)
! 276: (progn
! 277: (setq lim (cdr containing-sexp))
! 278: (if (cdr c-state-cache)
! 279: ;; Ignore balanced paren. The next entry
! 280: ;; can't be another one.
! 281: (setq containing-sexp (car (cdr c-state-cache))
! 282: paren-state (cdr paren-state))
! 283: ;; If there is no surrounding open paren then
! 284: ;; put the last balanced pair back on paren-state.
! 285: (setq paren-state (cons containing-sexp paren-state)
! 286: containing-sexp nil)))
! 287: (setq lim (1+ containing-sexp))))
! 288: (setq lim (point-min)))
! 289:
! 290: ;; If we're in a parenthesis list then ',' delimits the
! 291: ;; "statements" rather than being an operator (with the
! 292: ;; exception of the "for" clause). This difference is
! 293: ;; typically only noticeable when statements are used in macro
! 294: ;; arglists.
! 295: (when (and containing-sexp
! 296: (eq (char-after containing-sexp) ?\())
! 297: (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
! 298:
! 299: ;; cache char before and after indent point, and move point to
! 300: ;; the most likely position to perform the majority of tests
! 301: (goto-char indent-point)
! 302: (c-backward-syntactic-ws lim)
! 303: (setq before-ws-ip (point)
! 304: char-before-ip (char-before))
! 305: (goto-char indent-point)
! 306: (skip-chars-forward " \t")
! 307: (setq char-after-ip (char-after))
! 308:
! 309: ;; are we in a literal?
! 310: (setq literal (c-in-literal lim))
! 311:
! 312: ;; now figure out syntactic qualities of the current line
! 313: (cond
! 314:
! 315: ;; CASE 1: in a string.
! 316: ((eq literal 'string)
! 317: (c-add-syntax 'string (c-point 'bopl)))
! 318:
! 319: ;; CASE 2: in a C or C++ style comment.
! 320: ((and (memq literal '(c c++))
! 321: ;; This is a kludge for XEmacs where we use
! 322: ;; `buffer-syntactic-context', which doesn't correctly
! 323: ;; recognize "\*/" to end a block comment.
! 324: ;; `parse-partial-sexp' which is used by
! 325: ;; `c-literal-limits' will however do that in most
! 326: ;; versions, which results in that we get nil from
! 327: ;; `c-literal-limits' even when `c-in-literal' claims
! 328: ;; we're inside a comment.
! 329: (setq placeholder (c-literal-limits lim)))
! 330: (c-add-syntax literal (car placeholder)))
! 331:
! 332: ;; CASE 3: in a cpp preprocessor macro continuation.
! 333: ((and (save-excursion
! 334: (when (c-beginning-of-macro)
! 335: (setq macro-start (point))))
! 336: (/= macro-start (c-point 'boi))
! 337: (progn
! 338: (setq tmpsymbol 'cpp-macro-cont)
! 339: (or (not c-syntactic-indentation-in-macros)
! 340: (save-excursion
! 341: (goto-char macro-start)
! 342: ;; If at the beginning of the body of a #define
! 343: ;; directive then analyze as cpp-define-intro
! 344: ;; only. Go on with the syntactic analysis
! 345: ;; otherwise. in-macro-expr is set if we're in a
! 346: ;; cpp expression, i.e. before the #define body
! 347: ;; or anywhere in a non-#define directive.
! 348: (if (c-forward-to-cpp-define-body)
! 349: (let ((indent-boi (c-point 'boi indent-point)))
! 350: (setq in-macro-expr (> (point) indent-boi)
! 351: tmpsymbol 'cpp-define-intro)
! 352: (= (point) indent-boi))
! 353: (setq in-macro-expr t)
! 354: nil)))))
! 355: (c-add-syntax tmpsymbol macro-start)
! 356: (setq macro-start nil))
! 357:
! 358: ;; CASE 11: an else clause?
! 359: ((looking-at "else\\>[^_]")
! 360: (c-beginning-of-statement-1 containing-sexp)
! 361: (c-add-stmt-syntax 'else-clause nil t
! 362: containing-sexp paren-state))
! 363:
! 364: ;; CASE 12: while closure of a do/while construct?
! 365: ((and (looking-at "while\\>[^_]")
! 366: (save-excursion
! 367: (prog1 (eq (c-beginning-of-statement-1 containing-sexp)
! 368: 'beginning)
! 369: (setq placeholder (point)))))
! 370: (goto-char placeholder)
! 371: (c-add-stmt-syntax 'do-while-closure nil t
! 372: containing-sexp paren-state))
! 373:
! 374: ;; CASE 13: A catch or finally clause? This case is simpler
! 375: ;; than if-else and do-while, because a block is required
! 376: ;; after every try, catch and finally.
! 377: ((save-excursion
! 378: (and (cond ((c-major-mode-is 'c++-mode)
! 379: (looking-at "catch\\>[^_]"))
! 380: ((c-major-mode-is 'java-mode)
! 381: (looking-at "\\(catch\\|finally\\)\\>[^_]")))
! 382: (and (c-safe (c-backward-syntactic-ws)
! 383: (c-backward-sexp)
! 384: t)
! 385: (eq (char-after) ?{)
! 386: (c-safe (c-backward-syntactic-ws)
! 387: (c-backward-sexp)
! 388: t)
! 389: (if (eq (char-after) ?\()
! 390: (c-safe (c-backward-sexp) t)
! 391: t))
! 392: (looking-at "\\(try\\|catch\\)\\>[^_]")
! 393: (setq placeholder (point))))
! 394: (goto-char placeholder)
! 395: (c-add-stmt-syntax 'catch-clause nil t
! 396: containing-sexp paren-state))
! 397:
! 398: ;; CASE 18: A substatement we can recognize by keyword.
! 399: ((save-excursion
! 400: (and c-opt-block-stmt-key
! 401: (not (eq char-before-ip ?\;))
! 402: (not (c-at-vsemi-p before-ws-ip))
! 403: (not (memq char-after-ip '(?\) ?\] ?,)))
! 404: (or (not (eq char-before-ip ?}))
! 405: (c-looking-at-inexpr-block-backward c-state-cache))
! 406: (> (point)
! 407: (progn
! 408: ;; Ought to cache the result from the
! 409: ;; c-beginning-of-statement-1 calls here.
! 410: (setq placeholder (point))
! 411: (while (eq (setq step-type
! 412: (c-beginning-of-statement-1 lim))
! 413: 'label))
! 414: (if (eq step-type 'previous)
! 415: (goto-char placeholder)
! 416: (setq placeholder (point))
! 417: (if (and (eq step-type 'same)
! 418: (not (looking-at c-opt-block-stmt-key)))
! 419: ;; Step up to the containing statement if we
! 420: ;; stayed in the same one.
! 421: (let (step)
! 422: (while (eq
! 423: (setq step
! 424: (c-beginning-of-statement-1 lim))
! 425: 'label))
! 426: (if (eq step 'up)
! 427: (setq placeholder (point))
! 428: ;; There was no containing statement after all.
! 429: (goto-char placeholder)))))
! 430: placeholder))
! 431: (if (looking-at c-block-stmt-2-key)
! 432: ;; Require a parenthesis after these keywords.
! 433: ;; Necessary to catch e.g. synchronized in Java,
! 434: ;; which can be used both as statement and
! 435: ;; modifier.
! 436: (and (zerop (c-forward-token-2 1 nil))
! 437: (eq (char-after) ?\())
! 438: (looking-at c-opt-block-stmt-key))))
! 439:
! 440: (if (eq step-type 'up)
! 441: ;; CASE 18A: Simple substatement.
! 442: (progn
! 443: (goto-char placeholder)
! 444: (cond
! 445: ((eq char-after-ip ?{)
! 446: (c-add-stmt-syntax 'substatement-open nil nil
! 447: containing-sexp paren-state))
! 448: ((save-excursion
! 449: (goto-char indent-point)
! 450: (back-to-indentation)
! 451: (c-forward-label))
! 452: (c-add-stmt-syntax 'substatement-label nil nil
! 453: containing-sexp paren-state))
! 454: (t
! 455: (c-add-stmt-syntax 'substatement nil nil
! 456: containing-sexp paren-state))))
! 457:
! 458: ;; CASE 18B: Some other substatement. This is shared
! 459: ;; with case 10.
! 460: (c-guess-continued-construct indent-point
! 461: char-after-ip
! 462: placeholder
! 463: lim
! 464: paren-state)))
! 465:
! 466: ;; CASE 14: A case or default label
! 467: ((looking-at c-label-kwds-regexp)
! 468: (if containing-sexp
! 469: (progn
! 470: (goto-char containing-sexp)
! 471: (setq lim (c-most-enclosing-brace c-state-cache
! 472: containing-sexp))
! 473: (c-backward-to-block-anchor lim)
! 474: (c-add-stmt-syntax 'case-label nil t lim paren-state))
! 475: ;; Got a bogus label at the top level. In lack of better
! 476: ;; alternatives, anchor it on (point-min).
! 477: (c-add-syntax 'case-label (point-min))))
! 478:
! 479: ;; CASE 15: any other label
! 480: ((save-excursion
! 481: (back-to-indentation)
! 482: (and (not (looking-at c-syntactic-ws-start))
! 483: (c-forward-label)))
! 484: (cond (containing-decl-open
! 485: (setq placeholder (c-add-class-syntax 'inclass
! 486: containing-decl-open
! 487: containing-decl-start
! 488: containing-decl-kwd
! 489: paren-state))
! 490: ;; Append access-label with the same anchor point as
! 491: ;; inclass gets.
! 492: (c-append-syntax 'access-label placeholder))
! 493:
! 494: (containing-sexp
! 495: (goto-char containing-sexp)
! 496: (setq lim (c-most-enclosing-brace c-state-cache
! 497: containing-sexp))
! 498: (save-excursion
! 499: (setq tmpsymbol
! 500: (if (and (eq (c-beginning-of-statement-1 lim) 'up)
! 501: (looking-at "switch\\>[^_]"))
! 502: ;; If the surrounding statement is a switch then
! 503: ;; let's analyze all labels as switch labels, so
! 504: ;; that they get lined up consistently.
! 505: 'case-label
! 506: 'label)))
! 507: (c-backward-to-block-anchor lim)
! 508: (c-add-stmt-syntax tmpsymbol nil t lim paren-state))
! 509:
! 510: (t
! 511: ;; A label on the top level. Treat it as a class
! 512: ;; context. (point-min) is the closest we get to the
! 513: ;; class open brace.
! 514: (c-add-syntax 'access-label (point-min)))))
! 515:
! 516: ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and
! 517: ;; 17E.
! 518: ((setq placeholder (c-looking-at-inexpr-block
! 519: (c-safe-position containing-sexp paren-state)
! 520: containing-sexp
! 521: ;; Have to turn on the heuristics after
! 522: ;; the point even though it doesn't work
! 523: ;; very well. C.f. test case class-16.pike.
! 524: t))
! 525: (setq tmpsymbol (assq (car placeholder)
! 526: '((inexpr-class . class-open)
! 527: (inexpr-statement . block-open))))
! 528: (if tmpsymbol
! 529: ;; It's a statement block or an anonymous class.
! 530: (setq tmpsymbol (cdr tmpsymbol))
! 531: ;; It's a Pike lambda. Check whether we are between the
! 532: ;; lambda keyword and the argument list or at the defun
! 533: ;; opener.
! 534: (setq tmpsymbol (if (eq char-after-ip ?{)
! 535: 'inline-open
! 536: 'lambda-intro-cont)))
! 537: (goto-char (cdr placeholder))
! 538: (back-to-indentation)
! 539: (c-add-stmt-syntax tmpsymbol nil t
! 540: (c-most-enclosing-brace c-state-cache (point))
! 541: paren-state)
! 542: (unless (eq (point) (cdr placeholder))
! 543: (c-add-syntax (car placeholder))))
! 544:
! 545: ;; CASE 5: Line is inside a declaration level block or at top level.
! 546: ((or containing-decl-open (null containing-sexp))
! 547: (cond
! 548:
! 549: ;; CASE 5A: we are looking at a defun, brace list, class,
! 550: ;; or inline-inclass method opening brace
! 551: ((setq special-brace-list
! 552: (or (and c-special-brace-lists
! 553: (c-looking-at-special-brace-list))
! 554: (eq char-after-ip ?{)))
! 555: (cond
! 556:
! 557: ;; CASE 5A.1: Non-class declaration block open.
! 558: ((save-excursion
! 559: (let (tmp)
! 560: (and (eq char-after-ip ?{)
! 561: (setq tmp (c-looking-at-decl-block containing-sexp t))
! 562: (progn
! 563: (setq placeholder (point))
! 564: (goto-char tmp)
! 565: (looking-at c-symbol-key))
! 566: (c-keyword-member
! 567: (c-keyword-sym (setq keyword (match-string 0)))
! 568: 'c-other-block-decl-kwds))))
! 569: (goto-char placeholder)
! 570: (c-add-stmt-syntax
! 571: (if (string-equal keyword "extern")
! 572: ;; Special case for extern-lang-open.
! 573: 'extern-lang-open
! 574: (intern (concat keyword "-open")))
! 575: nil t containing-sexp paren-state))
! 576:
! 577: ;; CASE 5A.2: we are looking at a class opening brace
! 578: ((save-excursion
! 579: (goto-char indent-point)
! 580: (skip-chars-forward " \t")
! 581: (and (eq (char-after) ?{)
! 582: (c-looking-at-decl-block containing-sexp t)
! 583: (setq placeholder (point))))
! 584: (c-add-syntax 'class-open placeholder))
! 585:
! 586: ;; CASE 5A.3: brace list open
! 587: ((save-excursion
! 588: (c-beginning-of-decl-1 lim)
! 589: (while (looking-at c-specifier-key)
! 590: (goto-char (match-end 1))
! 591: (c-forward-syntactic-ws indent-point))
! 592: (setq placeholder (c-point 'boi))
! 593: (or (consp special-brace-list)
! 594: (and (or (save-excursion
! 595: (goto-char indent-point)
! 596: (setq tmpsymbol nil)
! 597: (while (and (> (point) placeholder)
! 598: (zerop (c-backward-token-2 1 t))
! 599: (/= (char-after) ?=))
! 600: (and c-opt-inexpr-brace-list-key
! 601: (not tmpsymbol)
! 602: (looking-at c-opt-inexpr-brace-list-key)
! 603: (setq tmpsymbol 'topmost-intro-cont)))
! 604: (eq (char-after) ?=))
! 605: (looking-at c-brace-list-key))
! 606: (save-excursion
! 607: (while (and (< (point) indent-point)
! 608: (zerop (c-forward-token-2 1 t))
! 609: (not (memq (char-after) '(?\; ?\()))))
! 610: (not (memq (char-after) '(?\; ?\()))
! 611: ))))
! 612: (if (and (not c-auto-newline-analysis)
! 613: (c-major-mode-is 'java-mode)
! 614: (eq tmpsymbol 'topmost-intro-cont))
! 615: ;; We're in Java and have found that the open brace
! 616: ;; belongs to a "new Foo[]" initialization list,
! 617: ;; which means the brace list is part of an
! 618: ;; expression and not a top level definition. We
! 619: ;; therefore treat it as any topmost continuation
! 620: ;; even though the semantically correct symbol still
! 621: ;; is brace-list-open, on the same grounds as in
! 622: ;; case B.2.
! 623: (progn
! 624: (c-beginning-of-statement-1 lim)
! 625: (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
! 626: (c-add-syntax 'brace-list-open placeholder)))
! 627:
! 628: ;; CASE 5A.4: inline defun open
! 629: ((and containing-decl-open
! 630: (not (c-keyword-member containing-decl-kwd
! 631: 'c-other-block-decl-kwds)))
! 632: (c-add-syntax 'inline-open)
! 633: (c-add-class-syntax 'inclass
! 634: containing-decl-open
! 635: containing-decl-start
! 636: containing-decl-kwd
! 637: paren-state))
! 638:
! 639: ;; CASE 5A.5: ordinary defun open
! 640: (t
! 641: (save-excursion
! 642: (c-beginning-of-decl-1 lim)
! 643: (while (looking-at c-specifier-key)
! 644: (goto-char (match-end 1))
! 645: (c-forward-syntactic-ws indent-point))
! 646: (c-add-syntax 'defun-open (c-point 'boi))
! 647: ;; Bogus to use bol here, but it's the legacy. (Resolved,
! 648: ;; 2007-11-09)
! 649: ))))
! 650:
! 651: ;; CASE 5B: After a function header but before the body (or
! 652: ;; the ending semicolon if there's no body).
! 653: ((save-excursion
! 654: (when (setq placeholder (c-just-after-func-arglist-p lim))
! 655: (setq tmp-pos (point))))
! 656: (cond
! 657:
! 658: ;; CASE 5B.1: Member init list.
! 659: ((eq (char-after tmp-pos) ?:)
! 660: (if (or (> tmp-pos indent-point)
! 661: (= (c-point 'bosws) (1+ tmp-pos)))
! 662: (progn
! 663: ;; There is no preceding member init clause.
! 664: ;; Indent relative to the beginning of indentation
! 665: ;; for the topmost-intro line that contains the
! 666: ;; prototype's open paren.
! 667: (goto-char placeholder)
! 668: (c-add-syntax 'member-init-intro (c-point 'boi)))
! 669: ;; Indent relative to the first member init clause.
! 670: (goto-char (1+ tmp-pos))
! 671: (c-forward-syntactic-ws)
! 672: (c-add-syntax 'member-init-cont (point))))
! 673:
! 674: ;; CASE 5B.2: K&R arg decl intro
! 675: ((and c-recognize-knr-p
! 676: (c-in-knr-argdecl lim))
! 677: (c-beginning-of-statement-1 lim)
! 678: (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
! 679: (if containing-decl-open
! 680: (c-add-class-syntax 'inclass
! 681: containing-decl-open
! 682: containing-decl-start
! 683: containing-decl-kwd
! 684: paren-state)))
! 685:
! 686: ;; CASE 5B.4: Nether region after a C++ or Java func
! 687: ;; decl, which could include a `throws' declaration.
! 688: (t
! 689: (c-beginning-of-statement-1 lim)
! 690: (c-add-syntax 'func-decl-cont (c-point 'boi))
! 691: )))
! 692:
! 693: ;; CASE 5C: inheritance line. could be first inheritance
! 694: ;; line, or continuation of a multiple inheritance
! 695: ((or (and (c-major-mode-is 'c++-mode)
! 696: (progn
! 697: (when (eq char-after-ip ?,)
! 698: (skip-chars-forward " \t")
! 699: (forward-char))
! 700: (looking-at c-opt-postfix-decl-spec-key)))
! 701: (and (or (eq char-before-ip ?:)
! 702: ;; watch out for scope operator
! 703: (save-excursion
! 704: (and (eq char-after-ip ?:)
! 705: (c-safe (forward-char 1) t)
! 706: (not (eq (char-after) ?:))
! 707: )))
! 708: (save-excursion
! 709: (c-backward-syntactic-ws lim)
! 710: (if (eq char-before-ip ?:)
! 711: (progn
! 712: (forward-char -1)
! 713: (c-backward-syntactic-ws lim)))
! 714: (back-to-indentation)
! 715: (looking-at c-class-key)))
! 716: ;; for Java
! 717: (and (c-major-mode-is 'java-mode)
! 718: (let ((fence (save-excursion
! 719: (c-beginning-of-statement-1 lim)
! 720: (point)))
! 721: cont done)
! 722: (save-excursion
! 723: (while (not done)
! 724: (cond ((looking-at c-opt-postfix-decl-spec-key)
! 725: (setq injava-inher (cons cont (point))
! 726: done t))
! 727: ((or (not (c-safe (c-forward-sexp -1) t))
! 728: (<= (point) fence))
! 729: (setq done t))
! 730: )
! 731: (setq cont t)))
! 732: injava-inher)
! 733: (not (c-crosses-statement-barrier-p (cdr injava-inher)
! 734: (point)))
! 735: ))
! 736: (cond
! 737:
! 738: ;; CASE 5C.1: non-hanging colon on an inher intro
! 739: ((eq char-after-ip ?:)
! 740: (c-beginning-of-statement-1 lim)
! 741: (c-add-syntax 'inher-intro (c-point 'boi))
! 742: ;; don't add inclass symbol since relative point already
! 743: ;; contains any class offset
! 744: )
! 745:
! 746: ;; CASE 5C.2: hanging colon on an inher intro
! 747: ((eq char-before-ip ?:)
! 748: (c-beginning-of-statement-1 lim)
! 749: (c-add-syntax 'inher-intro (c-point 'boi))
! 750: (if containing-decl-open
! 751: (c-add-class-syntax 'inclass
! 752: containing-decl-open
! 753: containing-decl-start
! 754: containing-decl-kwd
! 755: paren-state)))
! 756:
! 757: ;; CASE 5C.3: in a Java implements/extends
! 758: (injava-inher
! 759: (let ((where (cdr injava-inher))
! 760: (cont (car injava-inher)))
! 761: (goto-char where)
! 762: (cond ((looking-at "throws\\>[^_]")
! 763: (c-add-syntax 'func-decl-cont
! 764: (progn (c-beginning-of-statement-1 lim)
! 765: (c-point 'boi))))
! 766: (cont (c-add-syntax 'inher-cont where))
! 767: (t (c-add-syntax 'inher-intro
! 768: (progn (goto-char (cdr injava-inher))
! 769: (c-beginning-of-statement-1 lim)
! 770: (point))))
! 771: )))
! 772:
! 773: ;; CASE 5C.4: a continued inheritance line
! 774: (t
! 775: (c-beginning-of-inheritance-list lim)
! 776: (c-add-syntax 'inher-cont (point))
! 777: ;; don't add inclass symbol since relative point already
! 778: ;; contains any class offset
! 779: )))
! 780:
! 781: ;; CASE 5D: this could be a top-level initialization, a
! 782: ;; member init list continuation, or a template argument
! 783: ;; list continuation.
! 784: ((save-excursion
! 785: ;; Note: We use the fact that lim is always after any
! 786: ;; preceding brace sexp.
! 787: (if c-recognize-<>-arglists
! 788: (while (and
! 789: (progn
! 790: (c-syntactic-skip-backward "^;$,=<>" lim t)
! 791: (> (point) lim))
! 792: (or
! 793: (when c-overloadable-operators-regexp
! 794: (when (setq placeholder (c-after-special-operator-id lim))
! 795: (goto-char placeholder)
! 796: t))
! 797: (cond
! 798: ((eq (char-before) ?>)
! 799: (or (c-backward-<>-arglist nil lim)
! 800: (backward-char))
! 801: t)
! 802: ((eq (char-before) ?<)
! 803: (backward-char)
! 804: (if (save-excursion
! 805: (c-forward-<>-arglist nil))
! 806: (progn (forward-char)
! 807: nil)
! 808: t))
! 809: (t nil)))))
! 810: ;; NB: No c-after-special-operator-id stuff in this
! 811: ;; clause - we assume only C++ needs it.
! 812: (c-syntactic-skip-backward "^;$,=" lim t))
! 813: (memq (char-before) '(?, ?= ?<)))
! 814: (cond
! 815:
! 816: ;; CASE 5D.3: perhaps a template list continuation?
! 817: ((and (c-major-mode-is 'c++-mode)
! 818: (save-excursion
! 819: (save-restriction
! 820: (c-with-syntax-table c++-template-syntax-table
! 821: (goto-char indent-point)
! 822: (setq placeholder (c-up-list-backward))
! 823: (and placeholder
! 824: (eq (char-after placeholder) ?<))))))
! 825: (c-with-syntax-table c++-template-syntax-table
! 826: (goto-char placeholder)
! 827: (c-beginning-of-statement-1 lim t)
! 828: (if (save-excursion
! 829: (c-backward-syntactic-ws lim)
! 830: (eq (char-before) ?<))
! 831: ;; In a nested template arglist.
! 832: (progn
! 833: (goto-char placeholder)
! 834: (c-syntactic-skip-backward "^,;" lim t)
! 835: (c-forward-syntactic-ws))
! 836: (back-to-indentation)))
! 837: ;; FIXME: Should use c-add-stmt-syntax, but it's not yet
! 838: ;; template aware.
! 839: (c-add-syntax 'template-args-cont (point) placeholder))
! 840:
! 841: ;; CASE 5D.4: perhaps a multiple inheritance line?
! 842: ((and (c-major-mode-is 'c++-mode)
! 843: (save-excursion
! 844: (c-beginning-of-statement-1 lim)
! 845: (setq placeholder (point))
! 846: (if (looking-at "static\\>[^_]")
! 847: (c-forward-token-2 1 nil indent-point))
! 848: (and (looking-at c-class-key)
! 849: (zerop (c-forward-token-2 2 nil indent-point))
! 850: (if (eq (char-after) ?<)
! 851: (c-with-syntax-table c++-template-syntax-table
! 852: (zerop (c-forward-token-2 1 t indent-point)))
! 853: t)
! 854: (eq (char-after) ?:))))
! 855: (goto-char placeholder)
! 856: (c-add-syntax 'inher-cont (c-point 'boi)))
! 857:
! 858: ;; CASE 5D.5: Continuation of the "expression part" of a
! 859: ;; top level construct. Or, perhaps, an unrecognized construct.
! 860: (t
! 861: (while (and (setq placeholder (point))
! 862: (eq (car (c-beginning-of-decl-1 containing-sexp))
! 863: 'same)
! 864: (save-excursion
! 865: (c-backward-syntactic-ws)
! 866: (eq (char-before) ?}))
! 867: (< (point) placeholder)))
! 868: (c-add-stmt-syntax
! 869: (cond
! 870: ((eq (point) placeholder) 'statement) ; unrecognized construct
! 871: ;; A preceding comma at the top level means that a
! 872: ;; new variable declaration starts here. Use
! 873: ;; topmost-intro-cont for it, for consistency with
! 874: ;; the first variable declaration. C.f. case 5N.
! 875: ((eq char-before-ip ?,) 'topmost-intro-cont)
! 876: (t 'statement-cont))
! 877: nil nil containing-sexp paren-state))
! 878: ))
! 879:
! 880: ;; CASE 5F: Close of a non-class declaration level block.
! 881: ((and (eq char-after-ip ?})
! 882: (c-keyword-member containing-decl-kwd
! 883: 'c-other-block-decl-kwds))
! 884: ;; This is inconsistent: Should use `containing-decl-open'
! 885: ;; here if it's at boi, like in case 5J.
! 886: (goto-char containing-decl-start)
! 887: (c-add-stmt-syntax
! 888: (if (string-equal (symbol-name containing-decl-kwd) "extern")
! 889: ;; Special case for compatibility with the
! 890: ;; extern-lang syntactic symbols.
! 891: 'extern-lang-close
! 892: (intern (concat (symbol-name containing-decl-kwd)
! 893: "-close")))
! 894: nil t
! 895: (c-most-enclosing-brace paren-state (point))
! 896: paren-state))
! 897:
! 898: ;; CASE 5G: we are looking at the brace which closes the
! 899: ;; enclosing nested class decl
! 900: ((and containing-sexp
! 901: (eq char-after-ip ?})
! 902: (eq containing-decl-open containing-sexp))
! 903: (c-add-class-syntax 'class-close
! 904: containing-decl-open
! 905: containing-decl-start
! 906: containing-decl-kwd
! 907: paren-state))
! 908:
! 909: ;; CASE 5H: we could be looking at subsequent knr-argdecls
! 910: ((and c-recognize-knr-p
! 911: (not containing-sexp) ; can't be knr inside braces.
! 912: (not (eq char-before-ip ?}))
! 913: (save-excursion
! 914: (setq placeholder (cdr (c-beginning-of-decl-1 lim)))
! 915: (and placeholder
! 916: ;; Do an extra check to avoid tripping up on
! 917: ;; statements that occur in invalid contexts
! 918: ;; (e.g. in macro bodies where we don't really
! 919: ;; know the context of what we're looking at).
! 920: (not (and c-opt-block-stmt-key
! 921: (looking-at c-opt-block-stmt-key)))))
! 922: (< placeholder indent-point))
! 923: (goto-char placeholder)
! 924: (c-add-syntax 'knr-argdecl (point)))
! 925:
! 926: ;; CASE 5I: ObjC method definition.
! 927: ((and c-opt-method-key
! 928: (looking-at c-opt-method-key))
! 929: (c-beginning-of-statement-1 nil t)
! 930: (if (= (point) indent-point)
! 931: ;; Handle the case when it's the first (non-comment)
! 932: ;; thing in the buffer. Can't look for a 'same return
! 933: ;; value from cbos1 since ObjC directives currently
! 934: ;; aren't recognized fully, so that we get 'same
! 935: ;; instead of 'previous if it moved over a preceding
! 936: ;; directive.
! 937: (goto-char (point-min)))
! 938: (c-add-syntax 'objc-method-intro (c-point 'boi)))
! 939:
! 940: ;; CASE 5P: AWK pattern or function or continuation
! 941: ;; thereof.
! 942: ((c-major-mode-is 'awk-mode)
! 943: (setq placeholder (point))
! 944: (c-add-stmt-syntax
! 945: (if (and (eq (c-beginning-of-statement-1) 'same)
! 946: (/= (point) placeholder))
! 947: 'topmost-intro-cont
! 948: 'topmost-intro)
! 949: nil nil
! 950: containing-sexp paren-state))
! 951:
! 952: ;; CASE 5N: At a variable declaration that follows a class
! 953: ;; definition or some other block declaration that doesn't
! 954: ;; end at the closing '}'. C.f. case 5D.5.
! 955: ((progn
! 956: (c-backward-syntactic-ws lim)
! 957: (and (eq (char-before) ?})
! 958: (save-excursion
! 959: (let ((start (point)))
! 960: (if (and c-state-cache
! 961: (consp (car c-state-cache))
! 962: (eq (cdar c-state-cache) (point)))
! 963: ;; Speed up the backward search a bit.
! 964: (goto-char (caar c-state-cache)))
! 965: (c-beginning-of-decl-1 containing-sexp)
! 966: (setq placeholder (point))
! 967: (if (= start (point))
! 968: ;; The '}' is unbalanced.
! 969: nil
! 970: (c-end-of-decl-1)
! 971: (>= (point) indent-point))))))
! 972: (goto-char placeholder)
! 973: (c-add-stmt-syntax 'topmost-intro-cont nil nil
! 974: containing-sexp paren-state))
! 975:
! 976: ;; NOTE: The point is at the end of the previous token here.
! 977:
! 978: ;; CASE 5J: we are at the topmost level, make
! 979: ;; sure we skip back past any access specifiers
! 980: ((and
! 981: ;; A macro continuation line is never at top level.
! 982: (not (and macro-start
! 983: (> indent-point macro-start)))
! 984: (save-excursion
! 985: (setq placeholder (point))
! 986: (or (memq char-before-ip '(?\; ?$ ?{ ?} nil))
! 987: (c-at-vsemi-p before-ws-ip)
! 988: (when (and (eq char-before-ip ?:)
! 989: (eq (c-beginning-of-statement-1 lim)
! 990: 'label))
! 991: (c-backward-syntactic-ws lim)
! 992: (setq placeholder (point)))
! 993: (and (c-major-mode-is 'objc-mode)
! 994: (catch 'not-in-directive
! 995: (c-beginning-of-statement-1 lim)
! 996: (setq placeholder (point))
! 997: (while (and (c-forward-objc-directive)
! 998: (< (point) indent-point))
! 999: (c-forward-syntactic-ws)
! 1000: (if (>= (point) indent-point)
! 1001: (throw 'not-in-directive t))
! 1002: (setq placeholder (point)))
! 1003: nil)))))
! 1004: ;; For historic reasons we anchor at bol of the last
! 1005: ;; line of the previous declaration. That's clearly
! 1006: ;; highly bogus and useless, and it makes our lives hard
! 1007: ;; to remain compatible. :P
! 1008: (goto-char placeholder)
! 1009: (c-add-syntax 'topmost-intro (c-point 'bol))
! 1010: (if containing-decl-open
! 1011: (if (c-keyword-member containing-decl-kwd
! 1012: 'c-other-block-decl-kwds)
! 1013: (progn
! 1014: (goto-char (c-brace-anchor-point containing-decl-open))
! 1015: (c-add-stmt-syntax
! 1016: (if (string-equal (symbol-name containing-decl-kwd)
! 1017: "extern")
! 1018: ;; Special case for compatibility with the
! 1019: ;; extern-lang syntactic symbols.
! 1020: 'inextern-lang
! 1021: (intern (concat "in"
! 1022: (symbol-name containing-decl-kwd))))
! 1023: nil t
! 1024: (c-most-enclosing-brace paren-state (point))
! 1025: paren-state))
! 1026: (c-add-class-syntax 'inclass
! 1027: containing-decl-open
! 1028: containing-decl-start
! 1029: containing-decl-kwd
! 1030: paren-state)))
! 1031: (when (and c-syntactic-indentation-in-macros
! 1032: macro-start
! 1033: (/= macro-start (c-point 'boi indent-point)))
! 1034: (c-add-syntax 'cpp-define-intro)
! 1035: (setq macro-start nil)))
! 1036:
! 1037: ;; CASE 5K: we are at an ObjC method definition
! 1038: ;; continuation line.
! 1039: ((and c-opt-method-key
! 1040: (save-excursion
! 1041: (c-beginning-of-statement-1 lim)
! 1042: (beginning-of-line)
! 1043: (when (looking-at c-opt-method-key)
! 1044: (setq placeholder (point)))))
! 1045: (c-add-syntax 'objc-method-args-cont placeholder))
! 1046:
! 1047: ;; CASE 5L: we are at the first argument of a template
! 1048: ;; arglist that begins on the previous line.
! 1049: ((and c-recognize-<>-arglists
! 1050: (eq (char-before) ?<)
! 1051: (setq placeholder (1- (point)))
! 1052: (not (and c-overloadable-operators-regexp
! 1053: (c-after-special-operator-id lim))))
! 1054: (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
! 1055: (c-add-syntax 'template-args-cont (c-point 'boi) placeholder))
! 1056:
! 1057: ;; CASE 5Q: we are at a statement within a macro.
! 1058: (macro-start
! 1059: (c-beginning-of-statement-1 containing-sexp)
! 1060: (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
! 1061:
! 1062: ;; CASE 5M: we are at a topmost continuation line
! 1063: (t
! 1064: (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
! 1065: (when (c-major-mode-is 'objc-mode)
! 1066: (setq placeholder (point))
! 1067: (while (and (c-forward-objc-directive)
! 1068: (< (point) indent-point))
! 1069: (c-forward-syntactic-ws)
! 1070: (setq placeholder (point)))
! 1071: (goto-char placeholder))
! 1072: (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
! 1073: ))
! 1074:
! 1075: ;; (CASE 6 has been removed.)
! 1076:
! 1077: ;; CASE 19: line is an expression, not a statement, and is directly
! 1078: ;; contained by a template delimiter. Most likely, we are in a
! 1079: ;; template arglist within a statement. This case is based on CASE
! 1080: ;; 7. At some point in the future, we may wish to create more
! 1081: ;; syntactic symbols such as `template-intro',
! 1082: ;; `template-cont-nonempty', etc., and distinguish between them as we
! 1083: ;; do for `arglist-intro' etc. (2009-12-07).
! 1084: ((and c-recognize-<>-arglists
! 1085: (setq containing-< (c-up-list-backward indent-point containing-sexp))
! 1086: (eq (char-after containing-<) ?\<))
! 1087: (setq placeholder (c-point 'boi containing-<))
! 1088: (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not
! 1089: ; '<') before indent-point.
! 1090: (if (>= (point) placeholder)
! 1091: (progn
! 1092: (forward-char)
! 1093: (skip-chars-forward " \t"))
! 1094: (goto-char placeholder))
! 1095: (c-add-stmt-syntax 'template-args-cont (list containing-<) t
! 1096: (c-most-enclosing-brace c-state-cache (point))
! 1097: paren-state))
! 1098:
! 1099:
! 1100: ;; CASE 7: line is an expression, not a statement. Most
! 1101: ;; likely we are either in a function prototype or a function
! 1102: ;; call argument list, or a template argument list.
! 1103: ((not (or (and c-special-brace-lists
! 1104: (save-excursion
! 1105: (goto-char containing-sexp)
! 1106: (c-looking-at-special-brace-list)))
! 1107: (eq (char-after containing-sexp) ?{)
! 1108: (eq (char-after containing-sexp) ?<)))
! 1109: (cond
! 1110:
! 1111: ;; CASE 7A: we are looking at the arglist closing paren.
! 1112: ;; C.f. case 7F.
! 1113: ((memq char-after-ip '(?\) ?\]))
! 1114: (goto-char containing-sexp)
! 1115: (setq placeholder (c-point 'boi))
! 1116: (if (and (c-safe (backward-up-list 1) t)
! 1117: (>= (point) placeholder))
! 1118: (progn
! 1119: (forward-char)
! 1120: (skip-chars-forward " \t"))
! 1121: (goto-char placeholder))
! 1122: (c-add-stmt-syntax 'arglist-close (list containing-sexp) t
! 1123: (c-most-enclosing-brace paren-state (point))
! 1124: paren-state))
! 1125:
! 1126: ;; CASE 7B: Looking at the opening brace of an
! 1127: ;; in-expression block or brace list. C.f. cases 4, 16A
! 1128: ;; and 17E.
! 1129: ((and (eq char-after-ip ?{)
! 1130: (progn
! 1131: (setq placeholder (c-inside-bracelist-p (point)
! 1132: paren-state))
! 1133: (if placeholder
! 1134: (setq tmpsymbol '(brace-list-open . inexpr-class))
! 1135: (setq tmpsymbol '(block-open . inexpr-statement)
! 1136: placeholder
! 1137: (cdr-safe (c-looking-at-inexpr-block
! 1138: (c-safe-position containing-sexp
! 1139: paren-state)
! 1140: containing-sexp)))
! 1141: ;; placeholder is nil if it's a block directly in
! 1142: ;; a function arglist. That makes us skip out of
! 1143: ;; this case.
! 1144: )))
! 1145: (goto-char placeholder)
! 1146: (back-to-indentation)
! 1147: (c-add-stmt-syntax (car tmpsymbol) nil t
! 1148: (c-most-enclosing-brace paren-state (point))
! 1149: paren-state)
! 1150: (if (/= (point) placeholder)
! 1151: (c-add-syntax (cdr tmpsymbol))))
! 1152:
! 1153: ;; CASE 7C: we are looking at the first argument in an empty
! 1154: ;; argument list. Use arglist-close if we're actually
! 1155: ;; looking at a close paren or bracket.
! 1156: ((memq char-before-ip '(?\( ?\[))
! 1157: (goto-char containing-sexp)
! 1158: (setq placeholder (c-point 'boi))
! 1159: (if (and (c-safe (backward-up-list 1) t)
! 1160: (>= (point) placeholder))
! 1161: (progn
! 1162: (forward-char)
! 1163: (skip-chars-forward " \t"))
! 1164: (goto-char placeholder))
! 1165: (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t
! 1166: (c-most-enclosing-brace paren-state (point))
! 1167: paren-state))
! 1168:
! 1169: ;; CASE 7D: we are inside a conditional test clause. treat
! 1170: ;; these things as statements
! 1171: ((progn
! 1172: (goto-char containing-sexp)
! 1173: (and (c-safe (c-forward-sexp -1) t)
! 1174: (looking-at "\\<for\\>[^_]")))
! 1175: (goto-char (1+ containing-sexp))
! 1176: (c-forward-syntactic-ws indent-point)
! 1177: (if (eq char-before-ip ?\;)
! 1178: (c-add-syntax 'statement (point))
! 1179: (c-add-syntax 'statement-cont (point))
! 1180: ))
! 1181:
! 1182: ;; CASE 7E: maybe a continued ObjC method call. This is the
! 1183: ;; case when we are inside a [] bracketed exp, and what
! 1184: ;; precede the opening bracket is not an identifier.
! 1185: ((and c-opt-method-key
! 1186: (eq (char-after containing-sexp) ?\[)
! 1187: (progn
! 1188: (goto-char (1- containing-sexp))
! 1189: (c-backward-syntactic-ws (c-point 'bod))
! 1190: (if (not (looking-at c-symbol-key))
! 1191: (c-add-syntax 'objc-method-call-cont containing-sexp))
! 1192: )))
! 1193:
! 1194: ;; CASE 7F: we are looking at an arglist continuation line,
! 1195: ;; but the preceding argument is on the same line as the
! 1196: ;; opening paren. This case includes multi-line
! 1197: ;; mathematical paren groupings, but we could be on a
! 1198: ;; for-list continuation line. C.f. case 7A.
! 1199: ((progn
! 1200: (goto-char (1+ containing-sexp))
! 1201: (< (save-excursion
! 1202: (c-forward-syntactic-ws)
! 1203: (point))
! 1204: (c-point 'bonl)))
! 1205: (goto-char containing-sexp) ; paren opening the arglist
! 1206: (setq placeholder (c-point 'boi))
! 1207: (if (and (c-safe (backward-up-list 1) t)
! 1208: (>= (point) placeholder))
! 1209: (progn
! 1210: (forward-char)
! 1211: (skip-chars-forward " \t"))
! 1212: (goto-char placeholder))
! 1213: (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t
! 1214: (c-most-enclosing-brace c-state-cache (point))
! 1215: paren-state))
! 1216:
! 1217: ;; CASE 7G: we are looking at just a normal arglist
! 1218: ;; continuation line
! 1219: (t (c-forward-syntactic-ws indent-point)
! 1220: (c-add-syntax 'arglist-cont (c-point 'boi)))
! 1221: ))
! 1222:
! 1223: ;; CASE 8: func-local multi-inheritance line
! 1224: ((and (c-major-mode-is 'c++-mode)
! 1225: (save-excursion
! 1226: (goto-char indent-point)
! 1227: (skip-chars-forward " \t")
! 1228: (looking-at c-opt-postfix-decl-spec-key)))
! 1229: (goto-char indent-point)
! 1230: (skip-chars-forward " \t")
! 1231: (cond
! 1232:
! 1233: ;; CASE 8A: non-hanging colon on an inher intro
! 1234: ((eq char-after-ip ?:)
! 1235: (c-backward-syntactic-ws lim)
! 1236: (c-add-syntax 'inher-intro (c-point 'boi)))
! 1237:
! 1238: ;; CASE 8B: hanging colon on an inher intro
! 1239: ((eq char-before-ip ?:)
! 1240: (c-add-syntax 'inher-intro (c-point 'boi)))
! 1241:
! 1242: ;; CASE 8C: a continued inheritance line
! 1243: (t
! 1244: (c-beginning-of-inheritance-list lim)
! 1245: (c-add-syntax 'inher-cont (point))
! 1246: )))
! 1247:
! 1248: ;; CASE 9: we are inside a brace-list
! 1249: ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29)
! 1250: (setq special-brace-list
! 1251: (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!!
! 1252: (save-excursion
! 1253: (goto-char containing-sexp)
! 1254: (c-looking-at-special-brace-list)))
! 1255: (c-inside-bracelist-p containing-sexp paren-state))))
! 1256: (cond
! 1257:
! 1258: ;; CASE 9A: In the middle of a special brace list opener.
! 1259: ((and (consp special-brace-list)
! 1260: (save-excursion
! 1261: (goto-char containing-sexp)
! 1262: (eq (char-after) ?\())
! 1263: (eq char-after-ip (car (cdr special-brace-list))))
! 1264: (goto-char (car (car special-brace-list)))
! 1265: (skip-chars-backward " \t")
! 1266: (if (and (bolp)
! 1267: (assoc 'statement-cont
! 1268: (setq placeholder (c-guess-basic-syntax))))
! 1269: (setq c-syntactic-context placeholder)
! 1270: (c-beginning-of-statement-1
! 1271: (c-safe-position (1- containing-sexp) paren-state))
! 1272: (c-forward-token-2 0)
! 1273: (while (looking-at c-specifier-key)
! 1274: (goto-char (match-end 1))
! 1275: (c-forward-syntactic-ws))
! 1276: (c-add-syntax 'brace-list-open (c-point 'boi))))
! 1277:
! 1278: ;; CASE 9B: brace-list-close brace
! 1279: ((if (consp special-brace-list)
! 1280: ;; Check special brace list closer.
! 1281: (progn
! 1282: (goto-char (car (car special-brace-list)))
! 1283: (save-excursion
! 1284: (goto-char indent-point)
! 1285: (back-to-indentation)
! 1286: (or
! 1287: ;; We were between the special close char and the `)'.
! 1288: (and (eq (char-after) ?\))
! 1289: (eq (1+ (point)) (cdr (car special-brace-list))))
! 1290: ;; We were before the special close char.
! 1291: (and (eq (char-after) (cdr (cdr special-brace-list)))
! 1292: (zerop (c-forward-token-2))
! 1293: (eq (1+ (point)) (cdr (car special-brace-list)))))))
! 1294: ;; Normal brace list check.
! 1295: (and (eq char-after-ip ?})
! 1296: (c-safe (goto-char (c-up-list-backward (point))) t)
! 1297: (= (point) containing-sexp)))
! 1298: (if (eq (point) (c-point 'boi))
! 1299: (c-add-syntax 'brace-list-close (point))
! 1300: (setq lim (c-most-enclosing-brace c-state-cache (point)))
! 1301: (c-beginning-of-statement-1 lim)
! 1302: (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
! 1303:
! 1304: (t
! 1305: ;; Prepare for the rest of the cases below by going to the
! 1306: ;; token following the opening brace
! 1307: (if (consp special-brace-list)
! 1308: (progn
! 1309: (goto-char (car (car special-brace-list)))
! 1310: (c-forward-token-2 1 nil indent-point))
! 1311: (goto-char containing-sexp))
! 1312: (forward-char)
! 1313: (let ((start (point)))
! 1314: (c-forward-syntactic-ws indent-point)
! 1315: (goto-char (max start (c-point 'bol))))
! 1316: (c-skip-ws-forward indent-point)
! 1317: (cond
! 1318:
! 1319: ;; CASE 9C: we're looking at the first line in a brace-list
! 1320: ((= (point) indent-point)
! 1321: (if (consp special-brace-list)
! 1322: (goto-char (car (car special-brace-list)))
! 1323: (goto-char containing-sexp))
! 1324: (if (eq (point) (c-point 'boi))
! 1325: (c-add-syntax 'brace-list-intro (point))
! 1326: (setq lim (c-most-enclosing-brace c-state-cache (point)))
! 1327: (c-beginning-of-statement-1 lim)
! 1328: (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state)))
! 1329:
! 1330: ;; CASE 9D: this is just a later brace-list-entry or
! 1331: ;; brace-entry-open
! 1332: (t (if (or (eq char-after-ip ?{)
! 1333: (and c-special-brace-lists
! 1334: (save-excursion
! 1335: (goto-char indent-point)
! 1336: (c-forward-syntactic-ws (c-point 'eol))
! 1337: (c-looking-at-special-brace-list (point)))))
! 1338: (c-add-syntax 'brace-entry-open (point))
! 1339: (c-add-syntax 'brace-list-entry (point))
! 1340: ))
! 1341: ))))
! 1342:
! 1343: ;; CASE 10: A continued statement or top level construct.
! 1344: ((and (not (memq char-before-ip '(?\; ?:)))
! 1345: (not (c-at-vsemi-p before-ws-ip))
! 1346: (or (not (eq char-before-ip ?}))
! 1347: (c-looking-at-inexpr-block-backward c-state-cache))
! 1348: (> (point)
! 1349: (save-excursion
! 1350: (c-beginning-of-statement-1 containing-sexp)
! 1351: (setq placeholder (point))))
! 1352: (/= placeholder containing-sexp))
! 1353: ;; This is shared with case 18.
! 1354: (c-guess-continued-construct indent-point
! 1355: char-after-ip
! 1356: placeholder
! 1357: containing-sexp
! 1358: paren-state))
! 1359:
! 1360: ;; CASE 16: block close brace, possibly closing the defun or
! 1361: ;; the class
! 1362: ((eq char-after-ip ?})
! 1363: ;; From here on we have the next containing sexp in lim.
! 1364: (setq lim (c-most-enclosing-brace paren-state))
! 1365: (goto-char containing-sexp)
! 1366: (cond
! 1367:
! 1368: ;; CASE 16E: Closing a statement block? This catches
! 1369: ;; cases where it's preceded by a statement keyword,
! 1370: ;; which works even when used in an "invalid" context,
! 1371: ;; e.g. a macro argument.
! 1372: ((c-after-conditional)
! 1373: (c-backward-to-block-anchor lim)
! 1374: (c-add-stmt-syntax 'block-close nil t lim paren-state))
! 1375:
! 1376: ;; CASE 16A: closing a lambda defun or an in-expression
! 1377: ;; block? C.f. cases 4, 7B and 17E.
! 1378: ((setq placeholder (c-looking-at-inexpr-block
! 1379: (c-safe-position containing-sexp paren-state)
! 1380: nil))
! 1381: (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
! 1382: 'inline-close
! 1383: 'block-close))
! 1384: (goto-char containing-sexp)
! 1385: (back-to-indentation)
! 1386: (if (= containing-sexp (point))
! 1387: (c-add-syntax tmpsymbol (point))
! 1388: (goto-char (cdr placeholder))
! 1389: (back-to-indentation)
! 1390: (c-add-stmt-syntax tmpsymbol nil t
! 1391: (c-most-enclosing-brace paren-state (point))
! 1392: paren-state)
! 1393: (if (/= (point) (cdr placeholder))
! 1394: (c-add-syntax (car placeholder)))))
! 1395:
! 1396: ;; CASE 16B: does this close an inline or a function in
! 1397: ;; a non-class declaration level block?
! 1398: ((save-excursion
! 1399: (and lim
! 1400: (progn
! 1401: (goto-char lim)
! 1402: (c-looking-at-decl-block
! 1403: (c-most-enclosing-brace paren-state lim)
! 1404: nil))
! 1405: (setq placeholder (point))))
! 1406: (c-backward-to-decl-anchor lim)
! 1407: (back-to-indentation)
! 1408: (if (save-excursion
! 1409: (goto-char placeholder)
! 1410: (looking-at c-other-decl-block-key))
! 1411: (c-add-syntax 'defun-close (point))
! 1412: (c-add-syntax 'inline-close (point))))
! 1413:
! 1414: ;; CASE 16F: Can be a defun-close of a function declared
! 1415: ;; in a statement block, e.g. in Pike or when using gcc
! 1416: ;; extensions, but watch out for macros followed by
! 1417: ;; blocks. Let it through to be handled below.
! 1418: ;; C.f. cases B.3 and 17G.
! 1419: ((save-excursion
! 1420: (and (not (c-at-statement-start-p))
! 1421: (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
! 1422: (setq placeholder (point))
! 1423: (let ((c-recognize-typeless-decls nil))
! 1424: ;; Turn off recognition of constructs that
! 1425: ;; lacks a type in this case, since that's more
! 1426: ;; likely to be a macro followed by a block.
! 1427: (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
! 1428: (back-to-indentation)
! 1429: (if (/= (point) containing-sexp)
! 1430: (goto-char placeholder))
! 1431: (c-add-stmt-syntax 'defun-close nil t lim paren-state))
! 1432:
! 1433: ;; CASE 16C: If there is an enclosing brace then this is
! 1434: ;; a block close since defun closes inside declaration
! 1435: ;; level blocks have been handled above.
! 1436: (lim
! 1437: ;; If the block is preceded by a case/switch label on
! 1438: ;; the same line, we anchor at the first preceding label
! 1439: ;; at boi. The default handling in c-add-stmt-syntax
! 1440: ;; really fixes it better, but we do like this to keep
! 1441: ;; the indentation compatible with version 5.28 and
! 1442: ;; earlier. C.f. case 17H.
! 1443: (while (and (/= (setq placeholder (point)) (c-point 'boi))
! 1444: (eq (c-beginning-of-statement-1 lim) 'label)))
! 1445: (goto-char placeholder)
! 1446: (if (looking-at c-label-kwds-regexp)
! 1447: (c-add-syntax 'block-close (point))
! 1448: (goto-char containing-sexp)
! 1449: ;; c-backward-to-block-anchor not necessary here; those
! 1450: ;; situations are handled in case 16E above.
! 1451: (c-add-stmt-syntax 'block-close nil t lim paren-state)))
! 1452:
! 1453: ;; CASE 16D: Only top level defun close left.
! 1454: (t
! 1455: (goto-char containing-sexp)
! 1456: (c-backward-to-decl-anchor lim)
! 1457: (c-add-stmt-syntax 'defun-close nil nil
! 1458: (c-most-enclosing-brace paren-state)
! 1459: paren-state))
! 1460: ))
! 1461:
! 1462: ;; CASE 17: Statement or defun catchall.
! 1463: (t
! 1464: (goto-char indent-point)
! 1465: ;; Back up statements until we find one that starts at boi.
! 1466: (while (let* ((prev-point (point))
! 1467: (last-step-type (c-beginning-of-statement-1
! 1468: containing-sexp)))
! 1469: (if (= (point) prev-point)
! 1470: (progn
! 1471: (setq step-type (or step-type last-step-type))
! 1472: nil)
! 1473: (setq step-type last-step-type)
! 1474: (/= (point) (c-point 'boi)))))
! 1475: (cond
! 1476:
! 1477: ;; CASE 17B: continued statement
! 1478: ((and (eq step-type 'same)
! 1479: (/= (point) indent-point))
! 1480: (c-add-stmt-syntax 'statement-cont nil nil
! 1481: containing-sexp paren-state))
! 1482:
! 1483: ;; CASE 17A: After a case/default label?
! 1484: ((progn
! 1485: (while (and (eq step-type 'label)
! 1486: (not (looking-at c-label-kwds-regexp)))
! 1487: (setq step-type
! 1488: (c-beginning-of-statement-1 containing-sexp)))
! 1489: (eq step-type 'label))
! 1490: (c-add-stmt-syntax (if (eq char-after-ip ?{)
! 1491: 'statement-case-open
! 1492: 'statement-case-intro)
! 1493: nil t containing-sexp paren-state))
! 1494:
! 1495: ;; CASE 17D: any old statement
! 1496: ((progn
! 1497: (while (eq step-type 'label)
! 1498: (setq step-type
! 1499: (c-beginning-of-statement-1 containing-sexp)))
! 1500: (eq step-type 'previous))
! 1501: (c-add-stmt-syntax 'statement nil t
! 1502: containing-sexp paren-state)
! 1503: (if (eq char-after-ip ?{)
! 1504: (c-add-syntax 'block-open)))
! 1505:
! 1506: ;; CASE 17I: Inside a substatement block.
! 1507: ((progn
! 1508: ;; The following tests are all based on containing-sexp.
! 1509: (goto-char containing-sexp)
! 1510: ;; From here on we have the next containing sexp in lim.
! 1511: (setq lim (c-most-enclosing-brace paren-state containing-sexp))
! 1512: (c-after-conditional))
! 1513: (c-backward-to-block-anchor lim)
! 1514: (c-add-stmt-syntax 'statement-block-intro nil t
! 1515: lim paren-state)
! 1516: (if (eq char-after-ip ?{)
! 1517: (c-add-syntax 'block-open)))
! 1518:
! 1519: ;; CASE 17E: first statement in an in-expression block.
! 1520: ;; C.f. cases 4, 7B and 16A.
! 1521: ((setq placeholder (c-looking-at-inexpr-block
! 1522: (c-safe-position containing-sexp paren-state)
! 1523: nil))
! 1524: (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
! 1525: 'defun-block-intro
! 1526: 'statement-block-intro))
! 1527: (back-to-indentation)
! 1528: (if (= containing-sexp (point))
! 1529: (c-add-syntax tmpsymbol (point))
! 1530: (goto-char (cdr placeholder))
! 1531: (back-to-indentation)
! 1532: (c-add-stmt-syntax tmpsymbol nil t
! 1533: (c-most-enclosing-brace c-state-cache (point))
! 1534: paren-state)
! 1535: (if (/= (point) (cdr placeholder))
! 1536: (c-add-syntax (car placeholder))))
! 1537: (if (eq char-after-ip ?{)
! 1538: (c-add-syntax 'block-open)))
! 1539:
! 1540: ;; CASE 17F: first statement in an inline, or first
! 1541: ;; statement in a top-level defun. we can tell this is it
! 1542: ;; if there are no enclosing braces that haven't been
! 1543: ;; narrowed out by a class (i.e. don't use bod here).
! 1544: ((save-excursion
! 1545: (or (not (setq placeholder (c-most-enclosing-brace
! 1546: paren-state)))
! 1547: (and (progn
! 1548: (goto-char placeholder)
! 1549: (eq (char-after) ?{))
! 1550: (c-looking-at-decl-block (c-most-enclosing-brace
! 1551: paren-state (point))
! 1552: nil))))
! 1553: (c-backward-to-decl-anchor lim)
! 1554: (back-to-indentation)
! 1555: (c-add-syntax 'defun-block-intro (point)))
! 1556:
! 1557: ;; CASE 17G: First statement in a function declared inside
! 1558: ;; a normal block. This can occur in Pike and with
! 1559: ;; e.g. the gcc extensions, but watch out for macros
! 1560: ;; followed by blocks. C.f. cases B.3 and 16F.
! 1561: ((save-excursion
! 1562: (and (not (c-at-statement-start-p))
! 1563: (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
! 1564: (setq placeholder (point))
! 1565: (let ((c-recognize-typeless-decls nil))
! 1566: ;; Turn off recognition of constructs that lacks
! 1567: ;; a type in this case, since that's more likely
! 1568: ;; to be a macro followed by a block.
! 1569: (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
! 1570: (back-to-indentation)
! 1571: (if (/= (point) containing-sexp)
! 1572: (goto-char placeholder))
! 1573: (c-add-stmt-syntax 'defun-block-intro nil t
! 1574: lim paren-state))
! 1575:
! 1576: ;; CASE 17H: First statement in a block.
! 1577: (t
! 1578: ;; If the block is preceded by a case/switch label on the
! 1579: ;; same line, we anchor at the first preceding label at
! 1580: ;; boi. The default handling in c-add-stmt-syntax is
! 1581: ;; really fixes it better, but we do like this to keep the
! 1582: ;; indentation compatible with version 5.28 and earlier.
! 1583: ;; C.f. case 16C.
! 1584: (while (and (/= (setq placeholder (point)) (c-point 'boi))
! 1585: (eq (c-beginning-of-statement-1 lim) 'label)))
! 1586: (goto-char placeholder)
! 1587: (if (looking-at c-label-kwds-regexp)
! 1588: (c-add-syntax 'statement-block-intro (point))
! 1589: (goto-char containing-sexp)
! 1590: ;; c-backward-to-block-anchor not necessary here; those
! 1591: ;; situations are handled in case 17I above.
! 1592: (c-add-stmt-syntax 'statement-block-intro nil t
! 1593: lim paren-state))
! 1594: (if (eq char-after-ip ?{)
! 1595: (c-add-syntax 'block-open)))
! 1596: ))
! 1597: )
! 1598:
! 1599: ;; now we need to look at any modifiers
! 1600: (goto-char indent-point)
! 1601: (skip-chars-forward " \t")
! 1602:
! 1603: ;; are we looking at a comment only line?
! 1604: (when (and (looking-at c-comment-start-regexp)
! 1605: (/= (c-forward-token-2 0 nil (c-point 'eol)) 0))
! 1606: (c-append-syntax 'comment-intro))
! 1607:
! 1608: ;; we might want to give additional offset to friends (in C++).
! 1609: (when (and c-opt-friend-key
! 1610: (looking-at c-opt-friend-key))
! 1611: (c-append-syntax 'friend))
! 1612:
! 1613: ;; Set syntactic-relpos.
! 1614: (let ((p c-syntactic-context))
! 1615: (while (and p
! 1616: (if (integerp (c-langelem-pos (car p)))
! 1617: (progn
! 1618: (setq syntactic-relpos (c-langelem-pos (car p)))
! 1619: nil)
! 1620: t))
! 1621: (setq p (cdr p))))
! 1622:
! 1623: ;; Start of or a continuation of a preprocessor directive?
! 1624: (if (and macro-start
! 1625: (eq macro-start (c-point 'boi))
! 1626: (not (and (c-major-mode-is 'pike-mode)
! 1627: (eq (char-after (1+ macro-start)) ?\"))))
! 1628: (c-append-syntax 'cpp-macro)
! 1629: (when (and c-syntactic-indentation-in-macros macro-start)
! 1630: (if in-macro-expr
! 1631: (when (or
! 1632: (< syntactic-relpos macro-start)
! 1633: (not (or
! 1634: (assq 'arglist-intro c-syntactic-context)
! 1635: (assq 'arglist-cont c-syntactic-context)
! 1636: (assq 'arglist-cont-nonempty c-syntactic-context)
! 1637: (assq 'arglist-close c-syntactic-context))))
! 1638: ;; If inside a cpp expression, i.e. anywhere in a
! 1639: ;; cpp directive except a #define body, we only let
! 1640: ;; through the syntactic analysis that is internal
! 1641: ;; in the expression. That means the arglist
! 1642: ;; elements, if they are anchored inside the cpp
! 1643: ;; expression.
! 1644: (setq c-syntactic-context nil)
! 1645: (c-add-syntax 'cpp-macro-cont macro-start))
! 1646: (when (and (eq macro-start syntactic-relpos)
! 1647: (not (assq 'cpp-define-intro c-syntactic-context))
! 1648: (save-excursion
! 1649: (goto-char macro-start)
! 1650: (or (not (c-forward-to-cpp-define-body))
! 1651: (<= (point) (c-point 'boi indent-point)))))
! 1652: ;; Inside a #define body and the syntactic analysis is
! 1653: ;; anchored on the start of the #define. In this case
! 1654: ;; we add cpp-define-intro to get the extra
! 1655: ;; indentation of the #define body.
! 1656: (c-add-syntax 'cpp-define-intro)))))
! 1657:
! 1658: ;; return the syntax
! 1659: c-syntactic-context)))
! 1660:
! 1661: ;;;; End of `asir-c-guess-basic-syntax'
! 1662:
! 1663: (provide 'asir-mode)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>