3 pygments.lexers.verification |
3 pygments.lexers.verification |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Lexer for Intermediate Verification Languages (IVLs). |
6 Lexer for Intermediate Verification Languages (IVLs). |
7 |
7 |
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 from pygments.lexer import RegexLexer, include, words |
12 from pygments.lexer import RegexLexer, include, words |
13 from pygments.token import Comment, Operator, Keyword, Name, Number, \ |
13 from pygments.token import Comment, Operator, Keyword, Name, Number, \ |
14 Punctuation, Whitespace |
14 Punctuation, Text, Generic |
15 |
15 |
16 __all__ = ['BoogieLexer', 'SilverLexer'] |
16 __all__ = ['BoogieLexer', 'SilverLexer'] |
17 |
17 |
18 |
18 |
19 class BoogieLexer(RegexLexer): |
19 class BoogieLexer(RegexLexer): |
43 (words(('const',), suffix=r'\b'), Keyword.Reserved), |
44 (words(('const',), suffix=r'\b'), Keyword.Reserved), |
44 |
45 |
45 (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type), |
46 (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type), |
46 include('numbers'), |
47 include('numbers'), |
47 (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator), |
48 (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator), |
|
49 (r'\{.*?\}', Generic.Emph), #triggers |
48 (r"([{}():;,.])", Punctuation), |
50 (r"([{}():;,.])", Punctuation), |
49 # Identifier |
51 # Identifier |
50 (r'[a-zA-Z_]\w*', Name), |
52 (r'[a-zA-Z_]\w*', Name), |
51 ], |
53 ], |
52 'comment': [ |
54 'comment': [ |
72 filenames = ['*.sil', '*.vpr'] |
74 filenames = ['*.sil', '*.vpr'] |
73 |
75 |
74 tokens = { |
76 tokens = { |
75 'root': [ |
77 'root': [ |
76 # Whitespace and Comments |
78 # Whitespace and Comments |
77 (r'\n', Whitespace), |
79 (r'\n', Text), |
78 (r'\s+', Whitespace), |
80 (r'\s+', Text), |
|
81 (r'\\\n', Text), # line continuation |
79 (r'//[/!](.*?)\n', Comment.Doc), |
82 (r'//[/!](.*?)\n', Comment.Doc), |
80 (r'//(.*?)\n', Comment.Single), |
83 (r'//(.*?)\n', Comment.Single), |
81 (r'/\*', Comment.Multiline, 'comment'), |
84 (r'/\*', Comment.Multiline, 'comment'), |
82 |
85 |
83 (words(( |
86 (words(( |
84 'result', 'true', 'false', 'null', 'method', 'function', |
87 'result', 'true', 'false', 'null', 'method', 'function', |
85 'predicate', 'program', 'domain', 'axiom', 'var', 'returns', |
88 'predicate', 'program', 'domain', 'axiom', 'var', 'returns', |
86 'field', 'define', 'requires', 'ensures', 'invariant', |
89 'field', 'define', 'fold', 'unfold', 'inhale', 'exhale', 'new', 'assert', |
87 'fold', 'unfold', 'inhale', 'exhale', 'new', 'assert', |
|
88 'assume', 'goto', 'while', 'if', 'elseif', 'else', 'fresh', |
90 'assume', 'goto', 'while', 'if', 'elseif', 'else', 'fresh', |
89 'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection', |
91 'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection', |
90 'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists', |
92 'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists', |
91 'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique', |
93 'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique', |
92 'apply', 'package', 'folding', 'label', 'forperm'), |
94 'apply', 'package', 'folding', 'label', 'forperm'), |
93 suffix=r'\b'), Keyword), |
95 suffix=r'\b'), Keyword), |
94 (words(('Int', 'Perm', 'Bool', 'Ref'), suffix=r'\b'), Keyword.Type), |
96 (words(('requires', 'ensures', 'invariant'), suffix=r'\b'), Name.Decorator), |
|
97 (words(('Int', 'Perm', 'Bool', 'Ref', 'Rational'), suffix=r'\b'), Keyword.Type), |
95 include('numbers'), |
98 include('numbers'), |
96 |
|
97 (r'[!%&*+=|?:<>/\-\[\]]', Operator), |
99 (r'[!%&*+=|?:<>/\-\[\]]', Operator), |
|
100 (r'\{.*?\}', Generic.Emph), #triggers |
98 (r'([{}():;,.])', Punctuation), |
101 (r'([{}():;,.])', Punctuation), |
99 # Identifier |
102 # Identifier |
100 (r'[\w$]\w*', Name), |
103 (r'[\w$]\w*', Name), |
101 ], |
104 ], |
102 'comment': [ |
105 'comment': [ |