aboutsummaryrefslogtreecommitdiff
path: root/lib/bnf-mode.el
diff options
context:
space:
mode:
authorLibravatar Martin Michalec <martin@michalec.dev>2026-11-08 06:02:38 +0000
committerLibravatar Martin Michalec <martin@michalec.dev>2026-11-08 06:26:07 +0000
commit6ecea40c849effd171c1d27c961f5c1ee100481f (patch)
tree99a92dafddf7d2ef0e318d927ae70c3b642e4171 /lib/bnf-mode.el
downloadlab-03-6ecea40c849effd171c1d27c961f5c1ee100481f.tar.gz
publishHEADmaster
Diffstat (limited to 'lib/bnf-mode.el')
-rw-r--r--lib/bnf-mode.el40
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