+(defconst c++-font-lock-keywords-3 nil
+ "Gaudy level highlighting for C++ mode.
+See also `c++-font-lock-extra-types'.")
+
+(defun font-lock-match-c++-style-declaration-item-and-skip-to-next (limit)
+ ;; Regexp matches after point: word<word>::word (
+ ;; ^^^^ ^^^^ ^^^^ ^
+ ;; Where the match subexpressions are: 1 3 5 6
+ ;;
+ ;; Item is delimited by (match-beginning 1) and (match-end 1).
+ ;; If (match-beginning 3) is non-nil, that part of the item incloses a `<>'.
+ ;; If (match-beginning 5) is non-nil, that part of the item follows a `::'.
+ ;; If (match-beginning 6) is non-nil, the item is followed by a `('.
+ (when (looking-at (eval-when-compile
+ (concat
+ ;; Skip any leading whitespace.
+ "[ \t*&]*"
+ ;; This is `c++-type-spec' from below. (Hint hint!)
+ "\\(\\sw+\\)" ; The instance?
+ "\\([ \t]*<\\([^>\n]+\\)[ \t*&]*>\\)?" ; Or template?
+ "\\([ \t]*::[ \t*~]*\\(\\sw+\\)\\)*" ; Or member?
+ ;; Match any trailing parenthesis.
+ "[ \t]*\\((\\)?")))
+ (save-match-data
+ (condition-case nil
+ (save-restriction
+ ;; Restrict to the end of line, currently guaranteed to be LIMIT.
+ (narrow-to-region (point-min) limit)
+ (goto-char (match-end 1))
+ ;; Move over any item value, etc., to the next item.
+ (while (not (looking-at "[ \t]*\\(\\(,\\)\\|;\\|$\\)"))
+ (goto-char (or (scan-sexps (point) 1) (point-max))))
+ (goto-char (match-end 2)))
+ (error t)))))
+
+(let* ((c++-keywords
+ (eval-when-compile
+ (regexp-opt
+ '("break" "continue" "do" "else" "for" "if" "return" "switch"
+ "while" "asm" "catch" "delete" "new" "sizeof" "this" "throw" "try"
+ ;; Eric Hopper <hopper@omnifarious.mn.org> says these are new.
+ "static_cast" "dynamic_cast" "const_cast" "reinterpret_cast") t)))
+ (c++-operators
+ (eval-when-compile
+ (regexp-opt
+ ;; Taken from Stroustrup, minus keywords otherwise fontified.
+ '("+" "-" "*" "/" "%" "^" "&" "|" "~" "!" "=" "<" ">" "+=" "-="
+ "*=" "/=" "%=" "^=" "&=" "|=" "<<" ">>" ">>=" "<<=" "==" "!="
+ "<=" ">=" "&&" "||" "++" "--" "->*" "," "->" "[]" "()"))))
+ (c++-type-types
+ `(mapconcat 'identity
+ (cons
+ (,@ (eval-when-compile
+ (regexp-opt
+ '("extern" "auto" "register" "static" "typedef" "struct"
+ "union" "enum" "signed" "unsigned" "short" "long"
+ "int" "char" "float" "double" "void" "volatile" "const"
+ "inline" "friend" "bool" "virtual" "complex" "template"
+ "namespace" "using"
+ ;; Mark Mitchell <mmitchell@usa.net> says these are new.
+ "explicit" "mutable"
+ ;; Branko Cibej <branko.cibej@hermes.si> suggests this.
+ "export"))))
+ c++-font-lock-extra-types)
+ "\\|"))
+ ;;
+ ;; A brave attempt to match templates following a type and/or match
+ ;; class membership. See and sync the above function
+ ;; `font-lock-match-c++-style-declaration-item-and-skip-to-next'.
+ (c++-type-suffix (concat "\\([ \t]*<\\([^>\n]+\\)[ \t*&]*>\\)?"
+ "\\([ \t]*::[ \t*~]*\\(\\sw+\\)\\)*"))
+ ;; If the string is a type, it may be followed by the cruft above.
+ (c++-type-spec (concat "\\(\\sw+\\)\\>" c++-type-suffix))
+ ;;
+ ;; Parenthesis depth of user-defined types not forgetting their cruft.
+ (c++-type-depth `(regexp-opt-depth
+ (concat (,@ c++-type-types) (,@ c++-type-suffix))))
+ )
+ (setq c++-font-lock-keywords-1
+ (append
+ ;;
+ ;; The list `c-font-lock-keywords-1' less that for function names.
+ (cdr c-font-lock-keywords-1)
+ (list
+ ;;
+ ;; Class names etc.
+ (list (concat "\\<\\(class\\|public\\|private\\|protected\\|typename\\)\\>"
+ "[ \t]*"
+ "\\(" c++-type-spec "\\)?")
+ '(1 font-lock-type-face)
+ '(3 (if (match-beginning 6)
+ font-lock-type-face
+ font-lock-function-name-face) nil t)
+ '(5 font-lock-function-name-face nil t)
+ '(7 font-lock-function-name-face nil t))
+ ;;
+ ;; Fontify function name definitions, possibly incorporating class names.
+ (list (concat "^" c++-type-spec "[ \t]*(")
+ '(1 (if (or (match-beginning 2) (match-beginning 4))
+ font-lock-type-face
+ font-lock-function-name-face))
+ '(3 font-lock-function-name-face nil t)
+ '(5 font-lock-function-name-face nil t))
+ )))
+
+ (setq c++-font-lock-keywords-2
+ (append c++-font-lock-keywords-1
+ (list
+ ;;
+ ;; The list `c-font-lock-keywords-2' for C++ plus operator overloading.
+ `(eval .
+ (cons (concat "\\<\\(" (,@ c++-type-types) "\\)\\>")
+ 'font-lock-type-face))
+ ;;
+ ;; Fontify operator overloading.
+ (list (concat "\\<\\(operator\\)\\>[ \t]*\\(" c++-operators "\\)?")
+ '(1 font-lock-keyword-face)
+ '(2 font-lock-builtin-face nil t))
+ ;;
+ ;; Fontify case/goto keywords and targets, and case default/goto tags.
+ '("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
+ ;; This must come after the one for keywords and targets.
+ '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:\\($\\|[^:]\\)"
+ (beginning-of-line) (end-of-line)
+ (1 font-lock-constant-face)))
+ ;;
+ ;; Fontify other builtin keywords.
+ (concat "\\<" c++-keywords "\\>")
+ ;;
+ ;; Eric Hopper <hopper@omnifarious.mn.org> says `true' and `false' are new.
+ '("\\<\\(false\\|true\\)\\>" . font-lock-constant-face)
+ )))
+
+ (setq c++-font-lock-keywords-3
+ (append c++-font-lock-keywords-2
+ ;;
+ ;; More complicated regexps for more complete highlighting for types.
+ (list
+ ;;
+ ;; Fontify all storage classes and type specifiers, plus their items.
+ `(eval .
+ (list (concat "\\<\\(" (,@ c++-type-types) "\\)\\>" (,@ c++-type-suffix)
+ "\\([ \t*&]+" (,@ c++-type-spec) "\\)*")
+ ;; Fontify each declaration item.
+ (list 'font-lock-match-c++-style-declaration-item-and-skip-to-next
+ ;; Start with point after all type specifiers.
+ (list 'goto-char (list 'or (list 'match-beginning
+ (+ (,@ c++-type-depth) 2))
+ '(match-end 1)))
+ ;; Finish with point after first type specifier.
+ '(goto-char (match-end 1))
+ ;; Fontify as a variable or function name.
+ '(1 (cond ((or (match-beginning 2) (match-beginning 4))
+ font-lock-type-face)
+ ((match-beginning 6) font-lock-function-name-face)
+ (t font-lock-variable-name-face)))
+ '(3 font-lock-function-name-face nil t)
+ '(5 (if (match-beginning 6)
+ font-lock-function-name-face
+ font-lock-variable-name-face) nil t))))
+ ;;
+ ;; Fontify structures, or typedef names, plus their items.
+ '("\\(}\\)[ \t*]*\\sw"
+ (font-lock-match-c++-style-declaration-item-and-skip-to-next
+ (goto-char (match-end 1)) nil
+ (1 (if (match-beginning 6)
+ font-lock-function-name-face
+ font-lock-variable-name-face))))
+ ;;
+ ;; Fontify anything at beginning of line as a declaration or definition.
+ (list (concat "^\\(" c++-type-spec "[ \t*&]*\\)+")
+ '(font-lock-match-c++-style-declaration-item-and-skip-to-next
+ (goto-char (match-beginning 1))
+ (goto-char (match-end 1))
+ (1 (cond ((or (match-beginning 2) (match-beginning 4))
+ font-lock-type-face)
+ ((match-beginning 6) font-lock-function-name-face)
+ (t font-lock-variable-name-face)))
+ (3 font-lock-function-name-face nil t)
+ (5 (if (match-beginning 6)
+ font-lock-function-name-face
+ font-lock-variable-name-face) nil t)))
+ )))
+ )
+
+(defvar c++-font-lock-keywords c++-font-lock-keywords-1
+ "Default expressions to highlight in C++ mode.
+See also `c++-font-lock-extra-types'.")
+\f
+;;; Objective-C.
+
+(defconst objc-font-lock-keywords-1 nil
+ "Subdued level highlighting for Objective-C mode.")
+
+(defconst objc-font-lock-keywords-2 nil
+ "Medium level highlighting for Objective-C mode.
+See also `objc-font-lock-extra-types'.")
+
+(defconst objc-font-lock-keywords-3 nil
+ "Gaudy level highlighting for Objective-C mode.
+See also `objc-font-lock-extra-types'.")
+
+;; Regexps written with help from Stephen Peters <speters@us.oracle.com> and
+;; Jacques Duthen Prestataire <duthen@cegelec-red.fr>.
+(let* ((objc-keywords
+ (eval-when-compile
+ (regexp-opt '("break" "continue" "do" "else" "for" "if" "return"
+ "switch" "while" "sizeof" "self" "super") t)))
+ (objc-type-types
+ `(mapconcat 'identity
+ (cons
+ (,@ (eval-when-compile
+ (regexp-opt
+ '("auto" "extern" "register" "static" "typedef" "struct"
+ "union" "enum" "signed" "unsigned" "short" "long"
+ "int" "char" "float" "double" "void" "volatile" "const"
+ "id" "oneway" "in" "out" "inout" "bycopy" "byref"))))
+ objc-font-lock-extra-types)
+ "\\|"))
+ (objc-type-depth `(regexp-opt-depth (,@ objc-type-types)))
+ )
+ (setq objc-font-lock-keywords-1
+ (append
+ ;;
+ ;; The list `c-font-lock-keywords-1' less that for function names.
+ (cdr c-font-lock-keywords-1)
+ (list
+ ;;
+ ;; Fontify compiler directives.
+ '("@\\(\\sw+\\)\\>"
+ (1 font-lock-keyword-face)
+ ("\\=[ \t:<(,]*\\(\\sw+\\)" nil nil
+ (1 font-lock-function-name-face)))
+ ;;
+ ;; Fontify method names and arguments. Oh Lordy!
+ ;; First, on the same line as the function declaration.
+ '("^[+-][ \t]*\\(PRIVATE\\)?[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
+ (1 font-lock-type-face nil t)
+ (3 font-lock-type-face nil t)
+ (4 font-lock-function-name-face)
+ ("\\=[ \t]*\\(\\sw+\\)?:[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
+ nil nil
+ (1 font-lock-function-name-face nil t)
+ (3 font-lock-type-face nil t)
+ (4 font-lock-variable-name-face)))
+ ;; Second, on lines following the function declaration.
+ '(":" ("^[ \t]*\\(\\sw+\\)?:[ \t]*\\((\\([^)\n]+\\))\\)?[ \t]*\\(\\sw+\\)"
+ (beginning-of-line) (end-of-line)
+ (1 font-lock-function-name-face nil t)
+ (3 font-lock-type-face nil t)
+ (4 font-lock-variable-name-face)))
+ )))
+
+ (setq objc-font-lock-keywords-2
+ (append objc-font-lock-keywords-1
+ (list
+ ;;
+ ;; Simple regexps for speed.
+ ;;
+ ;; Fontify all type specifiers.
+ `(eval .
+ (cons (concat "\\<\\(" (,@ objc-type-types) "\\)\\>")
+ 'font-lock-type-face))
+ ;;
+ ;; Fontify all builtin keywords (except case, default and goto; see below).
+ (concat "\\<" objc-keywords "\\>")
+ ;;
+ ;; Fontify case/goto keywords and targets, and case default/goto tags.
+ '("\\<\\(case\\|goto\\)\\>[ \t]*\\(-?\\sw+\\)?"
+ (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
+ ;; Fontify tags iff sole statement on line, otherwise we detect selectors.
+ ;; This must come after the one for keywords and targets.
+ '(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
+ (beginning-of-line) (end-of-line)
+ (1 font-lock-constant-face)))
+ ;;
+ ;; Fontify null object pointers.
+ '("\\<[Nn]il\\>" . font-lock-constant-face)
+ )))
+
+ (setq objc-font-lock-keywords-3
+ (append objc-font-lock-keywords-2
+ ;;
+ ;; More complicated regexps for more complete highlighting for types.
+ ;; We still have to fontify type specifiers individually, as C is so hairy.
+ (list
+ ;;
+ ;; Fontify all storage classes and type specifiers, plus their items.
+ `(eval .
+ (list (concat "\\<\\(" (,@ objc-type-types) "\\)\\>"
+ "\\([ \t*&]+\\sw+\\>\\)*")
+ ;; Fontify each declaration item.
+ (list 'font-lock-match-c-style-declaration-item-and-skip-to-next
+ ;; Start with point after all type specifiers.
+ (list 'goto-char (list 'or (list 'match-beginning
+ (+ (,@ objc-type-depth) 2))
+ '(match-end 1)))
+ ;; Finish with point after first type specifier.
+ '(goto-char (match-end 1))
+ ;; Fontify as a variable or function name.
+ '(1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face)))))
+ ;;
+ ;; Fontify structures, or typedef names, plus their items.
+ '("\\(}\\)[ \t*]*\\sw"
+ (font-lock-match-c-style-declaration-item-and-skip-to-next
+ (goto-char (match-end 1)) nil
+ (1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face))))
+ ;;
+ ;; Fontify anything at beginning of line as a declaration or definition.
+ '("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
+ (1 font-lock-type-face)
+ (font-lock-match-c-style-declaration-item-and-skip-to-next
+ (goto-char (or (match-beginning 2) (match-end 1))) nil
+ (1 (if (match-beginning 2)
+ font-lock-function-name-face
+ font-lock-variable-name-face))))
+ )))
+ )
+
+(defvar objc-font-lock-keywords objc-font-lock-keywords-1
+ "Default expressions to highlight in Objective-C mode.
+See also `objc-font-lock-extra-types'.")
+\f
+;;; Java.
+
+(defconst java-font-lock-keywords-1 nil
+ "Subdued level highlighting for Java mode.")
+
+(defconst java-font-lock-keywords-2 nil
+ "Medium level highlighting for Java mode.
+See also `java-font-lock-extra-types'.")
+
+(defconst java-font-lock-keywords-3 nil
+ "Gaudy level highlighting for Java mode.
+See also `java-font-lock-extra-types'.")
+
+;; Regexps written with help from Fred White <fwhite@bbn.com> and
+;; Anders Lindgren <andersl@csd.uu.se>.
+(let* ((java-keywords
+ (eval-when-compile
+ (regexp-opt
+ '("catch" "do" "else" "super" "this" "finally" "for" "if"
+ ;; Anders Lindgren <andersl@csd.uu.se> says these have gone.
+ ;; "cast" "byvalue" "future" "generic" "operator" "var"
+ ;; "inner" "outer" "rest"
+ "interface" "return" "switch" "throw" "try" "while") t)))
+ ;;
+ ;; These are immediately followed by an object name.
+ (java-minor-types
+ (eval-when-compile
+ (regexp-opt '("boolean" "char" "byte" "short" "int" "long"
+ "float" "double" "void"))))
+ ;;
+ ;; These are eventually followed by an object name.
+ (java-major-types
+ (eval-when-compile
+ (regexp-opt
+ '("abstract" "const" "final" "synchronized" "transient" "static"
+ ;; Anders Lindgren <andersl@csd.uu.se> says this has gone.
+ ;; "threadsafe"
+ "volatile" "public" "private" "protected" "native"))))
+ ;;
+ ;; Random types immediately followed by an object name.
+ (java-other-types
+ '(mapconcat 'identity (cons "\\sw+\\.\\sw+" java-font-lock-extra-types)
+ "\\|"))
+ (java-other-depth `(regexp-opt-depth (,@ java-other-types)))
+ )
+ (setq java-font-lock-keywords-1