diff options
| author | 2026-11-08 06:49:14 +0000 | |
|---|---|---|
| committer | 2026-11-08 06:49:14 +0000 | |
| commit | 0e856ca15d8aa1499edc33c7302d4d97be404290 (patch) | |
| tree | d2bb840d13c57aa17f643e6039af370255e38379 /lib | |
| download | lab-04-master.tar.gz | |
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/milan-mode.el | 44 | ||||
| -rw-r--r-- | lib/milan-vm-mode.el | 42 |
2 files changed, 86 insertions, 0 deletions
diff --git a/lib/milan-mode.el b/lib/milan-mode.el new file mode 100644 index 0000000..b5df550 --- /dev/null +++ b/lib/milan-mode.el | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | ;;; milan-mode.el --- simple major mode for MiLan -*- 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-mode-fontlock | ||
| 28 | '(("/\\*\\(\\*[^/]\\|[^\\*]\\)*\\*/" . 'font-lock-comment-face) | ||
| 29 | ((string-join '("BEGIN" "END" "IF" "THEN" "ELSE" "FI" "WHILE" "DO" | ||
| 30 | "OD" "WRITE" "READ" "FUNC" "RETURNS?" "LOCALS") "\\|") | ||
| 31 | . 'font-lock-keyword-face) | ||
| 32 | (":=\\|+\\|-\\|\\*\\|/\\|<\\|<=\\|=\\|!=\\|>\\|>=" . 'font-lock-operator-face) | ||
| 33 | ("\\(\\|\\)" . 'font-lock-bracket-face) | ||
| 34 | ;; ("[_a-z][_a-z0-9]*\s*\\(" . 'font-lock-function-name-face) | ||
| 35 | ;; ("[_a-z][_a-z0-9]*" . 'font-lock-variable-name-face) | ||
| 36 | )) | ||
| 37 | |||
| 38 | (define-derived-mode milan-mode prog-mode "MiLan" | ||
| 39 | "Major mode for editing milan grammars." | ||
| 40 | (setq font-lock-defaults '(milan-mode-fontlock))) | ||
| 41 | |||
| 42 | (provide 'milan-mode) | ||
| 43 | |||
| 44 | ;;; milan-mode.el ends here | ||
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 | ||
