Skip to content

Commit

Permalink
Using regexp-opt for keyword regex declarations makes the word lists …
Browse files Browse the repository at this point in the history
…more

readable and easier to edit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114308 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
mbrukman committed Sep 19, 2010
1 parent 313a94c commit 7e28460
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
17 changes: 11 additions & 6 deletions utils/emacs/llvm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,28 @@
;; Unnamed variable slots
'("%[-]?[0-9]+" . font-lock-variable-name-face)
;; Types
'("\\bvoid\\b\\|\\bi[0-9]+\\b\\|\\float\\b\\|\\bdouble\\b\\|\\btype\\b\\|\\blabel\\b\\|\\bopaque\\b" . font-lock-type-face)
`(,(regexp-opt '("void" "i[0-9]+" "float" "double" "type" "label" "opaque") 'words) . font-lock-type-face)
;; Integer literals
'("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
;; Floating point constants
'("\\b[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\b" . font-lock-preprocessor-face)
;; Hex constants
'("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face)
;; Keywords
'("\\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)
`(,(regexp-opt '("begin" "end" "true" "false" "zeroinitializer" "declare"
"define" "global" "constant" "const" "internal" "linkonce" "linkonce_odr"
"weak" "weak_odr" "appending" "uninitialized" "implementation" "..."
"null" "undef" "to" "except" "not" "target" "endian" "little" "big"
"pointersize" "deplibs" "volatile" "fastcc" "coldcc" "cc") 'words) . font-lock-keyword-face)
;; Arithmetic and Logical Operators
'("\\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)
`(,(regexp-opt '("add" "sub" "mul" "div" "rem" "and" "or" "xor"
"setne" "seteq" "setlt" "setgt" "setle" "setge") 'words) . font-lock-keyword-face)
;; Special instructions
'("\\bphi\\b\\|\\btail\\b\\|\\bcall\\b\\|\\bcast\\b\\|\\bselect\\b\\|\\bto\\b\\|\\bshl\\b\\|\\bshr\\b\\|\\bvaarg\\b\\|\\bvanext\\b" . font-lock-keyword-face)
`(,(regexp-opt '("phi" "tail" "call" "cast" "select" "to" "shl" "shr" "vaarg" "vanext") 'words) . font-lock-keyword-face)
;; Control instructions
'("\\bret\\b\\|\\bbr\\b\\|\\bswitch\\b\\|\\binvoke\\b\\|\\bunwind\\b\\|\\bunreachable\\b" . font-lock-keyword-face)
`(,(regexp-opt '("ret" "br" "switch" "invoke" "unwind" "unreachable") 'words) . font-lock-keyword-face)
;; Memory operators
'("\\bmalloc\\b\\|\\balloca\\b\\|\\bfree\\b\\|\\bload\\b\\|\\bstore\\b\\|\\bgetelementptr\\b" . font-lock-keyword-face)
`(,(regexp-opt '("malloc" "alloca" "free" "load" "store" "getelementptr") 'words) . font-lock-keyword-face)
)
"Syntax highlighting for LLVM"
)
Expand Down
14 changes: 6 additions & 8 deletions utils/emacs/tablegen-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
(make-face 'td-decorators-face)

(defvar tablegen-font-lock-keywords
(let ((kw (mapconcat 'identity
'("class" "defm" "def" "field" "include" "in"
(let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in"
"let" "multiclass")
"\\|"))
(type-kw (mapconcat 'identity
'("bit" "bits" "code" "dag" "int" "list" "string")
"\\|"))
'words))
(type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string")
'words))
)
(list
;; Comments
Expand All @@ -36,10 +34,10 @@

'("^[ \t]*\\(@.+\\)" 1 'td-decorators-face)
;; Keywords
(cons (concat "\\<\\(" kw "\\)\\>[ \n\t(]") 1)
(cons (concat kw "[ \n\t(]") 1)

;; Type keywords
(cons (concat "\\<\\(" type-kw "\\)[ \n\t(]") 1)
(cons (concat type-kw "[ \n\t(]") 1)
))
"Additional expressions to highlight in TableGen mode.")
(put 'tablegen-mode 'font-lock-defaults '(tablegen-font-lock-keywords))
Expand Down

0 comments on commit 7e28460

Please sign in to comment.