]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-langs.el
(compilation-next-error-function):
[gnu-emacs] / lisp / progmodes / cc-langs.el
index 4048537458fd18adc80097267d8c866ab3e21843..94d58c66061620c3bf287034d3665c7c5fdaf449 100644 (file)
 (cc-require 'cc-defs)
 (cc-require 'cc-vars)
 
+;; This file is not always loaded.  See note above.
+(cc-external-require 'cl)
+
 \f
 ;;; Setup for the `c-lang-defvar' system.
 
   ;; These are used to collect the init forms from the subsequent
   ;; `c-lang-defvar'.  They are used to build the lambda in
   ;; `c-make-init-lang-vars-fun' below.
-  (defconst c-lang-variable-inits (list nil))
-  (defconst c-lang-variable-inits-tail c-lang-variable-inits))
+  (defvar c-lang-variable-inits nil)
+  (defvar c-lang-variable-inits-tail nil)
+  (setq c-lang-variable-inits (list nil)
+       c-lang-variable-inits-tail c-lang-variable-inits))
 
 (defmacro c-lang-defvar (var val &optional doc)
   "Declares the buffer local variable VAR to get the value VAL at mode
@@ -266,7 +271,7 @@ The syntax tables aren't stored directly since they're quite large."
   ;; the constants in this file are evaluated.
   t (funcall (c-lang-const c-make-mode-syntax-table)))
 
-(c-lang-defconst make-c++-template-syntax-table
+(c-lang-defconst c++-make-template-syntax-table
   ;; A variant of `c++-mode-syntax-table' that defines `<' and `>' as
   ;; parenthesis characters.  Used temporarily when template argument
   ;; lists are parsed.  Note that this encourages incorrect parsing of
@@ -280,8 +285,8 @@ The syntax tables aren't stored directly since they're quite large."
           (modify-syntax-entry ?> ")<" table)
           table)))
 (c-lang-defvar c++-template-syntax-table
-  (and (c-lang-const make-c++-template-syntax-table)
-       (funcall (c-lang-const make-c++-template-syntax-table))))
+  (and (c-lang-const c++-make-template-syntax-table)
+       (funcall (c-lang-const c++-make-template-syntax-table))))
 
 (c-lang-defconst c-identifier-syntax-modifications
   "A list that describes the modifications that should be done to the
@@ -372,6 +377,12 @@ identifiers, or nil in languages that don't have such things.  Does
 not contain a \\| operator at the top level."
   t    nil
   c++  "::"
+  ;; Java has "." to concatenate identifiers but it's also used for
+  ;; normal indexing.  There's special code in the Java font lock
+  ;; rules to fontify qualified identifiers based on the standard
+  ;; naming conventions.  We still define "." here to make
+  ;; `c-forward-name' move over as long names as possible which is
+  ;; necessary to e.g. handle throws clauses correctly.
   java "\\."
   idl  "::"
   pike "\\(::\\|\\.\\)")
@@ -542,6 +553,15 @@ submatch surrounds the directive name."
           '("defined"))
   pike '("defined" "efun" "constant"))
 
+(c-lang-defconst c-assignment-operators
+  "List of all assignment operators."
+  t    '("=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|=")
+  java (append (c-lang-const c-assignment-operators)
+              '(">>>="))
+  c++  (append (c-lang-const c-assignment-operators)
+              '("and_eq" "or_eq" "xor_eq"))
+  idl  nil)
+
 (c-lang-defconst c-operators
   "List describing all operators, along with their precedence and
 associativity.  The order in the list corresponds to the precedence of
@@ -684,11 +704,7 @@ since CC Mode treats every identifier as an expression."
       (right-assoc-sequence "?" ":")
 
       ;; Assignment.
-      (right-assoc "=" "*=" "/=" "%=" "+=" "-=" ">>=" "<<=" "&=" "^=" "|="
-                  ,@(when (c-major-mode-is 'java-mode)
-                      '(">>>="))
-                  ,@(when (c-major-mode-is 'c++-mode)
-                      '("and_eq" "or_eq" "xor_eq")))
+      (right-assoc ,@(c-lang-const c-assignment-operators))
 
       ;; Exception.
       ,@(when (c-major-mode-is 'c++-mode)
@@ -786,6 +802,23 @@ operators."
 (c-lang-defvar c-nonsymbol-token-regexp
   (c-lang-const c-nonsymbol-token-regexp))
 
+(c-lang-defconst c-assignment-op-regexp
+  ;; Regexp matching all assignment operators and only them.  The
+  ;; beginning of the first submatch is used to detect the end of the
+  ;; token, along with the end of the whole match.
+  t (if (c-lang-const c-assignment-operators)
+       (concat
+        ;; Need special case for "=" since it's a prefix of "==".
+        "=\\([^=]\\|$\\)"
+        "\\|"
+        (c-make-keywords-re nil
+          (set-difference (c-lang-const c-assignment-operators)
+                          '("=")
+                          :test 'string-equal)))
+      "\\<\\>"))
+(c-lang-defvar c-assignment-op-regexp
+  (c-lang-const c-assignment-op-regexp))
+
 (c-lang-defconst c-<-op-cont-regexp
   ;; Regexp matching the second and subsequent characters of all
   ;; multicharacter tokens that begin with "<".
@@ -880,19 +913,19 @@ operators."
 (c-lang-defvar comment-start-skip (c-lang-const comment-start-skip)
   'dont-doc)
 
-(c-lang-defconst syntactic-ws-start
+(c-lang-defconst c-syntactic-ws-start
   "Regexp matching any sequence that can start syntactic whitespace.
 The only uncertain case is '#' when there are cpp directives."
   t     "[ \n\t\r\v\f#]\\|/[/*]\\|\\\\[\n\r]"
   awk   "[ \n\t\r\v\f#]\\|\\\\[\n\r]")
-(c-lang-defvar c-syntactic-ws-start (c-lang-const syntactic-ws-start)
+(c-lang-defvar c-syntactic-ws-start (c-lang-const c-syntactic-ws-start)
   'dont-doc)
 
-(c-lang-defconst syntactic-ws-end
+(c-lang-defconst c-syntactic-ws-end
   "Regexp matching any single character that might end syntactic whitespace."
   t     "[ \n\t\r\v\f/]"
   awk   "[ \n\t\r\v\f]")
-(c-lang-defvar c-syntactic-ws-end (c-lang-const syntactic-ws-end)
+(c-lang-defvar c-syntactic-ws-end (c-lang-const c-syntactic-ws-end)
   'dont-doc)
 
 (c-lang-defconst c-nonwhite-syntactic-ws
@@ -1153,7 +1186,7 @@ will be handled."
 (c-lang-defvar c-brace-list-key (c-lang-const c-brace-list-key))
 
 (c-lang-defconst c-other-block-decl-kwds
-  "Keywords where the following block (if any) contain another
+  "Keywords where the following block (if any) contains another
 declaration level that should not be considered a class.
 
 If any of these also are on `c-type-list-kwds', `c-ref-list-kwds',
@@ -1338,7 +1371,8 @@ too.
 Note: Use `c-typeless-decl-kwds' for keywords followed by a function
 or variable identifier (that's being defined)."
   t    '("struct" "union" "enum")
-  (c c++ awk) nil
+  (c awk) nil
+  c++  '("operator")
   objc (append '("@class" "@interface" "@implementation" "@protocol")
               (c-lang-const c-type-list-kwds))
   java '("class" "import" "interface" "new" "extends" "implements" "throws")
@@ -1439,7 +1473,7 @@ assumed to be set if this isn't nil."
 
 (c-lang-defconst c-opt-<>-sexp-key
   ;; Adorned regexp matching keywords that can be followed by an angle
-  ;; bracket sexp.
+  ;; bracket sexp.  Always set when `c-recognize-<>-arglists' is.
   t (if (c-lang-const c-recognize-<>-arglists)
        (c-make-keywords-re t (c-lang-const c-<>-sexp-kwds))))
 (c-lang-defvar c-opt-<>-sexp-key (c-lang-const c-opt-<>-sexp-key))
@@ -2302,4 +2336,5 @@ This macro does not do any hidden buffer changes."
 \f
 (cc-provide 'cc-langs)
 
+;;; arch-tag: 1ab57482-cfc2-4c5b-b628-3539c3098822
 ;;; cc-langs.el ends here