Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pygments/lexers/verification.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

18 statements  

1""" 

2 pygments.lexers.verification 

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

4 

5 Lexer for Intermediate Verification Languages (IVLs). 

6 

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

8 :license: BSD, see LICENSE for details. 

9""" 

10 

11from pygments.lexer import RegexLexer, include, words 

12from pygments.token import Comment, Operator, Keyword, Name, Number, \ 

13 Punctuation, Text, Generic 

14 

15__all__ = ['BoogieLexer', 'SilverLexer'] 

16 

17 

18class BoogieLexer(RegexLexer): 

19 """ 

20 For Boogie source code. 

21 """ 

22 name = 'Boogie' 

23 url = 'https://boogie-docs.readthedocs.io/en/latest/' 

24 aliases = ['boogie'] 

25 filenames = ['*.bpl'] 

26 version_added = '2.1' 

27 

28 tokens = { 

29 'root': [ 

30 # Whitespace and Comments 

31 (r'\n', Text), 

32 (r'\s+', Text), 

33 (r'\\\n', Text), # line continuation 

34 (r'//[/!](.*?)\n', Comment.Doc), 

35 (r'//(.*?)\n', Comment.Single), 

36 (r'/\*', Comment.Multiline, 'comment'), 

37 

38 (words(( 

39 'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function', 

40 'forall', 'if', 'invariant', 'modifies', 'procedure', 'requires', 

41 'then', 'var', 'while'), 

42 suffix=r'\b'), Keyword), 

43 (words(('const',), suffix=r'\b'), Keyword.Reserved), 

44 

45 (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type), 

46 include('numbers'), 

47 (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator), 

48 (r'\{.*?\}', Generic.Emph), #triggers 

49 (r"([{}():;,.])", Punctuation), 

50 # Identifier 

51 (r'[a-zA-Z_]\w*', Name), 

52 ], 

53 'comment': [ 

54 (r'[^*/]+', Comment.Multiline), 

55 (r'/\*', Comment.Multiline, '#push'), 

56 (r'\*/', Comment.Multiline, '#pop'), 

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

58 ], 

59 'numbers': [ 

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

61 ], 

62 } 

63 

64 

65class SilverLexer(RegexLexer): 

66 """ 

67 For Silver source code. 

68 """ 

69 name = 'Silver' 

70 aliases = ['silver'] 

71 filenames = ['*.sil', '*.vpr'] 

72 url = 'https://github.com/viperproject/silver' 

73 version_added = '2.2' 

74 

75 tokens = { 

76 'root': [ 

77 # Whitespace and Comments 

78 (r'\n', Text), 

79 (r'\s+', Text), 

80 (r'\\\n', Text), # line continuation 

81 (r'//[/!](.*?)\n', Comment.Doc), 

82 (r'//(.*?)\n', Comment.Single), 

83 (r'/\*', Comment.Multiline, 'comment'), 

84 

85 (words(( 

86 'result', 'true', 'false', 'null', 'method', 'function', 

87 'predicate', 'program', 'domain', 'axiom', 'var', 'returns', 

88 'field', 'define', 'fold', 'unfold', 'inhale', 'exhale', 'new', 'assert', 

89 'assume', 'goto', 'while', 'if', 'elseif', 'else', 'fresh', 

90 'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection', 

91 'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists', 

92 'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique', 

93 'apply', 'package', 'folding', 'label', 'forperm'), 

94 suffix=r'\b'), Keyword), 

95 (words(('requires', 'ensures', 'invariant'), suffix=r'\b'), Name.Decorator), 

96 (words(('Int', 'Perm', 'Bool', 'Ref', 'Rational'), suffix=r'\b'), Keyword.Type), 

97 include('numbers'), 

98 (r'[!%&*+=|?:<>/\-\[\]]', Operator), 

99 (r'\{.*?\}', Generic.Emph), #triggers 

100 (r'([{}():;,.])', Punctuation), 

101 # Identifier 

102 (r'[\w$]\w*', Name), 

103 ], 

104 'comment': [ 

105 (r'[^*/]+', Comment.Multiline), 

106 (r'/\*', Comment.Multiline, '#push'), 

107 (r'\*/', Comment.Multiline, '#pop'), 

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

109 ], 

110 'numbers': [ 

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

112 ], 

113 }