-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzpl-mode.el
More file actions
86 lines (68 loc) · 2.95 KB
/
Copy pathzpl-mode.el
File metadata and controls
86 lines (68 loc) · 2.95 KB
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
;;; zpl-mode.el --- ZIMPL major mode
;; URL: https://github.com/ax487/zpl-mode.git
;; Version: 20180712
;; Package-Requires: ((emacs "24.3"))
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This package provides a major mode for
;; ZIMPL (Zuse Institute Mathematical Programming Language).
;; It supports basic font-lock highlights.
;;; Code:
(defvar zpl-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?# "<" st)
(modify-syntax-entry ?\n ">" st)
st)
"Syntax table for `zpl-mode'.")
(defvar zpl-keywords '("set" "param" "var"
"defset" "defnumb" "defstrg" "defbool"
"minimize" "maximize"
"subto"
"include"
"and" "or" "xor" "not"
"if" "then" "else" "end"
"forall" "in" "do"
"without" "with"
"binary" "integer" "implicit binary" "real"
"scale" "separate" "checkonly" "indicator"
"read" "as" "skip" "use" "comment"))
(defvar zpl-builtins '(
"union" "cross" "inter" "in" "symdiff" "proj"
"argmin" "argmax"
"print" "check"
"min" "max" "mod" "abs" "sgn" "floor" "ceil" "round"
"sum" "prod" "card" "random" "ord"
"sqrt" "log" "ln" "exp"
"substr" "lenth"
"powerset" "indexset" "subsets"))
;; (regexp-opt zpl-keywords)
;; (regexp-opt zpl-constants)
(defvar zpl-constants '("infinity"))
;; (defvar zpl-font-lock-keywords
;; `(,(regexp-opt zpl-keywords) . font-lock-constant-face)
;; "Keyword highlighting specification for `zpl-mode'.")
(defvar zpl-font-lock-keywords
(list `(,(regexp-opt zpl-keywords 'words) . font-lock-keyword-face)
`(,(regexp-opt zpl-constants 'words) . font-lock-constant-face)
`(,(regexp-opt zpl-builtins 'words) . font-lock-builtin-face))
"Keyword highlighting specification for `zpl-mode'.")
;; (defvar zpl-imenu-generic-expression
;; ...)
;; (defvar zpl-outline-regexp
;; ...)
;;;###autoload
(define-derived-mode zpl-mode fundamental-mode "ZIMPL"
"A major mode for editing ZIMPL files."
:syntax-table zpl-mode-syntax-table
(setq-local comment-start "# ")
(setq-local comment-start-skip "#+\\s-*")
(setq-local font-lock-defaults
'(zpl-font-lock-keywords))
;(setq-local indent-line-function 'zpl-indent-line)
;(setq-local imenu-generic-expression
; zpl-imenu-generic-expression)
;(setq-local outline-regexp zpl-outline-regexp)
)
(add-to-list 'auto-mode-alist '("\\.zpl\\'" . zpl-mode))
(provide 'zpl-mode)
;;; zpl-mode.el ends here