Commit 898169a2 authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

Add the switch statement to AWK Mode.

parent 13d49cbb
2011-12-13 Alan Mackenzie <acm@muc.de> 2011-12-13 Alan Mackenzie <acm@muc.de>
Add the switch statement to AWK Mode.
* progmodes/cc-awk (awk-font-lock-keywords): Add "switch", "case",
"default" to the keywords regexp.
* progmodes/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.
Large brace-block initialisation makes CC Mode slow: Fix. Large brace-block initialisation makes CC Mode slow: Fix.
Tidy up and accelerate c-in-literal, etc. by using the Tidy up and accelerate c-in-literal, etc. by using the
c-parse-state c-parse-state
......
...@@ -894,9 +894,9 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ ...@@ -894,9 +894,9 @@ std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\
;; Keywords. ;; Keywords.
(concat "\\<" (concat "\\<"
(regexp-opt (regexp-opt
'("BEGIN" "END" "break" "continue" "delete" "do" "else" '("BEGIN" "END" "break" "case" "continue" "default" "delete"
"exit" "for" "getline" "if" "in" "next" "nextfile" "do" "else" "exit" "for" "getline" "if" "in" "next"
"return" "while") "nextfile" "return" "switch" "while")
t) "\\>") t) "\\>")
;; Builtins. ;; Builtins.
......
...@@ -2242,8 +2242,7 @@ This construct is \"<keyword> <expression> :\"." ...@@ -2242,8 +2242,7 @@ This construct is \"<keyword> <expression> :\"."
(c-lang-defconst c-label-kwds (c-lang-defconst c-label-kwds
"Keywords introducing colon terminated labels in blocks." "Keywords introducing colon terminated labels in blocks."
t '("case" "default") t '("case" "default"))
awk nil)
(c-lang-defconst c-label-kwds-regexp (c-lang-defconst c-label-kwds-regexp
;; Adorned regexp matching any keyword that introduces a label. ;; Adorned regexp matching any keyword that introduces a label.
...@@ -2998,18 +2997,19 @@ neither in a statement nor in a declaration context. The regexp is ...@@ -2998,18 +2997,19 @@ neither in a statement nor in a declaration context. The regexp is
tested at the beginning of every sexp in a suspected label, tested at the beginning of every sexp in a suspected label,
i.e. before \":\". Only used if `c-recognize-colon-labels' is set." i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
t (concat t (concat
;; Don't allow string literals.
"\"\\|"
;; All keywords except `c-label-kwds' and `c-protection-kwds'. ;; All keywords except `c-label-kwds' and `c-protection-kwds'.
(c-make-keywords-re t (c-make-keywords-re t
(set-difference (c-lang-const c-keywords) (set-difference (c-lang-const c-keywords)
(append (c-lang-const c-label-kwds) (append (c-lang-const c-label-kwds)
(c-lang-const c-protection-kwds)) (c-lang-const c-protection-kwds))
:test 'string-equal))) :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 ;; Also check for open parens in C++, to catch member init lists in
;; constructors. We normally allow it so that macros with arguments ;; constructors. We normally allow it so that macros with arguments
;; work in labels. ;; 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-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
(c-lang-defconst c-nonlabel-token-2-key (c-lang-defconst c-nonlabel-token-2-key
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment