diff options
| author | 2026-11-08 08:19:44 +0000 | |
|---|---|---|
| committer | 2026-11-08 08:23:19 +0000 | |
| commit | 5be0e39d0ce97849d7722bd1ac98563c7014faf3 (patch) | |
| tree | 9dba821664337a6662a6da88dfe86291d269c36b /lib/bnf-mode.el | |
| download | lab-05-master.tar.gz | |
Diffstat (limited to 'lib/bnf-mode.el')
| -rw-r--r-- | lib/bnf-mode.el | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/bnf-mode.el b/lib/bnf-mode.el new file mode 100644 index 0000000..04b1afb --- /dev/null +++ b/lib/bnf-mode.el | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | ;;; bnf-mode.el --- simple major mode for BNF -*- 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 bnf-mode-fontlock | ||
| 28 | '(("#.*" . 'font-lock-comment-face) | ||
| 29 | ("<EOL>\\|<EOF>" . 'font-lock-builtin-face) | ||
| 30 | ("::=\\||" . 'font-lock-operator-face) | ||
| 31 | ("\"[^\"]*\"\\|'[^']*'" . 'font-lock-string-face) | ||
| 32 | ("<[^>]+>" . 'font-lock-variable-name-face))) | ||
| 33 | |||
| 34 | (define-derived-mode bnf-mode fundamental-mode "bnf" | ||
| 35 | "Major mode for editing bnf grammars." | ||
| 36 | (setq font-lock-defaults '(bnf-mode-fontlock))) | ||
| 37 | |||
| 38 | (provide 'bnf-mode) | ||
| 39 | |||
| 40 | ;;; bnf-mode.el ends here | ||
