add some missing quotes in debug output
[llvm/avr.git] / utils / emacs / llvm-mode.el
blob55c56daecd05d0b7086c717cd97f6808d9c50d0a
1 ;; Maintainer: The LLVM team, http://llvm.org/
2 ;; Description: Major mode for the LLVM assembler language.
3 ;; Updated: 2007-09-19
5 ;; Create mode-specific tables.
6 (defvar llvm-mode-syntax-table nil
7 "Syntax table used while in LLVM mode.")
9 (defvar llvm-font-lock-keywords
10 (list
11 ;; Comments
12 '(";.*" . font-lock-comment-face)
13 ;; Variables
14 '("%[-a-zA-Z$\._][-a-zA-Z$\._0-9]*" . font-lock-variable-name-face)
15 ;; Labels
16 '("[-a-zA-Z$\._0-9]+:" . font-lock-variable-name-face)
17 ;; Strings
18 '("\"[^\"]+\"" . font-lock-string-face)
19 ;; Unnamed variable slots
20 '("%[-]?[0-9]+" . font-lock-variable-name-face)
21 ;; Types
22 '("\\bvoid\\b\\|\\bi[0-9]+\\b\\|\\float\\b\\|\\bdouble\\b\\|\\btype\\b\\|\\blabel\\b\\|\\bopaque\\b" . font-lock-type-face)
23 ;; Integer literals
24 '("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
25 ;; Floating point constants
26 '("\\b[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\b" . font-lock-preprocessor-face)
27 ;; Hex constants
28 '("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face)
29 ;; Keywords
30 '("\\bbegin\\b\\|\\bend\\b\\|\\btrue\\b\\|\\bfalse\\b\\|\\bzeroinitializer\\b\\|\\bdeclare\\b\\|\\bdefine\\b\\|\\bglobal\\b\\|\\bconstant\\b\\|\\bconst\\b\\|\\binternal\\b\\|\\blinkonce\\b\\|\\blinkonce_odr\\b\\|\\bweak\\b\\|\\bweak_odr\\b\\|\\bappending\\b\\|\\buninitialized\\b\\|\\bimplementation\\b\\|\\b\\.\\.\\.\\b\\|\\bnull\\b\\|\\bundef\\b\\|\\bto\\b\\|\\bexcept\\b\\|\\bnot\\b\\|\\btarget\\b\\|\\bendian\\b\\|\\blittle\\b\\|\\bbig\\b\\|\\bpointersize\\b\\|\\bdeplibs\\b\\|\\bvolatile\\b\\|\\bfastcc\\b\\|\\bcoldcc\\b\\|\\bcc\\b" . font-lock-keyword-face)
31 ;; Arithmetic and Logical Operators
32 '("\\badd\\b\\|\\bsub\\b\\|\\bmul\\b\\|\\bdiv\\b\\|\\brem\\b\\|\\band\\b\\|\\bor\\b\\|\\bxor\\b\\|\\bset\\(ne\\b\\|\\beq\\b\\|\\blt\\b\\|\\bgt\\b\\|\\ble\\b\\|\\bge\\b\\)" . font-lock-keyword-face)
33 ;; Special instructions
34 '("\\bphi\\b\\|\\btail\\b\\|\\bcall\\b\\|\\bcast\\b\\|\\bselect\\b\\|\\bto\\b\\|\\bshl\\b\\|\\bshr\\b\\|\\bvaarg\\b\\|\\bvanext\\b" . font-lock-keyword-face)
35 ;; Control instructions
36 '("\\bret\\b\\|\\bbr\\b\\|\\bswitch\\b\\|\\binvoke\\b\\|\\bunwind\\b\\|\\bunreachable\\b" . font-lock-keyword-face)
37 ;; Memory operators
38 '("\\bmalloc\\b\\|\\balloca\\b\\|\\bfree\\b\\|\\bload\\b\\|\\bstore\\b\\|\\bgetelementptr\\b" . font-lock-keyword-face)
40 "Syntax highlighting for LLVM"
43 ;; ---------------------- Syntax table ---------------------------
44 ;; Shamelessly ripped from jasmin.el
45 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
47 (if (not llvm-mode-syntax-table)
48 (progn
49 (setq llvm-mode-syntax-table (make-syntax-table))
50 (mapcar (function (lambda (n)
51 (modify-syntax-entry (aref n 0)
52 (aref n 1)
53 llvm-mode-syntax-table)))
55 ;; whitespace (` ')
56 [?\^m " "]
57 [?\f " "]
58 [?\n " "]
59 [?\t " "]
60 [?\ " "]
61 ;; word constituents (`w')
62 ;;[?< "w"]
63 ;;[?> "w"]
64 [?\% "w"]
65 ;;[?_ "w "]
66 ;; comments
67 [?\; "< "]
68 [?\n "> "]
69 ;;[?\r "> "]
70 ;;[?\^m "> "]
71 ;; symbol constituents (`_')
72 ;; punctuation (`.')
73 ;; open paren (`(')
74 [?\( "("]
75 [?\[ "("]
76 [?\{ "("]
77 ;; close paren (`)')
78 [?\) ")"]
79 [?\] ")"]
80 [?\} ")"]
81 ;; string quote ('"')
82 [?\" "\""]
83 ))))
85 ;; --------------------- Abbrev table -----------------------------
87 (defvar llvm-mode-abbrev-table nil
88 "Abbrev table used while in LLVM mode.")
89 (define-abbrev-table 'llvm-mode-abbrev-table ())
91 (defvar llvm-mode-hook nil)
92 (defvar llvm-mode-map nil) ; Create a mode-specific keymap.
94 (if (not llvm-mode-map)
95 () ; Do not change the keymap if it is already set up.
96 (setq llvm-mode-map (make-sparse-keymap))
97 (define-key llvm-mode-map "\t" 'tab-to-tab-stop)
98 (define-key llvm-mode-map "\es" 'center-line)
99 (define-key llvm-mode-map "\eS" 'center-paragraph))
102 (defun llvm-mode ()
103 "Major mode for editing LLVM source files.
104 \\{llvm-mode-map}
105 Runs llvm-mode-hook on startup."
106 (interactive)
107 (kill-all-local-variables)
108 (use-local-map llvm-mode-map) ; Provides the local keymap.
109 (setq major-mode 'llvm-mode)
111 (make-local-variable 'font-lock-defaults)
112 (setq major-mode 'llvm-mode ; This is how describe-mode
113 ; finds the doc string to print.
114 mode-name "LLVM" ; This name goes into the modeline.
115 font-lock-defaults `(llvm-font-lock-keywords))
117 (setq local-abbrev-table llvm-mode-abbrev-table)
118 (set-syntax-table llvm-mode-syntax-table)
119 (setq comment-start ";")
120 (run-hooks 'llvm-mode-hook)) ; Finally, this permits the user to
121 ; customize the mode with a hook.
123 ;; Associate .ll files with llvm-mode
124 (setq auto-mode-alist
125 (append '(("\\.ll$" . llvm-mode) ("\\.llx$" . llvm-mode)) auto-mode-alist))
127 (provide 'llvm-mode)
128 ;; end of llvm-mode.el