Updated configure script so that it does not configure llvm/project
[oota-llvm.git] / utils / emacs / tablegen-mode.el
1 ;; Maintainer:  The LLVM team, http://llvm.cs.uiuc.edu/
2 ;; Description: Major mode for TableGen description files (part of LLVM project)
3 ;; Updated:     2003-08-11
4
5 ;; Create mode-specific tables.
6 (defvar tablegen-mode-syntax-table nil
7   "Syntax table used while in TableGen mode.")
8
9 (defvar tablegen-font-lock-keywords
10   (list
11    ;; Comments
12    '("\/\/.*" . font-lock-comment-face)
13    ;; Strings
14    '("\"[^\"]+\"" . font-lock-string-face)
15    ;; Hex constants
16    '("0x[0-9A-Fa-f]+" . font-lock-preprocessor-face)
17    ;; Binary constants
18    '("0b[01]+" . font-lock-preprocessor-face)
19    ;; Integer literals
20    '("[-]?[0-9]+" . font-lock-preprocessor-face)
21    ;; Floating point constants
22    '("[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?" . font-lock-preprocessor-face)
23    ;; Keywords
24    '("include\\|def\\|let\\|in\\|code\\|dag\\|field" . font-lock-keyword-face)
25    ;; Types
26    '("class\\|int\\|string\\|list\\|bits?" . font-lock-type-face)
27    )
28   "Syntax highlighting for TableGen"
29   )
30
31 ;; ---------------------- Syntax table ---------------------------
32 ;; Shamelessly ripped from jasmin.el
33 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
34
35 (if (not tablegen-mode-syntax-table)
36     (progn
37       (setq tablegen-mode-syntax-table (make-syntax-table))
38       (mapcar (function (lambda (n)
39                           (modify-syntax-entry (aref n 0)
40                                                (aref n 1)
41                                                tablegen-mode-syntax-table)))
42               '(
43                 ;; whitespace (` ')
44                 [?\^m " "]
45                 [?\f  " "]
46                 [?\n  " "]
47                 [?\t  " "]
48                 [?\   " "]
49                 ;; word constituents (`w')
50                 ;;[?<  "w"]
51                 ;;[?>  "w"]
52                 [?\%  "w"]
53                 ;;[?_  "w  "]
54                 ;; comments
55                 [?\;  "< "]
56                 [?\n  "> "]
57                 ;;[?\r  "> "]
58                 ;;[?\^m "> "]
59                 ;; symbol constituents (`_')
60                 ;; punctuation (`.')
61                 ;; open paren (`(')
62                 [?\( "("]
63                 [?\[ "("]
64                 [?\{ "("]
65                 ;; close paren (`)')
66                 [?\) ")"]
67                 [?\] ")"]
68                 [?\} ")"]
69                 ;; string quote ('"')
70                 [?\" "\""]
71                 ))))
72
73 ;; --------------------- Abbrev table -----------------------------
74
75 (defvar tablegen-mode-abbrev-table nil
76   "Abbrev table used while in TableGen mode.")
77 (define-abbrev-table 'tablegen-mode-abbrev-table ())
78
79 (defvar tablegen-mode-hook nil)
80 (defvar tablegen-mode-map nil)   ; Create a mode-specific keymap.
81
82 (if (not tablegen-mode-map)
83     ()  ; Do not change the keymap if it is already set up.
84   (setq tablegen-mode-map (make-sparse-keymap))
85   (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
86   (define-key tablegen-mode-map "\es" 'center-line)
87   (define-key tablegen-mode-map "\eS" 'center-paragraph))
88
89
90 (defun tablegen-mode ()
91   "Major mode for editing TableGen description files.
92   \\{tablegen-mode-map}
93   Runs tablegen-mode-hook on startup."
94   (interactive)
95   (kill-all-local-variables)
96   (use-local-map tablegen-mode-map)         ; Provides the local keymap.
97   (setq major-mode 'tablegen-mode)          
98
99   (make-local-variable  'font-lock-defaults)
100   (setq major-mode 'tablegen-mode           ; This is how describe-mode
101                                             ;   finds the doc string to print.
102         mode-name "TableGen"                      ; This name goes into the modeline.
103         font-lock-defaults `(tablegen-font-lock-keywords))
104
105   (setq local-abbrev-table tablegen-mode-abbrev-table)
106   (set-syntax-table tablegen-mode-syntax-table)
107   (run-hooks 'tablegen-mode-hook))          ; Finally, this permits the user to
108                                             ;   customize the mode with a hook.
109
110 ;; Associate .td files with tablegen-mode
111 (setq auto-mode-alist (append '(("\\.td$" . tablegen-mode)) auto-mode-alist))
112
113 (provide 'tablegen-mode)
114 ;; end of tablegen-mode.el