[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / utils / emacs / tablegen-mode.el
blob572823fa56e132fb02e5a3701145817a4865d526
1 ;;; tablegen-mode.el --- Major mode for TableGen description files (part of LLVM project)
3 ;; Maintainer: The LLVM team, http://llvm.org/
5 ;;; Commentary:
6 ;; A major mode for TableGen description files in LLVM.
8 (require 'comint)
9 (require 'custom)
10 (require 'ansi-color)
12 ;; Create mode-specific tables.
13 ;;; Code:
15 (defvar td-decorators-face 'td-decorators-face
16 "Face method decorators.")
17 (make-face 'td-decorators-face)
19 (defvar tablegen-font-lock-keywords
20 (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in"
21 "let" "multiclass" "foreach" "if" "then" "else"
22 "defvar" "defset")
23 'words))
24 (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string")
25 'words))
27 (list
28 ;; Comments
29 ;; '("\/\/" . font-lock-comment-face)
30 ;; Strings
31 '("\"[^\"]+\"" . font-lock-string-face)
32 ;; Hex constants
33 '("\\<0x[0-9A-Fa-f]+\\>" . font-lock-preprocessor-face)
34 ;; Binary constants
35 '("\\<0b[01]+\\>" . font-lock-preprocessor-face)
36 ;; Integer literals
37 '("\\<[-]?[0-9]+\\>" . font-lock-preprocessor-face)
38 ;; Floating point constants
39 '("\\<[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\>" . font-lock-preprocessor-face)
41 '("^[ \t]*\\(@.+\\)" 1 'td-decorators-face)
42 ;; Keywords
44 ;; Type keywords
45 type-kw
47 "Additional expressions to highlight in TableGen mode.")
48 (put 'tablegen-mode 'font-lock-defaults '(tablegen-font-lock-keywords))
50 ;; ---------------------- Syntax table ---------------------------
52 (defvar tablegen-mode-syntax-table nil
53 "Syntax table used in `tablegen-mode' buffers.")
54 (when (not tablegen-mode-syntax-table)
55 (setq tablegen-mode-syntax-table (make-syntax-table))
56 ;; whitespace (` ')
57 (modify-syntax-entry ?\ " " tablegen-mode-syntax-table)
58 (modify-syntax-entry ?\t " " tablegen-mode-syntax-table)
59 (modify-syntax-entry ?\r " " tablegen-mode-syntax-table)
60 (modify-syntax-entry ?\n " " tablegen-mode-syntax-table)
61 (modify-syntax-entry ?\f " " tablegen-mode-syntax-table)
62 ;; word constituents (`w')
63 (modify-syntax-entry ?\% "w" tablegen-mode-syntax-table)
64 (modify-syntax-entry ?\_ "w" tablegen-mode-syntax-table)
65 ;; comments
66 (modify-syntax-entry ?/ ". 124b" tablegen-mode-syntax-table)
67 (modify-syntax-entry ?* ". 23" tablegen-mode-syntax-table)
68 (modify-syntax-entry ?\n "> b" tablegen-mode-syntax-table)
69 ;; open paren (`(')
70 (modify-syntax-entry ?\( "(" tablegen-mode-syntax-table)
71 (modify-syntax-entry ?\[ "(" tablegen-mode-syntax-table)
72 (modify-syntax-entry ?\{ "(" tablegen-mode-syntax-table)
73 (modify-syntax-entry ?\< "(" tablegen-mode-syntax-table)
74 ;; close paren (`)')
75 (modify-syntax-entry ?\) ")" tablegen-mode-syntax-table)
76 (modify-syntax-entry ?\] ")" tablegen-mode-syntax-table)
77 (modify-syntax-entry ?\} ")" tablegen-mode-syntax-table)
78 (modify-syntax-entry ?\> ")" tablegen-mode-syntax-table)
79 ;; string quote ('"')
80 (modify-syntax-entry ?\" "\"" tablegen-mode-syntax-table)
83 ;; --------------------- Abbrev table -----------------------------
85 (defvar tablegen-mode-abbrev-table nil
86 "Abbrev table used while in TableGen mode.")
87 (define-abbrev-table 'tablegen-mode-abbrev-table ())
89 (defvar tablegen-mode-hook nil)
90 (defvar tablegen-mode-map nil) ; Create a mode-specific keymap.
92 (if (not tablegen-mode-map)
93 () ; Do not change the keymap if it is already set up.
94 (setq tablegen-mode-map (make-sparse-keymap))
95 (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
96 (define-key tablegen-mode-map "\es" 'center-line)
97 (define-key tablegen-mode-map "\eS" 'center-paragraph))
99 ;;;###autoload
100 (defun tablegen-mode ()
101 "Major mode for editing TableGen description files.
102 \\{tablegen-mode-map}
103 Runs `tablegen-mode-hook' on startup."
104 (interactive)
105 (kill-all-local-variables)
106 (use-local-map tablegen-mode-map) ; Provides the local keymap.
107 (make-local-variable 'font-lock-defaults)
108 (setq major-mode 'tablegen-mode ; This is how describe-mode
109 ; finds the doc string to print.
110 mode-name "TableGen" ; This name goes into the modeline.
111 local-abbrev-table tablegen-mode-abbrev-table
112 font-lock-defaults `(tablegen-font-lock-keywords)
113 require-final-newline t
116 (set-syntax-table tablegen-mode-syntax-table)
117 (make-local-variable 'comment-start)
118 (setq comment-start "//")
119 (setq indent-tabs-mode nil)
120 (run-hooks 'tablegen-mode-hook)) ; Finally, this permits the user to
121 ; customize the mode with a hook.
123 ;; Associate .td files with tablegen-mode
124 ;;;###autoload
125 (add-to-list 'auto-mode-alist (cons (purecopy "\\.td\\'") 'tablegen-mode))
127 (provide 'tablegen-mode)
129 ;;; tablegen-mode.el ends here