Alan Mackenzie  committed 5f8d839

Add the switch statement to AWK Mode.

cc-awk (awk-font-lock-keywords): Add "switch", "case", "default" to the
keywords regexp.

cc-langs (c-label-kwds): Let AWK take the same expression as the rest.
(c-nonlabel-token-key): Allow string literals for AWK. Refactor for the
other modes.

  • Participants
  • Parent commits 455dda0

Comments (0)

Files changed (2)

      ;; Keywords.
      (concat "\\<"
-	      '("BEGIN" "END" "break" "continue" "delete" "do" "else"
-		"exit" "for" "getline" "if" "in" "next" "nextfile"
-		"return" "while")
+	      '("BEGIN" "END" "break" "case" "continue" "default" "delete"
+		"do" "else" "exit" "for" "getline" "if" "in" "next"
+		"nextfile" "return" "switch" "while")
 	      t) "\\>")
      ;; Builtins.
 (c-lang-defconst c-label-kwds
   "Keywords introducing colon terminated labels in blocks."
-  t '("case" "default")
-  awk nil)
+  t '("case" "default"))
 (c-lang-defconst c-label-kwds-regexp
   ;; Adorned regexp matching any keyword that introduces a label.
 tested at the beginning of every sexp in a suspected label,
 i.e. before \":\".  Only used if `c-recognize-colon-labels' is set."
   t (concat
-     ;; Don't allow string literals.  Character constants are OK.
-     "\"\\|"
      ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
      (c-make-keywords-re t
        (set-difference (c-lang-const c-keywords)
 		       (append (c-lang-const c-label-kwds)
 			       (c-lang-const c-protection-kwds))
 		       :test 'string-equal)))
+  ;; Don't allow string literals, except in AWK.  Character constants are OK.
+  (c objc java pike idl) (concat "\"\\|"
+				 (c-lang-const c-nonlabel-token-key))
   ;; Also check for open parens in C++, to catch member init lists in
   ;; constructors.  We normally allow it so that macros with arguments
   ;; work in labels.
-  c++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key)))
+  c++ (concat "\\s\(\\|\"\\|" (c-lang-const c-nonlabel-token-key)))
 (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
 (c-lang-defconst c-nonlabel-token-2-key