(eval-when-compile
(let ((load-path
(if (and (boundp 'byte-compile-dest-file)
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
(load "cc-bytecomp" nil t)))
(cc-require 'cc-defs)
(cc-require-when-compile 'cc-langs)
(cc-require 'cc-vars)
(cc-require 'cc-engine)
(cc-require-when-compile 'cc-awk)
(provide 'cc-fonts)
(cc-external-require 'font-lock)
(cc-bytecomp-defvar parse-sexp-lookup-properties)
(cc-bytecomp-defvar c-preprocessor-face-name)
(cc-bytecomp-defvar c-reference-face-name)
(cc-bytecomp-defun c-fontify-recorded-types-and-refs)
(cc-bytecomp-defun c-font-lock-declarators)
(cc-bytecomp-defun c-font-lock-objc-method)
(cc-bytecomp-defun c-font-lock-invalid-string)
(defconst c-preprocessor-face-name
(cond ((c-face-name-p 'font-lock-preprocessor-face)
'font-lock-preprocessor-face)
((c-face-name-p 'font-lock-builtin-face)
'font-lock-builtin-face)
(t
'font-lock-reference-face)))
(cc-bytecomp-defvar font-lock-constant-face)
(defconst c-label-face-name
(cond ((c-face-name-p 'font-lock-label-face)
'font-lock-label-face)
((and (c-face-name-p 'font-lock-constant-face)
(eq font-lock-constant-face 'font-lock-constant-face))
'font-lock-constant-face)
(t
'font-lock-reference-face)))
(defconst c-constant-face-name
(if (and (c-face-name-p 'font-lock-constant-face)
(eq font-lock-constant-face 'font-lock-constant-face))
'font-lock-constant-face
c-label-face-name))
(defconst c-reference-face-name
(with-no-warnings
(if (and (c-face-name-p 'font-lock-reference-face)
(eq font-lock-reference-face 'font-lock-reference-face))
'font-lock-reference-face
c-label-face-name)))
(defconst c-doc-face-name
(cond ((c-face-name-p 'font-lock-doc-string-face)
'font-lock-doc-string-face)
((c-face-name-p 'font-lock-doc-face)
'font-lock-doc-face)
(t
'font-lock-comment-face)))
(defconst c-doc-markup-face-name
(if (c-face-name-p 'font-lock-doc-markup-face)
'font-lock-doc-markup-face
c-label-face-name))
(defconst c-negation-char-face-name
(if (c-face-name-p 'font-lock-negation-char-face)
'font-lock-negation-char-face))
(cc-bytecomp-defun face-inverse-video-p) (cc-bytecomp-defun face-property-instance)
(defun c-make-inverse-face (oldface newface)
(copy-face oldface newface)
(cond ((fboundp 'face-inverse-video-p)
(unless (face-inverse-video-p oldface)
(invert-face newface)))
((fboundp 'face-property-instance)
(unless (face-property-instance oldface 'reverse)
(invert-face newface)))))
(eval-and-compile
(defmacro c-put-font-lock-face (from to face)
(if (fboundp 'font-lock-set-face)
`(font-lock-set-face ,from ,to ,face)
`(put-text-property ,from ,to 'face ,face)))
(defmacro c-remove-font-lock-face (from to)
(if (fboundp 'font-lock-remove-face)
`(font-lock-remove-face ,from ,to)
`(remove-text-properties ,from ,to '(face nil))))
(defmacro c-put-font-lock-string-face (from to)
(if (featurep 'xemacs)
`(c-put-font-lock-face (1+ ,from) (1- ,to) 'font-lock-string-face)
`(c-put-font-lock-face ,from ,to 'font-lock-string-face)))
(defmacro c-fontify-types-and-refs (varlist &rest body)
`(let ((c-record-type-identifiers t)
c-record-ref-identifiers
,@varlist)
(prog1 (progn ,@body)
(c-fontify-recorded-types-and-refs))))
(put 'c-fontify-types-and-refs 'lisp-indent-function 1)
(defun c-skip-comments-and-strings (limit)
(when (c-got-face-at (point) c-literal-faces)
(while (progn
(goto-char (next-single-property-change
(point) 'face nil limit))
(and (< (point) limit)
(c-got-face-at (point) c-literal-faces))))
t))
(defun c-make-syntactic-matcher (regexp)
(byte-compile
`(lambda (limit)
(let (res)
(while (and (setq res (re-search-forward ,regexp limit t))
(progn
(goto-char (match-beginning 0))
(or (c-skip-comments-and-strings limit)
(progn
(goto-char (match-end 0))
nil)))))
res))))
(defun c-make-font-lock-search-function (regexp &rest highlights)
(byte-compile
`(lambda (limit)
(let ( (parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(while (re-search-forward ,regexp limit t)
(unless (progn
(goto-char (match-beginning 0))
(c-skip-comments-and-strings limit))
(goto-char (match-end 0))
,@(mapcar
(lambda (highlight)
(if (integerp (car highlight))
(progn
(unless (eq (nth 2 highlight) t)
(error
"The override flag must currently be t in %s"
highlight))
(when (nth 3 highlight)
(error
"The laxmatch flag may currently not be set in %s"
highlight))
`(save-match-data
(c-put-font-lock-face
(match-beginning ,(car highlight))
(match-end ,(car highlight))
,(elt highlight 1))))
(when (nth 3 highlight)
(error "Match highlights currently not supported in %s"
highlight))
`(progn
,(nth 1 highlight)
(save-match-data ,(car highlight))
,(nth 2 highlight))))
highlights))))
nil)))
(def-edebug-spec c-fontify-types-and-refs let*)
(def-edebug-spec c-make-syntactic-matcher t)
(def-edebug-spec c-make-font-lock-search-function
(form &rest &or ("quote" (&rest form)) ("`" (&rest form)) form)))
(defun c-fontify-recorded-types-and-refs ()
(let (elem)
(while (consp c-record-type-identifiers)
(setq elem (car c-record-type-identifiers)
c-record-type-identifiers (cdr c-record-type-identifiers))
(c-put-font-lock-face (car elem) (cdr elem)
'font-lock-type-face))
(while c-record-ref-identifiers
(setq elem (car c-record-ref-identifiers)
c-record-ref-identifiers (cdr c-record-ref-identifiers))
(c-put-font-lock-face (car elem) (cdr elem)
c-reference-face-name))))
(c-lang-defconst c-cpp-matchers
"Font lock matchers for preprocessor directives and purely lexical
stuff. Used on level 1 and higher."
t `(,@(when (c-lang-const c-opt-cpp-prefix)
(let* ((noncontinued-line-end "\\(\\=\\|\\(\\=\\|[^\\]\\)[\n\r]\\)")
(ncle-depth (regexp-opt-depth noncontinued-line-end))
(sws-depth (c-lang-const c-syntactic-ws-depth))
(nsws-depth (c-lang-const c-nonempty-syntactic-ws-depth)))
`( ,@(when (c-lang-const c-cpp-message-directives)
(let* ((re (c-make-keywords-re nil
(c-lang-const c-cpp-message-directives)))
(re-depth (regexp-opt-depth re)))
`((,(concat noncontinued-line-end
(c-lang-const c-opt-cpp-prefix)
re
"\\s +\\(.*\\)$")
,(+ ncle-depth re-depth 1) font-lock-string-face))))
,@(when (c-lang-const c-cpp-include-directives)
(let* ((re (c-make-keywords-re nil
(c-lang-const c-cpp-include-directives)))
(re-depth (regexp-opt-depth re)))
`((,(concat noncontinued-line-end
(c-lang-const c-opt-cpp-prefix)
re
(c-lang-const c-syntactic-ws)
"\\(<[^>\n\r]*>?\\)")
(,(+ ncle-depth re-depth sws-depth 1)
font-lock-string-face)
(,(byte-compile
`(lambda (limit)
(let ((beg (match-beginning
,(+ ncle-depth re-depth sws-depth 1)))
(end (1- (match-end ,(+ ncle-depth re-depth
sws-depth 1)))))
(if (eq (char-after end) ?>)
(progn
(c-mark-<-as-paren beg)
(c-mark->-as-paren end))
(c-clear-char-property beg 'syntax-table)))
nil)))))))
,@(when (c-lang-const c-opt-cpp-macro-define)
`((,(c-make-font-lock-search-function
(concat
noncontinued-line-end
(c-lang-const c-opt-cpp-prefix)
(c-lang-const c-opt-cpp-macro-define)
(c-lang-const c-nonempty-syntactic-ws)
"\\(" (c-lang-const c-symbol-key) "\\)"
(concat "\\(" "\\(\(\\)" "\\|"
"\\([^\(]\\|$\\)"
"\\)"))
`((if (match-beginning
,(+ 3 ncle-depth nsws-depth
(c-lang-const c-symbol-key-depth)))
(save-restriction
(c-put-font-lock-face
(match-beginning ,(+ 1 ncle-depth nsws-depth))
(match-end ,(+ 1 ncle-depth nsws-depth))
'font-lock-function-name-face)
(goto-char
(match-end
,(+ 3 ncle-depth nsws-depth
(c-lang-const c-symbol-key-depth))))
(narrow-to-region (point-min) limit)
(while (and
(progn
(c-forward-syntactic-ws)
(looking-at c-symbol-key))
(progn
(c-put-font-lock-face
(match-beginning 0) (match-end 0)
'font-lock-variable-name-face)
(goto-char (match-end 0))
(c-forward-syntactic-ws)
(eq (char-after) ?,)))
(forward-char)))
(c-put-font-lock-face
(match-beginning ,(+ 1 ncle-depth nsws-depth))
(match-end ,(+ 1 ncle-depth nsws-depth))
'font-lock-variable-name-face)))))))
,@(when (and (c-lang-const c-cpp-expr-directives)
(c-lang-const c-cpp-expr-functions))
(let ((ced-re (c-make-keywords-re t
(c-lang-const c-cpp-expr-directives)))
(cef-re (c-make-keywords-re t
(c-lang-const c-cpp-expr-functions))))
`((,(c-make-font-lock-search-function
(concat noncontinued-line-end
(c-lang-const c-opt-cpp-prefix)
ced-re "\\(\\\\\\(.\\|[\n\r]\\)\\|[^\n\r]\\)*")
`((let ((limit (match-end 0)))
(while (re-search-forward ,cef-re limit 'move)
(c-put-font-lock-face (match-beginning 1)
(match-end 1)
c-preprocessor-face-name)))
(goto-char (match-end ,(1+ ncle-depth)))))))))
(,(c-make-font-lock-search-function
(concat noncontinued-line-end
"\\("
(c-lang-const c-opt-cpp-prefix)
"[" (c-lang-const c-symbol-chars) "]+"
"\\)")
`(,(1+ ncle-depth) c-preprocessor-face-name t)))
(eval . (list ,(c-make-syntactic-matcher
(concat noncontinued-line-end
(c-lang-const c-opt-cpp-prefix)
"if\\(n\\)def\\>"))
,(+ ncle-depth 1)
c-negation-char-face-name
'append))
)))
,@(when (c-major-mode-is 'pike-mode)
`((eval . (list "\\`#![^\n\r]*"
0 c-preprocessor-face-name))))
(eval . (list
"\240"
0 (progn
(unless (c-face-name-p 'c-nonbreakable-space-face)
(c-make-inverse-face 'font-lock-warning-face
'c-nonbreakable-space-face))
''c-nonbreakable-space-face)))
))
(defun c-font-lock-invalid-string ()
(let ((start (1- (point))))
(save-excursion
(and (eq (elt (parse-partial-sexp start (c-point 'eol)) 8) start)
(if (integerp c-multiline-string-start-char)
(not (eq (char-before start) c-multiline-string-start-char))
(not c-multiline-string-start-char))
(if c-string-escaped-newlines
(not (eq (char-before (point)) ?\\))
t)
(c-put-font-lock-face start (1+ start) 'font-lock-warning-face)))))
(c-lang-defconst c-basic-matchers-before
"Font lock matchers for basic keywords, labels, references and various
other easily recognizable things that should be fontified before generic
casts and declarations are fontified. Used on level 2 and higher."
t `( ,(c-make-font-lock-search-function
(concat ".\\(" c-string-limit-regexp "\\)")
'((c-font-lock-invalid-string)))
,@(when (c-lang-const c-constant-kwds)
(let ((re (c-make-keywords-re nil (c-lang-const c-constant-kwds))))
(if (c-major-mode-is 'pike-mode)
`((eval . (list ,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)"
"\\<\\(" re "\\)\\>")
2 c-constant-face-name)))
`((eval . (list ,(concat "\\<\\(" re "\\)\\>")
1 c-constant-face-name))))))
,(if (c-major-mode-is 'pike-mode)
`(,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)"
"\\<" (c-lang-const c-regular-keywords-regexp))
2 font-lock-keyword-face)
`(,(concat "\\<" (c-lang-const c-regular-keywords-regexp))
1 font-lock-keyword-face))
,@(when (c-lang-const c-opt-identifier-concat-key)
(if (c-major-mode-is 'java-mode)
`(,(c-make-font-lock-search-function
(concat (c-lang-const c-opt-identifier-concat-key)
(c-lang-const c-simple-ws) "*"
(concat "\\("
"[" c-upper "]"
"[" (c-lang-const c-symbol-chars) "]*"
"\\|"
"\\*"
"\\)"))
`((let (id-end)
(goto-char (1+ (match-beginning 0)))
(while (and (eq (char-before) ?.)
(progn
(backward-char)
(c-backward-syntactic-ws)
(setq id-end (point))
(< (skip-chars-backward
,(c-lang-const c-symbol-chars)) 0))
(not (get-text-property (point) 'face)))
(c-put-font-lock-face (point) id-end
c-reference-face-name)
(c-backward-syntactic-ws)))
nil
(goto-char (match-end 0)))))
`((,(byte-compile
`(lambda (limit)
(while (re-search-forward
,(concat "\\(\\<" "\\(" (c-lang-const c-symbol-key) "\\)" (c-lang-const c-simple-ws) "*"
(c-lang-const c-opt-identifier-concat-key)
(c-lang-const c-simple-ws) "*"
"\\)"
"\\("
(c-lang-const c-opt-after-id-concat-key)
"\\)")
limit t)
(unless (progn
(goto-char (match-beginning 0))
(c-skip-comments-and-strings limit))
(or (get-text-property (match-beginning 2) 'face)
(c-put-font-lock-face (match-beginning 2)
(match-end 2)
c-reference-face-name))
(goto-char (match-end 1))))))))))
,@(when (c-major-mode-is 'objc-mode)
`( ,(c-make-font-lock-search-function
"\\["
'((c-fontify-types-and-refs ()
(c-forward-syntactic-ws limit)
(let ((start (point)))
(when (eq (c-forward-type) 'known)
(goto-char start)
(let ((c-promote-possible-types t))
(c-forward-type))))
(if (> (point) limit) (goto-char limit)))))
,(c-make-font-lock-search-function
(concat "\\<"
(regexp-opt
'("@interface" "@implementation" "@protocol")
t)
"\\>")
'((c-fontify-types-and-refs
( (parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(c-forward-objc-directive)
nil)
(goto-char (match-beginning 0))))))
(eval . (list "\\(!\\)[^=]" 1 c-negation-char-face-name))
))
(defun c-font-lock-complex-decl-prepare (limit)
(when (bobp)
(c-clear-found-types))
(c-clear-char-properties (point) limit 'c-type)
(c-parse-state)
(let ((prop (save-excursion
(c-backward-syntactic-ws)
(unless (bobp)
(c-get-char-property (1- (point)) 'c-type)))))
(when (memq prop '(c-decl-id-start c-decl-type-start))
(c-forward-syntactic-ws limit)
(c-font-lock-declarators limit t (eq prop 'c-decl-type-start))))
nil)
(defun c-font-lock-<>-arglists (limit)
(let ( (parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties)))
(c-parse-and-markup-<>-arglists t)
c-restricted-<>-arglists
id-start id-end id-face pos kwd-sym)
(while (and (< (point) limit)
(re-search-forward c-opt-<>-arglist-start limit t))
(setq id-start (match-beginning 1)
id-end (match-end 1)
pos (point))
(goto-char id-start)
(unless (c-skip-comments-and-strings limit)
(setq kwd-sym nil
c-restricted-<>-arglists nil
id-face (get-text-property id-start 'face))
(if (cond
((eq id-face 'font-lock-type-face)
nil)
((eq id-face 'font-lock-keyword-face)
(when (looking-at c-opt-<>-sexp-key)
(setq kwd-sym (c-keyword-sym (match-string 1)))))
(t
(c-backward-syntactic-ws)
(when (and (memq (char-before) '(?\( ?,))
(not (eq (get-text-property (1- (point)) 'c-type)
'c-decl-arg-start)))
(setq c-restricted-<>-arglists t))
t))
(progn
(goto-char (1- pos))
(unless (c-skip-comments-and-strings limit)
(c-fontify-types-and-refs ()
(when (c-forward-<>-arglist (c-keyword-member
kwd-sym 'c-<>-type-kwds))
(when (and c-opt-identifier-concat-key
(not (get-text-property id-start 'face)))
(c-forward-syntactic-ws)
(if (looking-at c-opt-identifier-concat-key)
(c-put-font-lock-face id-start id-end
c-reference-face-name)
(c-put-font-lock-face id-start id-end
'font-lock-type-face)))))
(goto-char pos)))
(goto-char pos)))))
nil)
(defun c-font-lock-declarators (limit list types)
(c-fontify-types-and-refs
((pos (point)) next-pos id-start id-end
paren-depth
id-face got-init
c-last-identifier-range
(separator-prop (if types 'c-decl-type-start 'c-decl-id-start)))
(while (and
pos
(< (point) limit)
(let (got-identifier)
(setq paren-depth 0)
(while (and (looking-at c-type-decl-prefix-key)
(if (and (c-major-mode-is 'c++-mode)
(match-beginning 2))
(progn
(setq id-start (point))
(c-forward-name)
(if (looking-at "\\(::\\)")
t
(setq got-identifier t)
nil))
t))
(if (eq (char-after) ?\()
(progn
(setq paren-depth (1+ paren-depth))
(forward-char))
(goto-char (match-end 1)))
(c-forward-syntactic-ws))
(unless got-identifier
(setq id-start (point))
(c-forward-name))
(setq id-end (point))
(/= id-end pos))
(or (= paren-depth 0)
(c-safe (goto-char (scan-lists (point) 1 paren-depth))))
(<= (point) limit)
(progn
(when (looking-at c-decl-hangon-key)
(c-forward-keyword-clause 1))
(<= (point) limit))
(c-syntactic-re-search-forward
"[;,]\\|\\s)\\|\\'\\|\\(=\\|\\s(\\)" limit t t))
(setq next-pos (match-beginning 0)
id-face (if (and (eq (char-after next-pos) ?\()
(let (c-last-identifier-range)
(save-excursion
(goto-char next-pos)
(c-at-toplevel-p))))
'font-lock-function-name-face
'font-lock-variable-name-face)
got-init (and (match-beginning 1)
(char-after (match-beginning 1))))
(if types
(let ((c-promote-possible-types t))
(goto-char id-start)
(c-forward-type))
(when (and c-last-identifier-range
(not (get-text-property (car c-last-identifier-range)
'face)))
(c-put-font-lock-face (car c-last-identifier-range)
(cdr c-last-identifier-range)
id-face)))
(goto-char next-pos)
(setq pos nil)
(when list
(cond ((eq id-face 'font-lock-function-name-face)
(if (c-safe (c-forward-sexp 1) t)
(c-forward-syntactic-ws limit)
(goto-char limit)))
(got-init
(and (if (and (eq got-init ?=)
(= (c-forward-token-2 1 nil limit) 0)
(looking-at "{"))
(c-safe (c-forward-sexp) t)
t)
(c-syntactic-re-search-forward "[;,{]" limit 'move t)
(backward-char)))
(t (c-forward-syntactic-ws limit)))
(when (and (< (point) limit) (looking-at ","))
(c-put-char-property (point) 'c-type separator-prop)
(forward-char)
(c-forward-syntactic-ws limit)
(setq pos (point))))))
nil)
(defconst c-font-lock-maybe-decl-faces
(list nil
font-lock-type-face
c-reference-face-name
font-lock-keyword-face))
(defun c-font-lock-declarations (limit)
(save-restriction
(let ( start-pos
context
last-cast-end
decl-or-cast
(max-type-decl-end 0)
(max-type-decl-end-before-token 0)
c-restricted-<>-arglists
(c-record-type-identifiers t)
label-type
c-record-ref-identifiers
(c-parse-and-markup-<>-arglists t)
(parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(narrow-to-region
(point-min)
(if (<= limit (c-point 'bonl))
(save-excursion
(goto-char limit)
(skip-chars-forward c-nonsymbol-chars)
(point))
limit))
(c-find-decl-spots
limit
c-decl-start-re
c-font-lock-maybe-decl-faces
(lambda (match-pos inside-macro)
(setq start-pos (point))
(when
(if (and (eq (get-text-property (point) 'face)
'font-lock-keyword-face)
(looking-at c-not-decl-init-keywords))
t
(if (memq (char-before match-pos) '(?\( ?, ?\[ ?<))
(if (<= match-pos (point-min))
(setq context 'arglist)
(let ((type (c-get-char-property (1- match-pos) 'c-type)))
(cond ((eq type 'c-decl-arg-start)
(setq context 'decl))
((or (eq type 'c-<>-arg-sep)
(eq (char-before match-pos) ?<))
(setq context '<>))
(type
(setq context 'arglist))
((if inside-macro
(< match-pos max-type-decl-end-before-token)
(< match-pos max-type-decl-end))
(setq context 'decl)
(c-put-char-property (1- match-pos)
'c-type 'c-decl-arg-start))
(t
(setq context 'arglist)))))
(setq context nil))
(setq c-restricted-<>-arglists (and c-recognize-<>-arglists
(eq context 'arglist))
decl-or-cast (c-forward-decl-or-cast-1
match-pos context last-cast-end))
(if (not decl-or-cast)
t
(if (eq decl-or-cast 'cast)
(setq last-cast-end (point))
(if inside-macro
(when (> (point) max-type-decl-end-before-token)
(setq max-type-decl-end-before-token (point)))
(when (> (point) max-type-decl-end)
(setq max-type-decl-end (point))))
(goto-char (car decl-or-cast))
(let ((decl-list
(if context
(when (eq (char-before match-pos) ?\()
(save-excursion
(goto-char (1- match-pos))
(c-backward-syntactic-ws)
(and (c-simple-skip-symbol-backward)
(looking-at c-paren-stmt-key))))
t)))
(when decl-list
(save-excursion
(c-backward-syntactic-ws)
(unless (bobp)
(c-put-char-property (1- (point)) 'c-type
(if (cdr decl-or-cast)
'c-decl-type-start
'c-decl-id-start)))))
(c-font-lock-declarators
(point-max) decl-list (cdr decl-or-cast))))
(c-fontify-recorded-types-and-refs)
nil))
(goto-char start-pos)
(when (setq label-type (c-forward-label t match-pos nil))
(cond ((eq label-type 'goto-target)
(c-put-font-lock-face (caar c-record-ref-identifiers)
(cdar c-record-ref-identifiers)
c-label-face-name))
((eq label-type 'qt-1kwd-colon)
(c-put-font-lock-face (caar c-record-ref-identifiers)
(cdar c-record-ref-identifiers)
'font-lock-keyword-face))
((eq label-type 'qt-2kwds-colon)
(mapc
(lambda (kwd)
(c-put-font-lock-face (car kwd) (cdr kwd)
'font-lock-keyword-face))
c-record-ref-identifiers)))
(setq c-record-ref-identifiers nil)
t))))
nil)))
(c-lang-defconst c-simple-decl-matchers
"Simple font lock matchers for types and declarations. These are used
on level 2 only and so aren't combined with `c-complex-decl-matchers'."
t `( ,@(when (c-major-mode-is 'objc-mode)
`((,(c-lang-const c-opt-method-key)
(,(byte-compile
(lambda (limit)
(let ( (parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(save-restriction
(narrow-to-region (point-min) limit)
(c-font-lock-objc-method)))
nil))
(goto-char (match-end 1))))))
(eval . (list ,(c-make-font-lock-search-function
'c-known-type-key
'(1 'font-lock-type-face t)
'((c-font-lock-declarators limit t nil)
(save-match-data
(goto-char (match-end 1))
(c-forward-syntactic-ws))
(goto-char (match-end 1))))))
,@(when (c-lang-const c-type-prefix-kwds)
(let* ((prefix-re (c-make-keywords-re nil
(c-lang-const c-type-prefix-kwds)))
(type-match (+ 2
(regexp-opt-depth prefix-re)
(c-lang-const c-simple-ws-depth))))
`((,(c-make-font-lock-search-function
(concat "\\<\\(" prefix-re "\\)" (c-lang-const c-simple-ws) "+"
(concat "\\(" (c-lang-const c-symbol-key)
"\\)"))
`(,type-match
'font-lock-type-face t)
`((c-font-lock-declarators limit t nil)
(save-match-data
(goto-char (match-end ,type-match))
(c-forward-syntactic-ws))
(goto-char (match-end ,type-match))))))))
,@(when (c-lang-const c-typeless-decl-kwds)
`((,(c-make-font-lock-search-function
(concat "\\<\\("
(regexp-opt (c-lang-const c-typeless-decl-kwds))
"\\)\\>")
'((c-font-lock-declarators limit t nil)
(save-match-data
(goto-char (match-end 1))
(c-forward-syntactic-ws))
(goto-char (match-end 1)))))))
,@(when (c-lang-const c-recognize-colon-labels)
`(c-font-lock-labels))))
(c-lang-defconst c-complex-decl-matchers
"Complex font lock matchers for types and declarations. Used on level
3 and higher."
t `( c-font-lock-complex-decl-prepare
,@(if (c-major-mode-is 'objc-mode)
`(,(c-make-font-lock-search-function
(c-make-keywords-re t
(delete "@class"
(append (c-lang-const c-protection-kwds)
(c-lang-const c-other-decl-kwds)
nil)))
'((c-put-char-property (1- (match-end 1))
'c-type 'c-decl-end)))
c-font-lock-objc-methods))
c-font-lock-declarations
,@(when (c-lang-const c-recognize-<>-arglists)
`(c-font-lock-<>-arglists))
,(let ((re (c-make-keywords-re nil
(c-lang-const c-primitive-type-kwds))))
(if (c-major-mode-is 'pike-mode)
`(,(concat "\\(\\=.?\\|[^>]\\|[^-]>\\)"
"\\<\\(" re "\\)\\>")
2 font-lock-type-face)
`(,(concat "\\<\\(" re "\\)\\>")
1 'font-lock-type-face)))
,@(when (c-lang-const c-type-prefix-kwds)
`((,(byte-compile
`(lambda (limit)
(c-fontify-types-and-refs
((c-promote-possible-types t)
(parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(save-restriction
(narrow-to-region (point) limit)
(while (re-search-forward
,(concat "\\<\\("
(c-make-keywords-re nil
(c-lang-const c-type-prefix-kwds))
"\\)\\>")
limit t)
(unless (c-skip-comments-and-strings limit)
(c-forward-syntactic-ws)
(when (looking-at c-prefix-spec-kwds-re)
(c-forward-keyword-clause 1))
,(if (c-major-mode-is 'c++-mode)
`(when (and (c-forward-type)
(eq (char-after) ?=))
(forward-char)
(c-forward-syntactic-ws)
(c-forward-type))
`(c-forward-type))
)))))))))
,@(when (c-lang-const c-opt-block-decls-with-vars-key)
`((,(c-make-font-lock-search-function
(concat "}"
(c-lang-const c-single-line-syntactic-ws)
"\\(" (c-lang-const c-type-decl-prefix-key)
"\\|"
(c-lang-const c-symbol-key)
"\\)")
`((c-font-lock-declarators limit t nil)
(progn
(c-put-char-property (match-beginning 0) 'c-type
'c-decl-id-start)
(goto-char (match-beginning
,(1+ (c-lang-const
c-single-line-syntactic-ws-depth)))))
(goto-char (match-end 0)))))))
,@(when (c-major-mode-is 'c++-mode)
`(("\\<new\\>"
(c-font-lock-c++-new))))
))
(defun c-font-lock-labels (limit)
(let (continue-pos id-start
(parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(while (re-search-forward ":[^:]" limit t)
(setq continue-pos (point))
(goto-char (match-beginning 0))
(unless (c-skip-comments-and-strings limit)
(c-backward-syntactic-ws)
(and (setq id-start (c-on-identifier))
(not (get-text-property id-start 'face))
(progn
(goto-char id-start)
(c-backward-syntactic-ws)
(or
(memq (char-before) '(?\} ?\{ ?\ (and (eq (char-before) ?:)
(progn
(backward-char)
(c-backward-syntactic-ws)
(not (bobp)))
(eq (get-text-property (1- (point)) 'face)
c-label-face-name))
(c-after-conditional)))
(progn
(goto-char id-start)
(looking-at c-symbol-key)
(c-put-font-lock-face (match-beginning 0) (match-end 0)
c-label-face-name)))
(goto-char continue-pos))))
nil)
(c-lang-defconst c-basic-matchers-after
"Font lock matchers for various things that should be fontified after
generic casts and declarations are fontified. Used on level 2 and
higher."
t `( ,@(when (c-lang-const c-brace-id-list-kwds)
`((,(c-make-font-lock-search-function
(concat
"\\<\\("
(c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds))
"\\)\\>"
"[^\]\[{}();,/#=]*"
"{")
'((c-font-lock-declarators limit t nil)
(save-match-data
(goto-char (match-end 0))
(c-put-char-property (1- (point)) 'c-type
'c-decl-id-start)
(c-forward-syntactic-ws))
(goto-char (match-end 0)))))))
,@(when (c-lang-const c-before-label-kwds)
`( (eval
. ,(let* ((c-before-label-re
(c-make-keywords-re nil
(c-lang-const c-before-label-kwds))))
`(list
,(concat "\\<\\(" c-before-label-re "\\)\\>"
"\\s *"
"\\(" (c-lang-const c-symbol-key)
"\\)")
(list ,(+ (regexp-opt-depth c-before-label-re) 2)
c-label-face-name nil t))))))
,@(when (or (c-lang-const c-type-list-kwds)
(c-lang-const c-ref-list-kwds)
(c-lang-const c-colon-type-list-kwds)
(c-lang-const c-paren-type-kwds))
`((,(c-make-font-lock-search-function
(concat "\\<\\("
(c-make-keywords-re nil
(append (c-lang-const c-type-list-kwds)
(c-lang-const c-ref-list-kwds)
(c-lang-const c-colon-type-list-kwds)
(c-lang-const c-paren-type-kwds)))
"\\)\\>")
'((c-fontify-types-and-refs ((c-promote-possible-types t))
(c-forward-keyword-clause 1)
(if (> (point) limit) (goto-char limit))))))))
))
(c-lang-defconst c-matchers-1
t (c-lang-const c-cpp-matchers))
(c-lang-defconst c-matchers-2
t (append (c-lang-const c-matchers-1)
(c-lang-const c-basic-matchers-before)
(c-lang-const c-simple-decl-matchers)
(c-lang-const c-basic-matchers-after)))
(c-lang-defconst c-matchers-3
t (append (c-lang-const c-matchers-1)
(c-lang-const c-basic-matchers-before)
(c-lang-const c-complex-decl-matchers)
(c-lang-const c-basic-matchers-after)))
(defun c-compose-keywords-list (base-list)
(unless (memq c-doc-face-name c-literal-faces)
(setq c-literal-faces (cons c-doc-face-name c-literal-faces)))
(let* ((doc-keywords
(if (consp (car-safe c-doc-comment-style))
(cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style)
(assq 'other c-doc-comment-style)))
c-doc-comment-style))
(list (nconc (apply 'nconc
(mapcar
(lambda (doc-style)
(let ((sym (intern
(concat (symbol-name doc-style)
"-font-lock-keywords"))))
(cond ((fboundp sym)
(funcall sym))
((boundp sym)
(append (eval sym) nil)))))
(if (listp doc-keywords)
doc-keywords
(list doc-keywords))))
base-list)))
(when (memq 'c-font-lock-complex-decl-prepare list)
(setq list (cons 'c-font-lock-complex-decl-prepare
(delq 'c-font-lock-complex-decl-prepare
(append list nil)))))
list))
(defun c-override-default-keywords (def-var)
(when (and (boundp def-var)
(memq (symbol-value def-var)
(cons nil
(mapcar
(lambda (suffix)
(let ((sym (intern (concat (symbol-name def-var)
suffix))))
(and (boundp sym) (symbol-value sym))))
'("-1" "-2" "-3")))))
(makunbound def-var)))
(c-override-default-keywords 'c-font-lock-keywords)
(defconst c-font-lock-keywords-1 (c-lang-const c-matchers-1 c)
"Minimal font locking for C mode.
Fontifies only preprocessor directives (in addition to the syntactic
fontification of strings and comments).")
(defconst c-font-lock-keywords-2 (c-lang-const c-matchers-2 c)
"Fast normal font locking for C mode.
In addition to `c-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `c-font-lock-extra-types', and the doc comment
styles specified by `c-doc-comment-style'.")
(defconst c-font-lock-keywords-3 (c-lang-const c-matchers-3 c)
"Accurate normal font locking for C mode.
Like `c-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `c-font-lock-extra-types'.")
(defvar c-font-lock-keywords c-font-lock-keywords-3
"Default expressions to highlight in C mode.")
(defun c-font-lock-keywords-2 ()
(c-compose-keywords-list c-font-lock-keywords-2))
(defun c-font-lock-keywords-3 ()
(c-compose-keywords-list c-font-lock-keywords-3))
(defun c-font-lock-keywords ()
(c-compose-keywords-list c-font-lock-keywords))
(defun c-font-lock-c++-new (limit)
(unless (c-skip-comments-and-strings limit)
(save-excursion
(catch 'false-alarm
(let (expr1-pos expr2-pos
(c-record-type-identifiers t)
c-record-ref-identifiers
(parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(c-forward-syntactic-ws)
(when (eq (char-after) ?\()
(setq expr1-pos (1+ (point)))
(condition-case nil
(c-forward-sexp)
(scan-error (throw 'false-alarm t)))
(c-forward-syntactic-ws))
(setq expr2-pos (1+ (point)))
(cond ((eq (char-after) ?\())
((let ((c-promote-possible-types t))
(c-forward-type)))
(t (setq expr2-pos nil)))
(when expr1-pos
(cond
((not expr2-pos)
(goto-char expr1-pos)
(let ((c-promote-possible-types t))
(c-forward-type)))
((eq (char-before expr2-pos) ?\()
(let (expr1-res expr2-res)
(goto-char expr1-pos)
(when (setq expr1-res (c-forward-type))
(unless (looking-at
(cc-eval-when-compile
(concat (c-lang-const c-symbol-start c++)
"\\|[*:\)\[]")))
(setq expr1-res nil)))
(goto-char expr2-pos)
(when (setq expr2-res (c-forward-type))
(unless (looking-at
(cc-eval-when-compile
(concat (c-lang-const c-symbol-start c++)
"\\|[*:\)\[]")))
(setq expr2-res nil))
(when (and (c-go-up-list-forward)
(progn (c-forward-syntactic-ws)
(eq (char-after) ?\()))
(setq expr1-res nil)))
(cond ((memq expr1-res '(t known prefix)))
((memq expr2-res '(t known prefix)))
((eq expr1-res 'found)
(let ((c-promote-possible-types t))
(goto-char expr1-pos)
(c-forward-type)))
((eq expr2-res 'found)
(let ((c-promote-possible-types t))
(goto-char expr2-pos)
(c-forward-type)))
((and (eq expr1-res 'maybe) (not expr2-res))
(let ((c-promote-possible-types t))
(goto-char expr1-pos)
(c-forward-type)))
((and (not expr1-res) (eq expr2-res 'maybe))
(let ((c-promote-possible-types t))
(goto-char expr2-pos)
(c-forward-type)))
)))))
(c-fontify-recorded-types-and-refs)))))
nil)
(c-override-default-keywords 'c++-font-lock-keywords)
(defconst c++-font-lock-keywords-1 (c-lang-const c-matchers-1 c++)
"Minimal font locking for C++ mode.
Fontifies only preprocessor directives (in addition to the syntactic
fontification of strings and comments).")
(defconst c++-font-lock-keywords-2 (c-lang-const c-matchers-2 c++)
"Fast normal font locking for C++ mode.
In addition to `c++-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `c++-font-lock-extra-types', and the doc comment
styles specified by `c-doc-comment-style'.")
(defconst c++-font-lock-keywords-3 (c-lang-const c-matchers-3 c++)
"Accurate normal font locking for C++ mode.
Like `c++-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `c++-font-lock-extra-types'.")
(defvar c++-font-lock-keywords c++-font-lock-keywords-3
"Default expressions to highlight in C++ mode.")
(defun c++-font-lock-keywords-2 ()
(c-compose-keywords-list c++-font-lock-keywords-2))
(defun c++-font-lock-keywords-3 ()
(c-compose-keywords-list c++-font-lock-keywords-3))
(defun c++-font-lock-keywords ()
(c-compose-keywords-list c++-font-lock-keywords))
(defun c-font-lock-objc-method ()
(c-fontify-types-and-refs
((first t)
(c-promote-possible-types t))
(while (and
(progn
(c-forward-syntactic-ws)
(if (eq (char-after) ?\()
(progn
(forward-char)
(c-forward-syntactic-ws)
(c-forward-type)
(prog1 (c-go-up-list-forward)
(c-forward-syntactic-ws)))
t))
(looking-at c-symbol-key)
(progn
(goto-char (match-end 0))
(c-put-font-lock-face (match-beginning 0)
(point)
(if first
'font-lock-function-name-face
'font-lock-variable-name-face))
(c-forward-syntactic-ws)
(when (looking-at c-symbol-key)
(goto-char (match-end 0))
(c-put-font-lock-face (match-beginning 0)
(point)
'font-lock-function-name-face)
(c-forward-syntactic-ws))
(eq (char-after) ?:)))
(forward-char)
(setq first nil))))
(defun c-font-lock-objc-methods (limit)
(let ( (parse-sexp-lookup-properties
(cc-eval-when-compile
(boundp 'parse-sexp-lookup-properties))))
(c-find-decl-spots
limit
"[-+]"
nil
(lambda (match-pos inside-macro)
(forward-char)
(c-font-lock-objc-method))))
nil)
(c-override-default-keywords 'objc-font-lock-keywords)
(defconst objc-font-lock-keywords-1 (c-lang-const c-matchers-1 objc)
"Minimal font locking for Objective-C mode.
Fontifies only compiler directives (in addition to the syntactic
fontification of strings and comments).")
(defconst objc-font-lock-keywords-2 (c-lang-const c-matchers-2 objc)
"Fast normal font locking for Objective-C mode.
In addition to `objc-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `objc-font-lock-extra-types', and the doc
comment styles specified by `c-doc-comment-style'.")
(defconst objc-font-lock-keywords-3 (c-lang-const c-matchers-3 objc)
"Accurate normal font locking for Objective-C mode.
Like `objc-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `objc-font-lock-extra-types'.")
(defvar objc-font-lock-keywords objc-font-lock-keywords-3
"Default expressions to highlight in Objective-C mode.")
(defun objc-font-lock-keywords-2 ()
(c-compose-keywords-list objc-font-lock-keywords-2))
(defun objc-font-lock-keywords-3 ()
(c-compose-keywords-list objc-font-lock-keywords-3))
(defun objc-font-lock-keywords ()
(c-compose-keywords-list objc-font-lock-keywords))
(when (equal (sort (append objc-font-lock-extra-types nil) 'string-lessp)
'("BOOL" "Class" "IMP" "SEL"))
(setq objc-font-lock-extra-types
(cc-eval-when-compile (list (concat "[" c-upper "]\\sw*")))))
(c-override-default-keywords 'java-font-lock-keywords)
(defconst java-font-lock-keywords-1 (c-lang-const c-matchers-1 java)
"Minimal font locking for Java mode.
Fontifies nothing except the syntactic fontification of strings and
comments.")
(defconst java-font-lock-keywords-2 (c-lang-const c-matchers-2 java)
"Fast normal font locking for Java mode.
In addition to `java-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `java-font-lock-extra-types', and the doc
comment styles specified by `c-doc-comment-style'.")
(defconst java-font-lock-keywords-3 (c-lang-const c-matchers-3 java)
"Accurate normal font locking for Java mode.
Like `java-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `java-font-lock-extra-types'.")
(defvar java-font-lock-keywords java-font-lock-keywords-3
"Default expressions to highlight in Java mode.")
(defun java-font-lock-keywords-2 ()
(c-compose-keywords-list java-font-lock-keywords-2))
(defun java-font-lock-keywords-3 ()
(c-compose-keywords-list java-font-lock-keywords-3))
(defun java-font-lock-keywords ()
(c-compose-keywords-list java-font-lock-keywords))
(c-override-default-keywords 'idl-font-lock-keywords)
(defconst idl-font-lock-keywords-1 (c-lang-const c-matchers-1 idl)
"Minimal font locking for CORBA IDL mode.
Fontifies nothing except the syntactic fontification of strings and
comments.")
(defconst idl-font-lock-keywords-2 (c-lang-const c-matchers-2 idl)
"Fast normal font locking for CORBA IDL mode.
In addition to `idl-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `idl-font-lock-extra-types', and the doc comment
styles specified by `c-doc-comment-style'.")
(defconst idl-font-lock-keywords-3 (c-lang-const c-matchers-3 idl)
"Accurate normal font locking for CORBA IDL mode.
Like `idl-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `idl-font-lock-extra-types'.")
(defvar idl-font-lock-keywords idl-font-lock-keywords-3
"Default expressions to highlight in CORBA IDL mode.")
(defun idl-font-lock-keywords-2 ()
(c-compose-keywords-list idl-font-lock-keywords-2))
(defun idl-font-lock-keywords-3 ()
(c-compose-keywords-list idl-font-lock-keywords-3))
(defun idl-font-lock-keywords ()
(c-compose-keywords-list idl-font-lock-keywords))
(c-override-default-keywords 'pike-font-lock-keywords)
(defconst pike-font-lock-keywords-1 (c-lang-const c-matchers-1 pike)
"Minimal font locking for Pike mode.
Fontifies only preprocessor directives (in addition to the syntactic
fontification of strings and comments).")
(defconst pike-font-lock-keywords-2 (c-lang-const c-matchers-2 pike)
"Fast normal font locking for Pike mode.
In addition to `pike-font-lock-keywords-1', this adds fontification of
keywords, simple types, declarations that are easy to recognize, the
user defined types on `pike-font-lock-extra-types', and the doc
comment styles specified by `c-doc-comment-style'.")
(defconst pike-font-lock-keywords-3 (c-lang-const c-matchers-3 pike)
"Accurate normal font locking for Pike mode.
Like `pike-font-lock-keywords-2' but detects declarations in a more
accurate way that works in most cases for arbitrary types without the
need for `pike-font-lock-extra-types'.")
(defvar pike-font-lock-keywords pike-font-lock-keywords-3
"Default expressions to highlight in Pike mode.")
(defun pike-font-lock-keywords-2 ()
(c-compose-keywords-list pike-font-lock-keywords-2))
(defun pike-font-lock-keywords-3 ()
(c-compose-keywords-list pike-font-lock-keywords-3))
(defun pike-font-lock-keywords ()
(c-compose-keywords-list pike-font-lock-keywords))
(defun c-font-lock-doc-comments (prefix limit keywords)
(let (comment-beg region-beg)
(if (eq (get-text-property (point) 'face)
'font-lock-comment-face)
(let ((range (c-literal-limits)))
(setq region-beg (point))
(when range
(goto-char (car range)))
(when (looking-at prefix)
(setq comment-beg (point)))))
(while (or
comment-beg
(while (when (re-search-forward prefix limit t)
(setq comment-beg (match-beginning 0))
(or (not (c-got-face-at comment-beg
c-literal-faces))
(and (/= comment-beg (point-min))
(c-got-face-at (1- comment-beg)
c-literal-faces))))
(setq comment-beg nil))
(setq region-beg comment-beg))
(if (eq (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7) t)
(progn
(goto-char comment-beg)
(while (and (progn
(c-forward-single-comment)
(skip-syntax-forward " ")
(< (point) limit))
(looking-at prefix))))
(goto-char comment-beg)
(c-forward-single-comment))
(if (> (point) limit) (goto-char limit))
(setq comment-beg nil)
(let ((region-end (point))
(keylist keywords) keyword matcher highlights)
(c-put-font-lock-face region-beg region-end c-doc-face-name)
(save-restriction
(and (> region-end (1+ region-beg))
(progn (goto-char region-end)
(backward-char 2)
(looking-at "\\*/"))
(setq region-end (point)))
(narrow-to-region region-beg region-end)
(while keylist
(setq keyword (car keylist)
keylist (cdr keylist)
matcher (car keyword))
(goto-char region-beg)
(while (if (stringp matcher)
(re-search-forward matcher region-end t)
(funcall matcher region-end))
(setq highlights (cdr keyword))
(if (consp (car highlights))
(while highlights
(font-lock-apply-highlight (car highlights))
(setq highlights (cdr highlights)))
(font-lock-apply-highlight highlights))))
(goto-char region-end)))))
nil)
(put 'c-font-lock-doc-comments 'lisp-indent-function 2)
(defun c-find-invalid-doc-markup (regexp limit)
(let (start)
(while (if (re-search-forward regexp limit t)
(not (eq (get-text-property
(setq start (match-beginning 0)) 'face)
c-doc-face-name))
(setq start nil)))
(when start
(store-match-data (list (copy-marker start)
(copy-marker (1+ start))))
t)))
(defconst gtkdoc-font-lock-doc-comments
(let ((symbol "[a-zA-Z0-9_]+")
(header "^ \\* "))
`((,(concat header "\\(" symbol "\\):[ \t]*$")
1 ,c-doc-markup-face-name prepend nil)
(,(concat symbol "()")
0 ,c-doc-markup-face-name prepend nil)
(,(concat header "\\(" "@" symbol "\\):")
1 ,c-doc-markup-face-name prepend nil)
(,(concat "[#%]" symbol)
0 ,c-doc-markup-face-name prepend nil))
))
(defconst gtkdoc-font-lock-doc-protection
`(("< \\(public\\|private\\|protected\\) >"
1 ,c-doc-markup-face-name prepend nil)))
(defconst gtkdoc-font-lock-keywords
`((,(lambda (limit)
(c-font-lock-doc-comments "/\\*\\*$" limit
gtkdoc-font-lock-doc-comments)
(c-font-lock-doc-comments "/\\*< " limit
gtkdoc-font-lock-doc-protection)
))))
(defconst javadoc-font-lock-doc-comments
`(("{@[a-z]+[^}\n\r]*}" 0 ,c-doc-markup-face-name prepend nil)
("^\\(/\\*\\)?\\(\\s \\|\\*\\)*\\(@[a-z]+\\)" 3 ,c-doc-markup-face-name prepend nil)
(,(concat "</?\\sw" "\\("
(concat "\\sw\\|\\s \\|[=\n\r*.:]\\|"
"\"[^\"]*\"\\|'[^']*'")
"\\)*>")
0 ,c-doc-markup-face-name prepend nil)
("&\\(\\sw\\|[.:]\\)+;" 0 ,c-doc-markup-face-name prepend nil)
(,(lambda (limit)
(c-find-invalid-doc-markup "[<>&]\\|{@" limit))
0 'font-lock-warning-face prepend nil)))
(defconst javadoc-font-lock-keywords
`((,(lambda (limit)
(c-font-lock-doc-comments "/\\*\\*" limit
javadoc-font-lock-doc-comments)))))
(defconst autodoc-decl-keywords
(cc-eval-when-compile
(c-make-keywords-re t '("@decl" "@elem" "@index" "@member") 'pike-mode)))
(defconst autodoc-decl-type-keywords
(cc-eval-when-compile
(c-make-keywords-re t '("@elem" "@member") 'pike-mode)))
(defun autodoc-font-lock-line-markup (limit)
(let ((line-re (concat "^\\(\\(/\\*!\\|\\s *\\("
c-current-comment-prefix
"\\)\\)\\s *\\)@[A-Za-z_-]+\\(\\s \\|$\\)"))
(markup-faces (list c-doc-markup-face-name c-doc-face-name)))
(while (re-search-forward line-re limit t)
(goto-char (match-end 1))
(if (looking-at autodoc-decl-keywords)
(let* ((kwd-pos (point))
(start (match-end 1))
(pos start)
end)
(c-put-font-lock-face (point) pos markup-faces)
(c-put-char-property (1- pos) 'c-type 'c-decl-end)
(goto-char pos)
(while (progn
(end-of-line)
(setq end (point))
(and (eq (char-before) ?@)
(not (eobp))
(progn (forward-char)
(skip-syntax-forward " ")
(looking-at c-current-comment-prefix))))
(goto-char (match-end 0))
(c-remove-font-lock-face pos (1- end))
(c-put-font-lock-face (1- end) end markup-faces)
(setq pos (point)))
(c-remove-font-lock-face pos (min (1+ (point)) (point-max)))
(goto-char start)
(while (re-search-forward
"\"\\([^\\\"]\\|\\\\.\\)*\"\\|'\\([^\\']\\|\\\\.\\)*'"
end 'move)
(c-put-font-lock-string-face (match-beginning 0)
(point)))
(goto-char kwd-pos)
(when (looking-at autodoc-decl-type-keywords)
(c-fontify-types-and-refs ((c-promote-possible-types t))
(goto-char start)
(c-forward-syntactic-ws)
(c-forward-type))))
(while (progn
(c-put-font-lock-face (point)
(progn (end-of-line) (point))
markup-faces)
(and (eq (char-before) ?@)
(not (eobp))
(progn (forward-char)
(skip-syntax-forward " ")
(looking-at c-current-comment-prefix))))
(goto-char (match-end 0))))))
nil)
(defconst autodoc-font-lock-doc-comments
`(("@\\(\\w+{\\|\\[\\([^\]@\n\r]\\|@@\\)*\\]\\|[@}]\\|$\\)"
0 ,c-doc-markup-face-name prepend nil)
(autodoc-font-lock-line-markup)
(,(lambda (limit)
(c-find-invalid-doc-markup "@" limit))
0 'font-lock-warning-face prepend nil)
))
(defun autodoc-font-lock-keywords ()
(setq c-type-decl-end-used t)
`((,(lambda (limit)
(c-font-lock-doc-comments "/[*/]!" limit
autodoc-font-lock-doc-comments)))))
(cc-provide 'cc-fonts)