From e521fffed272eba866f64484010090909d4f60b7 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 3 Jan 2023 09:02:54 +0100 Subject: [PATCH] feat: highlight ip6.arpa question with separation at upper-half hextet boundaries --- dig-lexer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dig-lexer.py b/dig-lexer.py index 8895e0c..570c53d 100755 --- a/dig-lexer.py +++ b/dig-lexer.py @@ -47,12 +47,23 @@ class CustomLexer(ExtendedRegexLexer): yield re.start('nadd'), String.Doc, re.group('nadd') ctx.pos = re.end() + def parse_rdns(lexer, re, ctx): + yield re.start('c1'), Comment.Hashbang, re.group('c1') + yield re.start('pl64'), Name.Class, re.group('pl64') + yield re.start('pl48'), Number.Integer, re.group('pl48') + yield re.start('pl32'), Name.Class, re.group('pl32') + yield re.start('pl16'), Name.Tag, re.group('pl16') + yield re.start('pl0'), String.Doc, re.group('pl0') + yield re.start('end'), Comment.Hashbang, re.group('end') + ctx.pos = re.end() + tokens = { 'root': [ (r'(?P; <<>>)(?P.*)(?P<<>>)(?P.*\n)', parse_dig_header), (r'(?P;; ->>HEADER<<- opcode: )(?P[^\s]+)(?P, status: )(?P[^\s]+)(?P, id: )(?P[^\s]+\n)(?P;; flags: )(?P[^;]+)(?P; QUERY: )(?P\d+)(?P, ANSWER: )(?P\d+)(?P, AUTHORITY: )(?P\d+)(?P, ADDITIONAL: )(?P\d+\n)', parse_response_header), + (r'(?P;)(?P([0-9a-fA-F]\.){16})(?P([0-9a-fA-F]\.){4})(?P([0-9a-fA-F]\.){4})(?P([0-9a-fA-F]\.){4})(?P([0-9a-fA-F]\.){4})(?Pip6\.arpa\..*$)', parse_rdns), (r';;.*', Generic.Subheading), # comment section headers - (r';.*', Comment.Single), # comment section headers + (r';.*', Comment.Single), (r'\n', Generic), (r'^', Generic, 'rname') ],