[BACK]Return to k0-mode.el CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097 / lib

Annotation of OpenXM/src/k097/lib/k0-mode.el, Revision 1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>