-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcasm-mode.el
135 lines (119 loc) · 3.2 KB
/
casm-mode.el
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;
; Copyright (C) 2017-2024 CASM Organization <https://casm-lang.org>
; All rights reserved.
;
; Developed by: Philipp Paulweber et al.
; <https://github.com/casm-lang/casm-lang.plugin.emacs/graphs/contributors>
;
; This file is part of casm-lang.plugin.emacs.
;
; casm-lang.plugin.emacs is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; casm-lang.plugin.emacs is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with casm-lang.plugin.emacs. If not, see <http://www.gnu.org/licenses/>.
;
;; -----------------------------------------------------------------------------
;; CASM syntax highlighting configuration (copy this to your emacs config file)
;; -----------------------------------------------------------------------------
;;
;; (load "<PATH-TO_REPO>/casm-mode.el")
;; (add-to-list 'auto-mode-alist '("\\.casm\\'" . casm-mode))
;;
(setq casm-types
'("Integer"
"Bit"
"Boolean"
"String"
"Floating"
"Rational"
"enum"
;; TODO
)
)
(setq casm-constants
'("undef"
"false"
"true"
"self"
)
)
(setq casm-builtins
'("asBoolean"
"asBit"
"asInteger"
;; TODO
)
)
(setq casm-function-names
'( "CASM"
"init"
"initially"
"defined"
"derived"
"function"
"rule"
)
)
(setq casm-keywords
'( "if"
"then"
"else"
"call"
"forall"
"do"
"in"
"let"
"debug"
"print"
"assert"
"case"
"of"
"default"
"_"
"skip"
"and"
"or"
"xor"
"not"
)
)
(setq casm-regexp-keywords (regexp-opt casm-keywords 'words))
(setq casm-regexp-types (regexp-opt casm-types 'words))
(setq casm-regexp-constants (regexp-opt casm-constants 'words))
(setq casm-regexp-builtins (regexp-opt casm-builtins 'words))
(setq casm-regexp-function-names (regexp-opt casm-function-names 'words))
(setq casm-mode-font-lock
'(
(,casm-regexp-function-names . font-lock-function-name-face)
(,casm-regexp-constants . font-lock-constant-face)
(,casm-regexp-types . font-lock-type-face)
(,casm-regexp-builtins . font-lock-builtin-face)
(,casm-regexp-keywords . font-lock-keyword-face)
)
)
(define-derived-mode casm-mode fundamental-mode
"CASM mode"
"Major mode for editing CASM (Corinthian Abstract State Machine) files."
(setq font-lock-defaults '((casm-mode-font-lock)))
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
)
(setq casm-regexp-keywords nil)
(setq casm-regexp-types nil)
(setq casm-regexp-constants nil)
(setq casm-regexp-builtins nil)
(setq casm-regexp-function-names nil)
(setq casm-keywords nil)
(setq casm-types nil)
(setq casm-constants nil)
(setq casm-builtins nil)
(setq casm-function-names nil)
(provide 'casm-mode)