Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/tls.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

14 statements  

1""" 

2 pygments.lexers.tls 

3 ~~~~~~~~~~~~~~~~~~~ 

4 

5 Lexers for the TLS presentation language. 

6 

7 :copyright: Copyright 2006-2025 by the Pygments team, see AUTHORS. 

8 :license: BSD, see LICENSE for details. 

9""" 

10import re 

11 

12from pygments.lexer import RegexLexer, words 

13from pygments.token import Comment, Operator, Keyword, Name, String, \ 

14 Number, Punctuation, Whitespace 

15 

16__all__ = ['TlsLexer'] 

17 

18 

19class TlsLexer(RegexLexer): 

20 """ 

21 The TLS presentation language, described in RFC 8446. 

22 """ 

23 name = 'TLS Presentation Language' 

24 url = 'https://www.rfc-editor.org/rfc/rfc8446#section-3' 

25 filenames = [] 

26 aliases = ['tls'] 

27 mimetypes = [] 

28 version_added = '2.16' 

29 

30 flags = re.MULTILINE | re.DOTALL 

31 

32 tokens = { 

33 'root': [ 

34 (r'\s+', Whitespace), 

35 # comments 

36 (r'/[*].*?[*]/', Comment.Multiline), 

37 # Keywords 

38 (words(('struct', 'enum', 'select', 'case'), suffix=r'\b'), 

39 Keyword), 

40 (words(('uint8', 'uint16', 'uint24', 'uint32', 'uint64', 'opaque'), 

41 suffix=r'\b'), Keyword.Type), 

42 # numeric literals 

43 (r'0x[0-9a-fA-F]+', Number.Hex), 

44 (r'[0-9]+', Number.Integer), 

45 # string literal 

46 (r'"(\\.|[^"\\])*"', String), 

47 # tokens 

48 (r'[.]{2}', Operator), 

49 (r'[+\-*/&^]', Operator), 

50 (r'[|<>=!()\[\]{}.,;:\?]', Punctuation), 

51 # identifiers 

52 (r'[^\W\d]\w*', Name.Other), 

53 ] 

54 }