ThirdParty/Pygments/pygments/lexers/esoteric.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
3 pygments.lexers.esoteric 3 pygments.lexers.esoteric
4 ~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for esoteric languages. 6 Lexers for esoteric languages.
7 7
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2015 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 12 from pygments.lexer import RegexLexer, include, words
13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ 13 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
14 Number, Punctuation, Error 14 Number, Punctuation, Error, Whitespace
15 15
16 __all__ = ['BrainfuckLexer', 'BefungeLexer', 'RedcodeLexer'] 16 __all__ = ['BrainfuckLexer', 'BefungeLexer', 'BoogieLexer', 'RedcodeLexer', 'CAmkESLexer']
17 17
18 18
19 class BrainfuckLexer(RegexLexer): 19 class BrainfuckLexer(RegexLexer):
20 """ 20 """
21 Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_ 21 Lexer for the esoteric `BrainFuck <http://www.muppetlabs.com/~breadbox/bf/>`_
72 (r'\'.', String.Single), # Single character 72 (r'\'.', String.Single), # Single character
73 (r'[#;]', Comment), # Trampoline... depends on direction hit 73 (r'[#;]', Comment), # Trampoline... depends on direction hit
74 (r'[pg&~=@iotsy]', Keyword), # Misc 74 (r'[pg&~=@iotsy]', Keyword), # Misc
75 (r'[()A-Z]', Comment), # Fingerprints 75 (r'[()A-Z]', Comment), # Fingerprints
76 (r'\s+', Text), # Whitespace doesn't matter 76 (r'\s+', Text), # Whitespace doesn't matter
77 ],
78 }
79
80
81 class CAmkESLexer(RegexLexer):
82 """
83 Basic lexer for the input language for the
84 `CAmkES <https://sel4.systems/CAmkES/>`_ component platform.
85
86 .. versionadded:: 2.1
87 """
88 name = 'CAmkES'
89 aliases = ['camkes', 'idl4']
90 filenames = ['*.camkes', '*.idl4']
91
92 tokens = {
93 'root':[
94 # C pre-processor directive
95 (r'^\s*#.*\n', Comment.Preproc),
96
97 # Whitespace, comments
98 (r'\s+', Text),
99 (r'/\*(.|\n)*?\*/', Comment),
100 (r'//.*\n', Comment),
101
102 (r'[\[\(\){},\.;=\]]', Punctuation),
103
104 (words(('assembly', 'attribute', 'component', 'composition',
105 'configuration', 'connection', 'connector', 'consumes',
106 'control', 'dataport', 'Dataport', 'emits', 'event',
107 'Event', 'from', 'group', 'hardware', 'has', 'interface',
108 'Interface', 'maybe', 'procedure', 'Procedure', 'provides',
109 'template', 'to', 'uses'), suffix=r'\b'), Keyword),
110
111 (words(('bool', 'boolean', 'Buf', 'char', 'character', 'double',
112 'float', 'in', 'inout', 'int', 'int16_6', 'int32_t',
113 'int64_t', 'int8_t', 'integer', 'mutex', 'out', 'real',
114 'refin', 'semaphore', 'signed', 'string', 'uint16_t',
115 'uint32_t', 'uint64_t', 'uint8_t', 'uintptr_t', 'unsigned',
116 'void'), suffix=r'\b'), Keyword.Type),
117
118 # Recognised attributes
119 (r'[a-zA-Z_]\w*_(priority|domain|buffer)', Keyword.Reserved),
120 (words(('dma_pool', 'from_access', 'to_access'), suffix=r'\b'),
121 Keyword.Reserved),
122
123 # CAmkES-level include
124 (r'import\s+(<[^>]*>|"[^"]*");', Comment.Preproc),
125
126 # C-level include
127 (r'include\s+(<[^>]*>|"[^"]*");', Comment.Preproc),
128
129 # Literals
130 (r'0[xX][\da-fA-F]+', Number.Hex),
131 (r'-?[\d]+', Number),
132 (r'-?[\d]+\.[\d]+', Number.Float),
133 (r'"[^"]*"', String),
134
135 # Identifiers
136 (r'[a-zA-Z_]\w*', Name),
77 ], 137 ],
78 } 138 }
79 139
80 140
81 class RedcodeLexer(RegexLexer): 141 class RedcodeLexer(RegexLexer):
110 (r'[.,]', Punctuation), # mode 170 (r'[.,]', Punctuation), # mode
111 # Numbers 171 # Numbers
112 (r'[-+]?\d+', Number.Integer), 172 (r'[-+]?\d+', Number.Integer),
113 ], 173 ],
114 } 174 }
175
176
177 class BoogieLexer(RegexLexer):
178 """
179 For `Boogie <https://boogie.codeplex.com/>`_ source code.
180
181 .. versionadded:: 2.1
182 """
183 name = 'Boogie'
184 aliases = ['boogie']
185 filenames = ['*.bpl']
186
187 tokens = {
188 'root': [
189 # Whitespace and Comments
190 (r'\n', Whitespace),
191 (r'\s+', Whitespace),
192 (r'//[/!](.*?)\n', Comment.Doc),
193 (r'//(.*?)\n', Comment.Single),
194 (r'/\*', Comment.Multiline, 'comment'),
195
196 (words((
197 'axiom', 'break', 'call', 'ensures', 'else', 'exists', 'function',
198 'forall', 'if', 'invariant', 'modifies', 'procedure', 'requires',
199 'then', 'var', 'while'),
200 suffix=r'\b'), Keyword),
201 (words(('const',), suffix=r'\b'), Keyword.Reserved),
202
203 (words(('bool', 'int', 'ref'), suffix=r'\b'), Keyword.Type),
204 include('numbers'),
205 (r"(>=|<=|:=|!=|==>|&&|\|\||[+/\-=>*<\[\]])", Operator),
206 (r"([{}():;,.])", Punctuation),
207 # Identifier
208 (r'[a-zA-Z_]\w*', Name),
209 ],
210 'comment': [
211 (r'[^*/]+', Comment.Multiline),
212 (r'/\*', Comment.Multiline, '#push'),
213 (r'\*/', Comment.Multiline, '#pop'),
214 (r'[*/]', Comment.Multiline),
215 ],
216 'numbers': [
217 (r'[0-9]+', Number.Integer),
218 ],
219 }

eric ide

mercurial