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

11 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:16 +0000

1""" 

2 pygments.lexers.verifpal 

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

4 

5 Lexers for Verifpal languages. 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11import re 

12 

13from pygments.lexer import RegexLexer, include, words, bygroups, default 

14from pygments.token import Text, Comment, Operator, Keyword, Name, String, Punctuation, Whitespace 

15 

16__all__ = ['VerifpalLexer'] 

17 

18 

19class VerifpalLexer(RegexLexer): 

20 """ 

21 For Verifpal code. 

22 

23 .. versionadded:: 2.16.0 

24 """ 

25 

26 name = 'Verifpal' 

27 aliases = ['verifpal'] 

28 filenames = ['*.vp'] 

29 mimetypes = ['text/x-verifpal'] 

30 url = 'https://verifpal.com' 

31 

32 tokens = { 

33 'root': [ 

34 (r'//.*$', Comment.Single), 

35 (r'(principal)( +)(\w+)( *)(\[)(.*)$', bygroups(Name.Builtin, Whitespace, String, Whitespace, Punctuation, Whitespace)), 

36 (r'(attacker)( *)(\[)( *)(passive|active)( *)(\])( *)$', bygroups(Name.Builtin, Whitespace, Punctuation, Whitespace, String, Whitespace, Punctuation, Whitespace)), 

37 (r'(knows)( +)(private|public)( +)', bygroups(Name.Builtin, Whitespace, Keyword.Constant, Whitespace), 'shared'), 

38 (r'(queries)( +)(\[)', bygroups(Name.Builtin, Whitespace, Punctuation), 'queries'), 

39 (r'(\w+)( +)(->|→)( *)(\w+)( *)(\:)', bygroups(String, Whitespace, Punctuation, Whitespace, String, Whitespace, Punctuation), 'shared'), 

40 (words(('generates', 'leaks'), suffix=r'\b'), Name.Builtin, 'shared'), 

41 (words(( 'phase', 'precondition',), suffix=r'\b'), Name.Builtin), 

42 (r'[\[\(\)\]\?:=→^,]', Punctuation), 

43 (r'->', Punctuation), 

44 (words(('password',), suffix=r'\b'), Keyword.Constant), 

45 (words(('AEAD_DEC', 'AEAD_ENC', 'ASSERT', 'BLIND', 'CONCAT', 

46 'DEC', 'ENC', 'G', 'HASH', 'HKDF', 'MAC', 'PKE_DEC', 

47 'PKE_ENC', 'PW_HASH', 'RINGSIGN', 'RINGSIGNVERIF', 

48 'SHAMIR_JOIN', 'SHAMIR_SPLIT', 'SIGN', 'SIGNVERIF', 

49 'SPLIT', 'UNBLIND', '_', 'nil'), suffix=r'\b'), 

50 Name.Function), 

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

52 (r'\w+', Name.Variable), 

53 ], 

54 'shared': [ 

55 (r'[\^\[\],]', Punctuation), 

56 (r' +', Whitespace), 

57 (r'\w+', Name.Variable), 

58 default('#pop') 

59 ], 

60 'queries': [ 

61 (r'\s+', Name.Variable), 

62 (words(('confidentiality?', 'authentication?', 'freshness?', 

63 'unlinkability?', 'equivalence?'), suffix='( )'), 

64 bygroups(Keyword.Pseudo, Whitespace), 'shared'), 

65 default('#pop') 

66 ] 

67 }