diff options
Diffstat (limited to 'lib/milan-vm-mode.el')
| -rw-r--r-- | lib/milan-vm-mode.el | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/milan-vm-mode.el b/lib/milan-vm-mode.el new file mode 100644 index 0000000..c27c1a2 --- /dev/null +++ b/lib/milan-vm-mode.el | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | ;;; milan-mode-vm.el --- simple major mode for MiLan VM -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2025 Michalec Martin | ||
| 4 | |||
| 5 | ;; Author: Michalec Martin <martin@michalec.dev> | ||
| 6 | ;; Keywords: convenience, faces, extensions | ||
| 7 | |||
| 8 | ;; This program is free software; you can redistribute it and/or modify | ||
| 9 | ;; it under the terms of the GNU General Public License as published by | ||
| 10 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 11 | ;; (at your option) any later version. | ||
| 12 | |||
| 13 | ;; This program is distributed in the hope that it will be useful, | ||
| 14 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | ;; GNU General Public License for more details. | ||
| 17 | |||
| 18 | ;; You should have received a copy of the GNU General Public License | ||
| 19 | ;; along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | ;;; Commentary: | ||
| 22 | |||
| 23 | ;; reference: http://xahlee.info/emacs/emacs/elisp_syntax_coloring.html | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (defvar-local milan-vm-mode-fontlock | ||
| 28 | '((";[^\n]*" . 'font-lock-comment-face) | ||
| 29 | ((string-join '("NOP" "LOADB" "STOREB" "STOP" "LOAD" "STORE" "BLOAD" | ||
| 30 | "BSTORE" "PUSH" "POP" "DUP" "INVERT" "ADD" "SUB" "MULT" | ||
| 31 | "DIV" "COMPARE" "JUMP" "JUMP_YES" "JUMP_NO" "INPUT" | ||
| 32 | "PRINT" "CALL" "RETURN" "SHIFT") "\\|") | ||
| 33 | . 'font-lock-keyword-face))) | ||
| 34 | |||
| 35 | (define-derived-mode milan-vm-mode prog-mode "MiLan VM" | ||
| 36 | "Major mode for editing MiLan VM object code." | ||
| 37 | (setq font-lock-defaults '(milan-vm-mode-fontlock) | ||
| 38 | comment-start ";")) | ||
| 39 | |||
| 40 | (provide 'milan-vm-mode) | ||
| 41 | |||
| 42 | ;;; milan-vm-mode.el ends here | ||
