llvm.org GIT mirror llvm / d4eeb80
Add better support for keywords. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35386 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 12 years ago
1 changed file(s) with 40 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
0 ;; Maintainer: The LLVM team, http://llvm.org/
11 ;; Description: Major mode for TableGen description files (part of LLVM project)
2 ;; Updated: 2003-08-11
2 ;; Updated: 2007-03-26
3
4 (require 'comint)
5 (require 'custom)
6 (require 'ansi-color)
37
48 ;; Create mode-specific tables.
59 (defvar tablegen-mode-syntax-table nil
610 "Syntax table used while in TableGen mode.")
711
12 (defvar td-decorators-face 'td-decorators-face
13 "Face method decorators.")
14 (make-face 'td-decorators-face)
15
816 (defvar tablegen-font-lock-keywords
9 (list
10 ;; Comments
11 '("\/\/.*" . font-lock-comment-face)
12 ;; Strings
13 '("\"[^\"]+\"" . font-lock-string-face)
14 ;; Hex constants
15 '("0x[0-9A-Fa-f]+" . font-lock-preprocessor-face)
16 ;; Binary constants
17 '("0b[01]+" . font-lock-preprocessor-face)
18 ;; Integer literals
19 '("[-]?[0-9]+" . font-lock-preprocessor-face)
20 ;; Floating point constants
21 '("[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?" . font-lock-preprocessor-face)
22 ;; Keywords
23 '("include\\|def\\|let\\|in\\|code\\|dag\\|field" . font-lock-keyword-face)
24 ;; Types
25 '("class\\|int\\|string\\|list\\|bits?" . font-lock-type-face)
26 )
27 "Syntax highlighting for TableGen"
28 )
17 (let ((kw (mapconcat 'identity
18 '("class" "def" "defm" "field" "in" "include"
19 "let" "multiclass")
20 "\\|"))
21 (type-kw (mapconcat 'identity
22 '("bit" "bits" "code" "dag" "int" "list" "string")
23 "\\|"))
24 )
25 (list
26 ;; Comments
27 '("\/\/" . font-lock-comment-face)
28 ;; Strings
29 '("\"[^\"]+\"" . font-lock-string-face)
30 ;; Hex constants
31 '("0x[0-9A-Fa-f]+" . font-lock-preprocessor-face)
32 ;; Binary constants
33 '("0b[01]+" . font-lock-preprocessor-face)
34 ;; Integer literals
35 '("[-]?[0-9]+" . font-lock-preprocessor-face)
36 ;; Floating point constants
37 '("[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?" . font-lock-preprocessor-face)
38
39 '("^[ \t]*\\(@.+\\)" 1 'td-decorators-face)
40 ;; Keywords
41 (cons (concat "\\<\\(" kw "\\)\\>[ \n\t(]") 1)
42
43 ;; Type keywords
44 (cons (concat "\\<\\(" type-kw "\\)[ \n\t(]") 1)
45 ))
46 "Additional expressions to highlight in TableGen mode.")
47 (put 'tablegen-mode 'font-lock-defaults '(tablegen-font-lock-keywords))
2948
3049 ;; ---------------------- Syntax table ---------------------------
3150 ;; Shamelessly ripped from jasmin.el