Refill some long/short copyright headers.
[bpt/emacs.git] / lisp / progmodes / cc-langs.el
index ac6ff40..86a963b 100644 (file)
@@ -1,8 +1,6 @@
 ;;; cc-langs.el --- language specific settings for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2011  Free Software Foundation, Inc.
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -12,8 +10,8 @@
 ;;             1985 Richard M. Stallman
 ;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
-;; Version:    See cc-mode.el
-;; Keywords:   c languages oop
+;; Keywords:   c languages
+;; Package:    cc-mode
 
 ;; This file is part of GNU Emacs.
 
@@ -359,7 +357,7 @@ The syntax tables aren't stored directly since they're quite large."
        (let ((table (make-syntax-table)))
         (c-populate-syntax-table table)
         ;; Mode specific syntaxes.
-        ,(cond ((c-major-mode-is 'objc-mode)
+        ,(cond ((or (c-major-mode-is 'objc-mode) (c-major-mode-is 'java-mode))
                 ;; Let '@' be part of symbols in ObjC to cope with
                 ;; its compiler directives as single keyword tokens.
                 ;; This is then necessary since it's assumed that
@@ -382,7 +380,7 @@ The syntax tables aren't stored directly since they're quite large."
   ;; '<' and '>' characters.  Therefore this syntax table might go
   ;; away when CC Mode handles templates correctly everywhere.
   t   nil
-  c++ `(lambda ()
+  (java c++) `(lambda ()
         (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
           (modify-syntax-entry ?< "(>" table)
           (modify-syntax-entry ?> ")<" table)
@@ -391,6 +389,27 @@ The syntax tables aren't stored directly since they're quite large."
   (and (c-lang-const c++-make-template-syntax-table)
        (funcall (c-lang-const c++-make-template-syntax-table))))
 
+(c-lang-defconst c-no-parens-syntax-table
+  ;; A variant of the standard syntax table which is used to find matching
+  ;; "<"s and ">"s which have been marked as parens using syntax table
+  ;; properties.  The other paren characters (e.g. "{", ")" "]") are given a
+  ;; non-paren syntax here. so that the list commands will work on "< ... >"
+  ;; even when there's unbalanced other parens inside them.
+  ;;
+  ;; This variable is nil for languages which don't have template stuff.
+  t  `(lambda ()
+       (if (c-lang-const c-recognize-<>-arglists)
+           (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))
+             (modify-syntax-entry ?\( "." table)
+             (modify-syntax-entry ?\) "." table)
+             (modify-syntax-entry ?\[ "." table)
+             (modify-syntax-entry ?\] "." table)
+             (modify-syntax-entry ?\{ "." table)
+             (modify-syntax-entry ?\} "." table)
+             table))))
+(c-lang-defvar c-no-parens-syntax-table
+              (funcall (c-lang-const c-no-parens-syntax-table)))
+
 (c-lang-defconst c-identifier-syntax-modifications
   "A list that describes the modifications that should be done to the
 mode syntax table to get a syntax table that matches all identifiers
@@ -404,7 +423,7 @@ the new syntax, as accepted by `modify-syntax-entry'."
   ;; it as an indentifier character since it's often used in various
   ;; machine generated identifiers.
   t    '((?_ . "w") (?$ . "w"))
-  objc (append '((?@ . "w"))
+  (objc java) (append '((?@ . "w"))
               (c-lang-const c-identifier-syntax-modifications))
   awk  '((?_ . "w")))
 (c-lang-defvar c-identifier-syntax-modifications
@@ -423,26 +442,36 @@ the new syntax, as accepted by `modify-syntax-entry'."
 classifies symbol constituents like '_' and '$' as word constituents,
 so that all identifiers are recognized as words.")
 
-(c-lang-defconst c-get-state-before-change-function
-  "If non-nil, a function called from c-before-change-hook.
-Typically it will record enough state to allow
+(c-lang-defconst c-get-state-before-change-functions
+  ;; For documentation see the following c-lang-defvar of the same name.
+  ;; The value here may be a list of functions or a single function.
+  t nil
+  c++ '(c-extend-region-for-CPP c-before-change-check-<>-operators)
+  (c objc) 'c-extend-region-for-CPP
+  ;; java 'c-before-change-check-<>-operators
+  awk 'c-awk-record-region-clear-NL)
+(c-lang-defvar c-get-state-before-change-functions
+              (let ((fs (c-lang-const c-get-state-before-change-functions)))
+                 (if (listp fs)
+                     fs
+                   (list fs)))
+  "If non-nil, a list of functions called from c-before-change-hook.
+Typically these will record enough state to allow
 `c-before-font-lock-function' to extend the region to fontify,
 and may do such things as removing text-properties which must be
 recalculated.
 
-It takes 2 parameters, the BEG and END supplied to every
+These functions will be run in the order given.  Each of them
+takes 2 parameters, the BEG and END supplied to every
 before-change function; on entry, the buffer will have been
 widened and match-data will have been saved; point is undefined
 on both entry and exit; the return value is ignored.
 
-When the mode is initialized, this function is called with
-parameters \(point-min) and \(point-max)."
-  t nil
-  (c c++ objc) 'c-extend-region-for-CPP
-  awk 'c-awk-record-region-clear-NL)
-(c-lang-defvar c-get-state-before-change-function
-              (c-lang-const c-get-state-before-change-function))
-  
+The functions are called even when font locking isn't enabled.
+
+When the mode is initialized, the functions are called with
+parameters \(point-min) and \(point-max).")
+
 (c-lang-defconst c-before-font-lock-function
   "If non-nil, a function called just before font locking.
 Typically it will extend the region about to be fontified \(see
@@ -461,7 +490,7 @@ The function is called even when font locking is disabled.
 When the mode is initialized, this function is called with
 parameters \(point-min), \(point-max) and <buffer size>."
   t nil
-  (c c++ objc) 'c-extend-and-neutralize-syntax-in-CPP
+  (c c++ objc) 'c-neutralize-syntax-in-and-mark-CPP
   awk 'c-awk-extend-and-syntax-tablify-region)
 (c-lang-defvar c-before-font-lock-function
               (c-lang-const c-before-font-lock-function))
@@ -471,9 +500,10 @@ parameters \(point-min), \(point-max) and <buffer size>."
 
 (c-lang-defconst c-symbol-start
   "Regexp that matches the start of a symbol, i.e. any identifier or
-keyword.  It's unspecified how far it matches.  Does not contain a \\|
+keyword.  It's unspecified how far it matches. Does not contain a \\|
 operator at the top level."
   t    (concat "[" c-alpha "_]")
+  java (concat "[" c-alpha "_@]")
   objc (concat "[" c-alpha "@]")
   pike (concat "[" c-alpha "_`]"))
 (c-lang-defvar c-symbol-start (c-lang-const c-symbol-start))
@@ -828,7 +858,7 @@ since CC Mode treats every identifier as an expression."
 
       ;; Primary.
       ,@(c-lang-const c-identifier-ops)
-      ,@(cond ((c-major-mode-is 'c++-mode)
+      ,@(cond ((or (c-major-mode-is 'c++-mode) (c-major-mode-is 'java-mode))
               `((postfix-if-paren "<" ">"))) ; Templates.
              ((c-major-mode-is 'pike-mode)
               `((prefix "global" "predef")))
@@ -1087,6 +1117,7 @@ operators."
                    t
                    "\\`<."
                    (lambda (op) (substring op 1)))))
+
 (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp))
 
 (c-lang-defconst c->-op-cont-regexp
@@ -1096,7 +1127,13 @@ operators."
       (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
                    t
                    "\\`>."
-                   (lambda (op) (substring op 1)))))
+                   (lambda (op) (substring op 1))))
+  java (c-make-keywords-re nil
+        (c-filter-ops (c-lang-const c-all-op-syntax-tokens)
+                      t
+                      "\\`>[^>]\\|\\`>>[^>]"
+                      (lambda (op) (substring op 1)))))
+
 (c-lang-defvar c->-op-cont-regexp (c-lang-const c->-op-cont-regexp))
 
 (c-lang-defconst c-stmt-delim-chars
@@ -1526,6 +1563,17 @@ be a subset of `c-primitive-type-kwds'."
            ;; In CORBA PSDL:
            "strong"))
 
+(c-lang-defconst c-typedef-kwds
+  "Prefix keyword\(s\) like \"typedef\" which make a type declaration out
+of a variable declaration."
+  t        '("typedef")
+  (awk idl java) nil)
+
+(c-lang-defconst c-typedef-key
+  ;; Adorned regexp matching `c-typedef-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-typedef-kwds)))
+(c-lang-defvar c-typedef-key (c-lang-const c-typedef-key))
+
 (c-lang-defconst c-type-prefix-kwds
   "Keywords where the following name - if any - is a type name, and
 where the keyword together with the symbol works as a type in
@@ -1597,7 +1645,7 @@ following identifier as a type; the keyword must also be present on
   c++  '("class" "struct" "union")
   objc '("struct" "union"
         "@interface" "@implementation" "@protocol")
-  java '("class" "interface")
+  java '("class" "@interface" "interface")
   idl  '("component" "eventtype" "exception" "home" "interface" "struct"
         "union" "valuetype"
         ;; In CORBA PSDL:
@@ -1620,7 +1668,7 @@ If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
 `c-<>-type-kwds', or `c-<>-arglist-kwds' then the associated clauses
 will be handled."
   t    '("enum")
-  (java awk) nil)
+  (awk) nil)
 
 (c-lang-defconst c-brace-list-key
   ;; Regexp matching the start of declarations where the following
@@ -1692,6 +1740,10 @@ will be handled."
   ;; types in IDL since they only can occur in "raises" specs.
   idl  (delete "exception" (append (c-lang-const c-typedef-decl-kwds) nil)))
 
+(c-lang-defconst c-typedef-decl-key
+  t  (c-make-keywords-re t (c-lang-const c-typedef-decl-kwds)))
+(c-lang-defvar c-typedef-decl-key (c-lang-const c-typedef-decl-key))
+
 (c-lang-defconst c-typeless-decl-kwds
   "Keywords introducing declarations where the \(first) identifier
 \(declarator) follows directly after the keyword, without any type.
@@ -1741,7 +1793,7 @@ will be handled."
         "bindsTo" "delegatesTo" "implements" "proxy" "storedOn")
   ;; Note: "const" is not used in Java, but it's still a reserved keyword.
   java '("abstract" "const" "final" "native" "private" "protected" "public"
-        "static" "strictfp" "synchronized" "transient" "volatile")
+        "static" "strictfp" "synchronized" "transient" "volatile" "@[A-Za-z0-9]+")
   pike '("final" "inline" "local" "nomask" "optional" "private" "protected"
         "public" "static" "variant"))
 
@@ -1827,7 +1879,11 @@ one of `c-type-list-kwds', `c-ref-list-kwds',
 
 (c-lang-defconst c-prefix-spec-kwds-re
   ;; Adorned regexp of `c-prefix-spec-kwds'.
-  t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))
+  t (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds))
+  java (replace-regexp-in-string
+     "\\\\\\[" "["
+     (replace-regexp-in-string "\\\\\\+" "+" (c-make-keywords-re t (c-lang-const c-prefix-spec-kwds)))))
+
 (c-lang-defvar c-prefix-spec-kwds-re (c-lang-const c-prefix-spec-kwds-re))
 
 (c-lang-defconst c-specifier-key
@@ -1919,7 +1975,7 @@ or variable identifier (that's being defined)."
   t    nil
   c++  '("operator")
   objc '("@class")
-  java '("import" "new" "extends" "implements" "throws")
+  java '("import" "new" "extends" "super" "implements" "throws")
   idl  '("manages" "native" "primarykey" "supports"
         ;; In CORBA PSDL:
         "as" "implements" "of" "scope")
@@ -2468,7 +2524,7 @@ more info."
   ;; in all languages except Java for when a cpp macro definition
   ;; begins with a declaration.
   t "\\([\{\}\(\);,]+\\)"
-  java "\\([\{\}\(;,]+\\)"
+  java "\\([\{\}\(;,<]+\\)"
   ;; Match "<" in C++ to get the first argument in a template arglist.
   ;; In that case there's an additional check in `c-find-decl-spots'
   ;; that it got open paren syntax.
@@ -2618,15 +2674,15 @@ Identifier syntax is in effect when this is matched \(see
   c++  (concat "\\("
               "[*\(&]"
               "\\|"
-              (concat "\\("    ; 2
+              (c-lang-const c-type-decl-prefix-key)
+              "\\|"
+              (concat "\\("   ; 3
                       ;; If this matches there's special treatment in
                       ;; `c-font-lock-declarators' and
                       ;; `c-font-lock-declarations' that check for a
                       ;; complete name followed by ":: *".
                       (c-lang-const c-identifier-start)
                       "\\)")
-              "\\|"
-              (c-lang-const c-type-decl-prefix-key)
               "\\)"
               "\\([^=]\\|$\\)")
   pike "\\(\\*\\)\\([^=]\\|$\\)")
@@ -2728,7 +2784,7 @@ It's undefined whether identifier syntax (see `c-identifier-syntax-table')
 is in effect or not."
   t nil
   (c c++ objc pike) "\\(\\.\\.\\.\\)"
-  java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\)"))
+  java (concat "\\(\\[" (c-lang-const c-simple-ws) "*\\]\\|\\.\\.\\.\\)"))
 (c-lang-defvar c-opt-type-suffix-key (c-lang-const c-opt-type-suffix-key))
 
 (c-lang-defvar c-known-type-key
@@ -3079,5 +3135,4 @@ evaluated and should not be quoted."
 \f
 (cc-provide 'cc-langs)
 
-;; arch-tag: 1ab57482-cfc2-4c5b-b628-3539c3098822
 ;;; cc-langs.el ends here