llvm.org GIT mirror llvm / 8387076
Modified to support comments better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45192 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 11 years ago
1 changed file(s) with 43 addition(s) and 54 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: 2007-03-26
2 ;; Updated: 2007-12-18
33
44 (require 'comint)
55 (require 'custom)
66 (require 'ansi-color)
77
88 ;; Create mode-specific tables.
9 (defvar tablegen-mode-syntax-table nil
10 "Syntax table used while in TableGen mode.")
11
129 (defvar td-decorators-face 'td-decorators-face
1310 "Face method decorators.")
1411 (make-face 'td-decorators-face)
2421 )
2522 (list
2623 ;; Comments
27 '("\/\/" . font-lock-comment-face)
24 ;; '("\/\/" . font-lock-comment-face)
2825 ;; Strings
2926 '("\"[^\"]+\"" . font-lock-string-face)
3027 ;; Hex constants
5047 ;; Shamelessly ripped from jasmin.el
5148 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el
5249
53 (if (not tablegen-mode-syntax-table)
54 (progn
55 (setq tablegen-mode-syntax-table (make-syntax-table))
56 (mapcar (function
57 (lambda (n)
58 (modify-syntax-entry (aref n 0)
59 (aref n 1)
60 tablegen-mode-syntax-table)))
61 '(
62 ;; whitespace (` ')
63 [?\^m " "]
64 [?\f " "]
65 [?\n " "]
66 [?\t " "]
67 [?\ " "]
68 ;; word constituents (`w')
69 [?\% "w"]
70 ;;[?_ "w "]
71 ;; comments
72 [?\; "< "]
73 [?\n "> "]
74 ;;[?\r "> "]
75 ;;[?\^m "> "]
76 ;; symbol constituents (`_')
77 ;; punctuation (`.')
78 ;; open paren (`(')
79 [?\( "("]
80 [?\[ "("]
81 [?\{ "("]
82 [?\< "("]
83 ;; close paren (`)')
84 [?\) ")"]
85 [?\] ")"]
86 [?\} ")"]
87 [?\> ")"]
88 ;; string quote ('"')
89 [?\" "\""]
90 ))))
50 (defvar tablegen-mode-syntax-table nil
51 "Syntax table used in `tablegen-mode' buffers.")
52 (when (not tablegen-mode-syntax-table)
53 (setq tablegen-mode-syntax-table (make-syntax-table))
54 ;; whitespace (` ')
55 (modify-syntax-entry ?\ " " tablegen-mode-syntax-table)
56 (modify-syntax-entry ?\t " " tablegen-mode-syntax-table)
57 (modify-syntax-entry ?\r " " tablegen-mode-syntax-table)
58 (modify-syntax-entry ?\n " " tablegen-mode-syntax-table)
59 (modify-syntax-entry ?\f " " tablegen-mode-syntax-table)
60 ;; word constituents (`w')
61 (modify-syntax-entry ?\% "w" tablegen-mode-syntax-table)
62 (modify-syntax-entry ?\_ "w" tablegen-mode-syntax-table)
63 ;; comments
64 (modify-syntax-entry ?/ ". 124b" tablegen-mode-syntax-table)
65 (modify-syntax-entry ?* ". 23" tablegen-mode-syntax-table)
66 (modify-syntax-entry ?\n "> b" tablegen-mode-syntax-table)
67 ;; open paren (`(')
68 (modify-syntax-entry ?\( "(" tablegen-mode-syntax-table)
69 (modify-syntax-entry ?\[ "(" tablegen-mode-syntax-table)
70 (modify-syntax-entry ?\{ "(" tablegen-mode-syntax-table)
71 (modify-syntax-entry ?\< "(" tablegen-mode-syntax-table)
72 ;; close paren (`)')
73 (modify-syntax-entry ?\) ")" tablegen-mode-syntax-table)
74 (modify-syntax-entry ?\] ")" tablegen-mode-syntax-table)
75 (modify-syntax-entry ?\} ")" tablegen-mode-syntax-table)
76 (modify-syntax-entry ?\> ")" tablegen-mode-syntax-table)
77 ;; string quote ('"')
78 (modify-syntax-entry ?\" "\"" tablegen-mode-syntax-table)
79 )
9180
9281 ;; --------------------- Abbrev table -----------------------------
9382
111100 Runs tablegen-mode-hook on startup."
112101 (interactive)
113102 (kill-all-local-variables)
114 (use-local-map tablegen-mode-map) ; Provides the local keymap.
115 (setq major-mode 'tablegen-mode)
103 (use-local-map tablegen-mode-map) ; Provides the local keymap.
104 (make-local-variable 'font-lock-defaults)
105 (setq major-mode 'tablegen-mode ; This is how describe-mode
106 ; finds the doc string to print.
107 mode-name "TableGen" ; This name goes into the modeline.
108 local-abbrev-table tablegen-mode-abbrev-table
109 font-lock-defaults `(tablegen-font-lock-keywords)
110 require-final-newline t
111 )
116112
117 (make-local-variable 'font-lock-defaults)
118 (setq major-mode 'tablegen-mode ; This is how describe-mode
119 ; finds the doc string to print.
120 mode-name "TableGen" ; This name goes into the modeline.
121 font-lock-defaults `(tablegen-font-lock-keywords))
122
123 (setq local-abbrev-table tablegen-mode-abbrev-table)
124113 (set-syntax-table tablegen-mode-syntax-table)
125 (run-hooks 'tablegen-mode-hook)) ; Finally, this permits the user to
126 ; customize the mode with a hook.
114 (run-hooks 'tablegen-mode-hook)) ; Finally, this permits the user to
115 ; customize the mode with a hook.
127116
128117 ;; Associate .td files with tablegen-mode
129118 (setq auto-mode-alist (append '(("\\.td$" . tablegen-mode)) auto-mode-alist))