summaryrefslogtreecommitdiffstats
path: root/doc/extra/frrlexer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
commite2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch)
treef0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /doc/extra/frrlexer.py
parentInitial commit. (diff)
downloadfrr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz
frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/extra/frrlexer.py')
-rw-r--r--doc/extra/frrlexer.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/extra/frrlexer.py b/doc/extra/frrlexer.py
new file mode 100644
index 0000000..39ce5e6
--- /dev/null
+++ b/doc/extra/frrlexer.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+# SPDX-License-Identifier: ISC
+# Copyright (c) 2017 Vincent Bernat <bernat@luffy.cx>
+
+from pygments.lexer import RegexLexer, bygroups
+from pygments.token import Text, Comment, Keyword
+from pygments.token import String, Number, Name
+
+
+class FRRLexer(RegexLexer):
+ name = "frr"
+ aliases = ["frr"]
+ tokens = {
+ "root": [
+ (r"^[ \t]*!.*?\n", Comment.Singleline),
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
+ (
+ r"[a-f0-9]*:[a-f0-9]*:[a-f0-9:]*(:\d+\.\d+\.\d+\.\d+)?(/\d+)?",
+ Number,
+ ), # IPv6
+ (r"\d+\.\d+\.\d+\.\d+(/\d+)?", Number), # IPv4
+ (r"^([ \t]*)(no[ \t]+)?([-\w]+)", bygroups(Text, Keyword, Name.Function)),
+ (r"[ \t]+", Text),
+ (r"\n", Text),
+ (r"\d+", Number),
+ (r"\S+", Text),
+ ],
+ }