eric6/ThirdParty/Pygments/pygments/lexers/verification.py

changeset 8258
82b608e352ec
parent 8257
28146736bbfc
child 8259
2bbec88047dd
equal deleted inserted replaced
8257:28146736bbfc 8258:82b608e352ec
1 # -*- coding: utf-8 -*-
2 """
3 pygments.lexers.verification
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
6 Lexer for Intermediate Verification Languages (IVLs).
7
8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details.
10 """
11
12 from pygments.lexer import RegexLexer, include, words
13 from pygments.token import Comment, Operator, Keyword, Name, Number, \
14 Punctuation, Text, Generic
15
16 __all__ = ['BoogieLexer', 'SilverLexer']
17
18
19 class BoogieLexer(RegexLexer):
20 """
21 For `Boogie <https://boogie.codeplex.com/>`_ source code.
22
23 .. versionadded:: 2.1
24 """
25 name = 'Boogie'
26 aliases = ['boogie']
27 filenames = ['*.bpl']
28
29 tokens = {
30 'root': [
31 # Whitespace and Comments
32 (r'\n', Text),
33 (r'\s+', Text),
34 (r'\\\n', Text), # line continuation
35 (r'//[/!](.*?)\n', Comment.Doc),
36 (r'//(.*?)\n', Comment.Single),
37 (r'/\*', Comment.Multiline, 'comment'),
38
39 (words((
40 'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function',
41 'forall', 'if', 'invariant', 'modifies', 'procedure', 'requires',
42 'then', 'var', 'while'),
43 suffix=r'\b'), Keyword),
44 (words(('const',), suffix=r'\b'), Keyword.Reserved),
45
46 (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type),
47 include('numbers'),
48 (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator),
49 (r'\{.*?\}', Generic.Emph), #triggers
50 (r"([{}():;,.])", Punctuation),
51 # Identifier
52 (r'[a-zA-Z_]\w*', Name),
53 ],
54 'comment': [
55 (r'[^*/]+', Comment.Multiline),
56 (r'/\*', Comment.Multiline, '#push'),
57 (r'\*/', Comment.Multiline, '#pop'),
58 (r'[*/]', Comment.Multiline),
59 ],
60 'numbers': [
61 (r'[0-9]+', Number.Integer),
62 ],
63 }
64
65
66 class SilverLexer(RegexLexer):
67 """
68 For `Silver <https://bitbucket.org/viperproject/silver>`_ source code.
69
70 .. versionadded:: 2.2
71 """
72 name = 'Silver'
73 aliases = ['silver']
74 filenames = ['*.sil', '*.vpr']
75
76 tokens = {
77 'root': [
78 # Whitespace and Comments
79 (r'\n', Text),
80 (r'\s+', Text),
81 (r'\\\n', Text), # line continuation
82 (r'//[/!](.*?)\n', Comment.Doc),
83 (r'//(.*?)\n', Comment.Single),
84 (r'/\*', Comment.Multiline, 'comment'),
85
86 (words((
87 'result', 'true', 'false', 'null', 'method', 'function',
88 'predicate', 'program', 'domain', 'axiom', 'var', 'returns',
89 'field', 'define', 'fold', 'unfold', 'inhale', 'exhale', 'new', 'assert',
90 'assume', 'goto', 'while', 'if', 'elseif', 'else', 'fresh',
91 'constraining', 'Seq', 'Set', 'Multiset', 'union', 'intersection',
92 'setminus', 'subset', 'unfolding', 'in', 'old', 'forall', 'exists',
93 'acc', 'wildcard', 'write', 'none', 'epsilon', 'perm', 'unique',
94 'apply', 'package', 'folding', 'label', 'forperm'),
95 suffix=r'\b'), Keyword),
96 (words(('requires', 'ensures', 'invariant'), suffix=r'\b'), Name.Decorator),
97 (words(('Int', 'Perm', 'Bool', 'Ref', 'Rational'), suffix=r'\b'), Keyword.Type),
98 include('numbers'),
99 (r'[!%&*+=|?:<>/\-\[\]]', Operator),
100 (r'\{.*?\}', Generic.Emph), #triggers
101 (r'([{}():;,.])', Punctuation),
102 # Identifier
103 (r'[\w$]\w*', Name),
104 ],
105 'comment': [
106 (r'[^*/]+', Comment.Multiline),
107 (r'/\*', Comment.Multiline, '#push'),
108 (r'\*/', Comment.Multiline, '#pop'),
109 (r'[*/]', Comment.Multiline),
110 ],
111 'numbers': [
112 (r'[0-9]+', Number.Integer),
113 ],
114 }

eric ide

mercurial