llvm.org GIT mirror llvm / bdb4119
* Added (X)Emacs mode for TableGen description files * Added README that describes how to use the mode files * Associated files with .llx extension with llvm-mode git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7738 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 17 years ago
3 changed file(s) with 142 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 -*- llvm/utils/emacs/README -*-
1
2 These are syntax highlighting files for the Emacs and XEmacs editors. Included
3 are:
4
5 * llvm-mode.el
6
7 Syntax highlighting mode for LLVM assembly files. To use, add this code to
8 your ~/.emacs :
9
10 (setq load-path
11 (cons (expand-file-name "path-to-llvm/utils/emacs") load-path))
12 (require 'llvm-mode)
13
14 * tablegen-mode.el
15
16 Syntax highlighting mode for TableGen description files. To use, add this code
17 to your ~/.emacs:
18
19 (setq load-path
20 (cons (expand-file-name "path-to-llvm/utils/emacs") load-path))
21 (require 'tablegen-mode)
22
23
24 Note: If you notice missing or incorrect syntax highlighting, please contact
25 ; if you wish to provide a patch to improve the
26 functionality, it will be most appreciated. Thank you.
120120
121121 ;; Associate .ll files with llvm-mode
122122 (setq auto-mode-alist
123 (append '(("\\.ll$" . llvm-mode)) auto-mode-alist))
123 (append '(("\\.ll$" . llvm-mode) ("\\.llx$" . llvm-mode)) auto-mode-alist))
124124
125125 (provide 'llvm-mode)
126126 ;; end of llvm-mode.el
0 ;; Maintainer: The LLVM team, http://llvm.cs.uiuc.edu/
1 ;; Description: Major mode for TableGen description files (part of LLVM project)
2 ;; Updated: 2003-08-11
3
4 ;; Create mode-specific tables.
5 (defvar tablegen-mode-syntax-table nil
6 "Syntax table used while in TableGen mode.")
7
8 (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 )
29
30 ;; ---------------------- Syntax table ---------------------------
31 ;; Shamelessly ripped from jasmin.el
32 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
33
34 (if (not tablegen-mode-syntax-table)
35 (progn
36 (setq tablegen-mode-syntax-table (make-syntax-table))
37 (mapcar (function (lambda (n)
38 (modify-syntax-entry (aref n 0)
39 (aref n 1)
40 tablegen-mode-syntax-table)))
41 '(
42 ;; whitespace (` ')
43 [?\^m " "]
44 [?\f " "]
45 [?\n " "]
46 [?\t " "]
47 [?\ " "]
48 ;; word constituents (`w')
49 ;;[?< "w"]
50 ;;[?> "w"]
51 [?\% "w"]
52 ;;[?_ "w "]
53 ;; comments
54 [?\; "< "]
55 [?\n "> "]
56 ;;[?\r "> "]
57 ;;[?\^m "> "]
58 ;; symbol constituents (`_')
59 ;; punctuation (`.')
60 ;; open paren (`(')
61 [?\( "("]
62 [?\[ "("]
63 [?\{ "("]
64 ;; close paren (`)')
65 [?\) ")"]
66 [?\] ")"]
67 [?\} ")"]
68 ;; string quote ('"')
69 [?\" "\""]
70 ))))
71
72 ;; --------------------- Abbrev table -----------------------------
73
74 (defvar tablegen-mode-abbrev-table nil
75 "Abbrev table used while in TableGen mode.")
76 (define-abbrev-table 'tablegen-mode-abbrev-table ())
77
78 (defvar tablegen-mode-hook nil)
79 (defvar tablegen-mode-map nil) ; Create a mode-specific keymap.
80
81 (if (not tablegen-mode-map)
82 () ; Do not change the keymap if it is already set up.
83 (setq tablegen-mode-map (make-sparse-keymap))
84 (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
85 (define-key tablegen-mode-map "\es" 'center-line)
86 (define-key tablegen-mode-map "\eS" 'center-paragraph))
87
88
89 (defun tablegen-mode ()
90 "Major mode for editing TableGen description files.
91 \\{tablegen-mode-map}
92 Runs tablegen-mode-hook on startup."
93 (interactive)
94 (kill-all-local-variables)
95 (use-local-map tablegen-mode-map) ; Provides the local keymap.
96 (setq major-mode 'tablegen-mode)
97
98 (make-local-variable 'font-lock-defaults)
99 (setq major-mode 'tablegen-mode ; This is how describe-mode
100 ; finds the doc string to print.
101 mode-name "TableGen" ; This name goes into the modeline.
102 font-lock-defaults `(tablegen-font-lock-keywords))
103
104 (setq local-abbrev-table tablegen-mode-abbrev-table)
105 (set-syntax-table tablegen-mode-syntax-table)
106 (run-hooks 'tablegen-mode-hook)) ; Finally, this permits the user to
107 ; customize the mode with a hook.
108
109 ;; Associate .td files with tablegen-mode
110 (setq auto-mode-alist (append '(("\\.td$" . tablegen-mode)) auto-mode-alist))
111
112 (provide 'tablegen-mode)
113 ;; end of tablegen-mode.el