1 ;;; george-mode.el --- George mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2019 Amin Bandali
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: languages, george
7 ;; URL: https://git.sr.ht/~bandali/george-mode
10 ;; This file is not part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
27 ;; This is an Emacs major mode for editing George files.
31 (defvar george-mode-map
32 (let ((map (make-sparse-keymap)))
34 "Keymap for `george-mode'.")
36 (defvar george-mode-directives
37 (let ((methods (regexp-opt
38 '("NONE" "PROP" "PRED" "TP" "ND" "ST" "Z" "PC")
40 (format "#\\(\\(u\\|a\\|q\\).*\\|check\\s-*%s\\)" methods
))
41 "Regexp matching George's directives.")
43 (defvar george-mode-symbols
44 '(";" ":" "," "." "!" "="
58 "<->" "-->" ">-->" "-->>" ">-->>"
59 "-|->" ">-|->" "-|->>" ">-|->>"))
61 (defvar george-mode-keywords
63 ;; "false" "true" ; will be constants
71 "comm" "assoc" "contr" "lem"
72 "impl" "contrapos" "simp1" "simp2"
73 "distr" "dm" "neg" "equiv"
76 "forall_over_and" "exists_over_or" "swap_vars" "move_exists"
77 "move_forall" ;; "dm" ; (same name as for prop logic)
83 ;; "lem" ; same name as for TP
86 "not_not_i" "not_not_e"
91 ;; "true" ; will be a constant
97 "for" "every" "forall_i"
104 "and_nb" "not_and_br"
106 "imp_br" "not_imp_br"
108 "iff_br" "not_iff_br"
109 "forall_nb" "not_forall_nb"
110 "exists_nb" "not_exists_nb"
135 "while" "for" "until" "do"
138 (defvar george-mode-constants
142 (defconst george-mode-syntax-table
143 (let ((st (make-syntax-table)))
144 ;; % is a comment starter
145 (modify-syntax-entry ?%
"<" st
)
146 ;; \n is a comment ender
147 (modify-syntax-entry ?
\n ">" st
)
149 ;; return our modified syntax table
152 (defvar george-mode-font-lock-defaults
153 `((("\"\\.\\*\\?" . font-lock-string-face
)
154 (,george-mode-directives . font-lock-builtin-face
)
155 (,(regexp-opt george-mode-symbols
'symbols
) . font-lock-keyword-face
)
156 (,(regexp-opt george-mode-keywords
'words
) . font-lock-keyword-face
)
157 (,(regexp-opt george-mode-constants
'words
) . font-lock-constant-face
))))
160 (define-derived-mode george-mode prog-mode
"George"
161 "Major mode for editing George files."
162 :syntax-table george-mode-syntax-table
164 (setq-local font-lock-defaults george-mode-font-lock-defaults
)
165 (setq-local comment-start
"%")
166 (setq-local comment-end
"")
170 (add-to-list 'auto-mode-alist
'("\\.grg\\'" . george-mode
))
172 (provide 'george-mode
)
173 ;;; george-mode.el ends here