Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pygments/lexers/tls.py: 100%
12 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-26 07:02 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-26 07:02 +0000
1"""
2 pygments.lexers.tls
3 ~~~~~~~~~~~~~~~~~~~
5 Lexers for the TLS presentation language.
7 :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
8 :license: BSD, see LICENSE for details.
9"""
10import re
12from pygments.lexer import RegexLexer, bygroups, words
13from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
14 Number, Punctuation, Whitespace
16__all__ = ['TlsLexer']
19class TlsLexer(RegexLexer):
20 """
21 The TLS presentation language, described in RFC 8446.
23 .. versionadded:: 2.16
24 """
25 name = 'TLS Presentation Language'
26 url = 'https://www.rfc-editor.org/rfc/rfc8446#section-3'
27 filenames = []
28 aliases = ['tls']
29 mimetypes = []
31 flags = re.MULTILINE | re.DOTALL
33 tokens = {
34 'root': [
35 (r'\s+', Whitespace),
36 # comments
37 (r'/[*].*?[*]/', Comment.Multiline),
38 # Keywords
39 (words(('struct', 'enum', 'select', 'case'), suffix=r'\b'),
40 Keyword),
41 (words(('uint8', 'uint16', 'uint24', 'uint32', 'uint64', 'opaque'),
42 suffix=r'\b'), Keyword.Type),
43 # numeric literals
44 (r'0x[0-9a-fA-F]+', Number.Hex),
45 (r'[0-9]+', Number.Integer),
46 # string literal
47 (r'"(\\.|[^"\\])*"', String),
48 # tokens
49 (r'[.]{2}', Operator),
50 (r'[+\-*/&^]', Operator),
51 (r'[|<>=!()\[\]{}.,;:\?]', Punctuation),
52 # identifiers
53 (r'[^\W\d]\w*', Name.Other),
54 ]
55 }