blob: e64758ef2e97ac1f95c246ff564d0ace04a29d7c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
(provide 'klee-pc-mode)
(require 'font-lock)
(defvar klee-pc-mode-syntax-table nil
"Syntax table used while in ft-bt mode.")
;;; --------------------------------------------------
;;;setup the syntax table
;;; --------------------------------------------------
(unless klee-pc-mode-syntax-table
(setq klee-pc-mode-syntax-table (make-syntax-table))
;;misc
(modify-syntax-entry ?\_ "w" klee-pc-mode-syntax-table)
(modify-syntax-entry ?\. "." klee-pc-mode-syntax-table))
;;;------------------------------------------------------------
;;; local keymap
;;;------------------------------------------------------------
(defvar klee-pc-local-keymap nil)
;;; --------------------------------------------------
;;; set keywords
;;; --------------------------------------------------
(defvar klee-pc-mode-font-lock-keywords
(list
;; Comments
'("#.*" . font-lock-comment-face)
;; Keywords
'("\\bdef\\b\\|\\bvar\\b\\|\\btrue\\b\\|\\barray\\b\\|\\bfalse\\b\\|\\bquery\\b\\|\\bdefine\\b\\|\\bdeclare\\b\\|\\bsymbolic\\b" . font-lock-keyword-face)
;; Functions
'("\\bEq\\b\\|\\bNe\\b\\|\\bOr\\b\\|\\bAdd\\b\\|\\bSub\\b\\|\\bMul\\b\\|\\bAnd\\b\\|\\bShl\\b\\|\\bXor\\b\\|\\bNot\\b\\|\\bNeg\\b\\|\\bUlt\\b\\|\\bUle\\b\\|\\bUgt\\b\\|\\bUge\\b\\|\\bSlt\\b\\|\\bSle\\b\\|\\bSgt\\b\\|\\bSge\\b\\|\\bRead\\b\\|\\bAShr\\b\\|\\bLShr\\b\\|\\bUDiv\\b\\|\\bSDiv\\b\\|\\bURem\\b\\|\\bSRem\\b\\|\\bSExt\\b\\|\\bZExt\\b\\|\\bConcat\\b\\|\\bSelect\\b\\|\\bExtract\\b\\|\\bReadLSB\\b\\|\\bReadMSB\\b" . font-lock-function-name-face)
;; Types
'("w[0-9]+" . font-lock-type-face)
;; Identifiers
'("[_a-zA-Z][a-zA-Z_.0-9]*" . font-lock-variable-name-face)
;; Numbers
'("[+-]?0b[01_]+" . font-lock-preprocessor-face)
'("[+-]?0o[0-7_]+" . font-lock-preprocessor-face)
'("[+-]?0x[a-zA-Z0-9_]+" . font-lock-preprocessor-face)
'("[+-]?[0-9]+" . font-lock-preprocessor-face)
)
"klee-PC mode keywords")
;;; --------------------------------------------------
;;; major mode function
;;; --------------------------------------------------
(defun klee-pc-mode ()
"Switch to the klee-pc major mode"
(interactive)
(kill-all-local-variables)
(setq major-mode 'klee-pc-mode)
(setq mode-name "klee-pc")
;; handle keymap
(use-local-map klee-pc-local-keymap)
;;handle syntax table
(set-syntax-table klee-pc-mode-syntax-table)
;;handle fontlock
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(klee-pc-mode-font-lock-keywords
nil t))
;;handle hook
(run-hooks 'klee-pc-mode-hook))
|