ThirdParty/Pygments/pygments/lexers/compiled.py

changeset 1705
b0fbc9300f2b
parent 808
8f85926125ef
child 2426
da76c71624de
equal deleted inserted replaced
1704:02ae6c55b35b 1705:b0fbc9300f2b
3 pygments.lexers.compiled 3 pygments.lexers.compiled
4 ~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for compiled languages. 6 Lexers for compiled languages.
7 7
8 :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2012 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 import re 12 import re
13 13 from string import Template
14
15 from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
16 this, combined
17 from pygments.util import get_bool_opt, get_list_opt
18 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
19 Number, Punctuation, Error, Literal
14 from pygments.scanner import Scanner 20 from pygments.scanner import Scanner
15 from pygments.lexer import Lexer, RegexLexer, include, bygroups, using, \
16 this, combined
17 from pygments.util import get_bool_opt, get_list_opt
18 from pygments.token import \
19 Text, Comment, Operator, Keyword, Name, String, Number, Punctuation, \
20 Error
21 21
22 # backwards compatibility 22 # backwards compatibility
23 from pygments.lexers.functional import OcamlLexer 23 from pygments.lexers.functional import OcamlLexer
24 24 from pygments.lexers.jvm import JavaLexer, ScalaLexer
25 __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'JavaLexer', 25
26 'ScalaLexer', 'DylanLexer', 'OcamlLexer', 'ObjectiveCLexer', 26 __all__ = ['CLexer', 'CppLexer', 'DLexer', 'DelphiLexer', 'ECLexer',
27 'FortranLexer', 'GLShaderLexer', 'PrologLexer', 'CythonLexer', 27 'DylanLexer', 'ObjectiveCLexer', 'FortranLexer', 'GLShaderLexer',
28 'ValaLexer', 'OocLexer', 'GoLexer', 'FelixLexer', 'AdaLexer', 28 'PrologLexer', 'CythonLexer', 'ValaLexer', 'OocLexer', 'GoLexer',
29 'Modula2Lexer', 'BlitzMaxLexer'] 29 'FelixLexer', 'AdaLexer', 'Modula2Lexer', 'BlitzMaxLexer',
30 'NimrodLexer', 'FantomLexer']
30 31
31 32
32 class CLexer(RegexLexer): 33 class CLexer(RegexLexer):
33 """ 34 """
34 For C source code with preprocessor directives. 35 For C source code with preprocessor directives.
35 """ 36 """
36 name = 'C' 37 name = 'C'
37 aliases = ['c'] 38 aliases = ['c']
38 filenames = ['*.c', '*.h'] 39 filenames = ['*.c', '*.h', '*.idc']
39 mimetypes = ['text/x-chdr', 'text/x-csrc'] 40 mimetypes = ['text/x-chdr', 'text/x-csrc']
40 41
41 #: optional Comment or Whitespace 42 #: optional Comment or Whitespace
42 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+' 43 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
43 44
45 'whitespace': [ 46 'whitespace': [
46 # preprocessor directives: without whitespace 47 # preprocessor directives: without whitespace
47 ('^#if\s+0', Comment.Preproc, 'if0'), 48 ('^#if\s+0', Comment.Preproc, 'if0'),
48 ('^#', Comment.Preproc, 'macro'), 49 ('^#', Comment.Preproc, 'macro'),
49 # or with whitespace 50 # or with whitespace
50 ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'), 51 ('^(' + _ws + r')(#if\s+0)',
51 ('^' + _ws + '#', Comment.Preproc, 'macro'), 52 bygroups(using(this), Comment.Preproc), 'if0'),
52 (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)), 53 ('^(' + _ws + ')(#)',
54 bygroups(using(this), Comment.Preproc), 'macro'),
55 (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))',
56 bygroups(Text, Name.Label)),
53 (r'\n', Text), 57 (r'\n', Text),
54 (r'\s+', Text), 58 (r'\s+', Text),
55 (r'\\\n', Text), # line continuation 59 (r'\\\n', Text), # line continuation
56 (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single), 60 (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
57 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 61 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
167 """ 171 """
168 For C++ source code with preprocessor directives. 172 For C++ source code with preprocessor directives.
169 """ 173 """
170 name = 'C++' 174 name = 'C++'
171 aliases = ['cpp', 'c++'] 175 aliases = ['cpp', 'c++']
172 filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx'] 176 filenames = ['*.cpp', '*.hpp', '*.c++', '*.h++',
177 '*.cc', '*.hh', '*.cxx', '*.hxx']
173 mimetypes = ['text/x-c++hdr', 'text/x-c++src'] 178 mimetypes = ['text/x-c++hdr', 'text/x-c++src']
174 179
175 #: optional Comment or Whitespace 180 #: optional Comment or Whitespace
176 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+' 181 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
177 182
179 'root': [ 184 'root': [
180 # preprocessor directives: without whitespace 185 # preprocessor directives: without whitespace
181 ('^#if\s+0', Comment.Preproc, 'if0'), 186 ('^#if\s+0', Comment.Preproc, 'if0'),
182 ('^#', Comment.Preproc, 'macro'), 187 ('^#', Comment.Preproc, 'macro'),
183 # or with whitespace 188 # or with whitespace
184 ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'), 189 ('^(' + _ws + r')(#if\s+0)',
185 ('^' + _ws + '#', Comment.Preproc, 'macro'), 190 bygroups(using(this), Comment.Preproc), 'if0'),
191 ('^(' + _ws + ')(#)',
192 bygroups(using(this), Comment.Preproc), 'macro'),
186 (r'\n', Text), 193 (r'\n', Text),
187 (r'\s+', Text), 194 (r'\s+', Text),
188 (r'\\\n', Text), # line continuation 195 (r'\\\n', Text), # line continuation
189 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single), 196 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
190 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 197 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
214 r'declspec|finally|int64|try|leave|wchar_t|w64|virtual_inheritance|' 221 r'declspec|finally|int64|try|leave|wchar_t|w64|virtual_inheritance|'
215 r'uuidof|unaligned|super|single_inheritance|raise|noop|' 222 r'uuidof|unaligned|super|single_inheritance|raise|noop|'
216 r'multiple_inheritance|m128i|m128d|m128|m64|interface|' 223 r'multiple_inheritance|m128i|m128d|m128|m64|interface|'
217 r'identifier|forceinline|event|assume)\b', Keyword.Reserved), 224 r'identifier|forceinline|event|assume)\b', Keyword.Reserved),
218 # Offload C++ extensions, http://offload.codeplay.com/ 225 # Offload C++ extensions, http://offload.codeplay.com/
219 (r'(__offload|__blockingoffload|__outer)\b', Keyword.Psuedo), 226 (r'(__offload|__blockingoffload|__outer)\b', Keyword.Pseudo),
220 (r'(true|false)\b', Keyword.Constant), 227 (r'(true|false)\b', Keyword.Constant),
221 (r'NULL\b', Name.Builtin), 228 (r'NULL\b', Name.Builtin),
222 ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label), 229 ('[a-zA-Z_][a-zA-Z0-9_]*:(?!:)', Name.Label),
223 ('[a-zA-Z_][a-zA-Z0-9_]*', Name), 230 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
224 ], 231 ],
246 (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'), 253 (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
247 (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'), 254 (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
248 (r'.*?\n', Comment), 255 (r'.*?\n', Comment),
249 ] 256 ]
250 } 257 }
258
259
260 class ECLexer(RegexLexer):
261 """
262 For eC source code with preprocessor directives.
263
264 *New in Pygments 1.5.*
265 """
266 name = 'eC'
267 aliases = ['ec']
268 filenames = ['*.ec', '*.eh']
269 mimetypes = ['text/x-echdr', 'text/x-ecsrc']
270
271 #: optional Comment or Whitespace
272 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
273
274 tokens = {
275 'whitespace': [
276 # preprocessor directives: without whitespace
277 ('^#if\s+0', Comment.Preproc, 'if0'),
278 ('^#', Comment.Preproc, 'macro'),
279 # or with whitespace
280 ('^' + _ws + r'#if\s+0', Comment.Preproc, 'if0'),
281 ('^' + _ws + '#', Comment.Preproc, 'macro'),
282 (r'^(\s*)([a-zA-Z_][a-zA-Z0-9_]*:(?!:))', bygroups(Text, Name.Label)),
283 (r'\n', Text),
284 (r'\s+', Text),
285 (r'\\\n', Text), # line continuation
286 (r'//(\n|(.|\n)*?[^\\]\n)', Comment.Single),
287 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
288 ],
289 'statements': [
290 (r'L?"', String, 'string'),
291 (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
292 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*', Number.Float),
293 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
294 (r'0x[0-9a-fA-F]+[LlUu]*', Number.Hex),
295 (r'0[0-7]+[LlUu]*', Number.Oct),
296 (r'\d+[LlUu]*', Number.Integer),
297 (r'\*/', Error),
298 (r'[~!%^&*+=|?:<>/-]', Operator),
299 (r'[()\[\],.]', Punctuation),
300 (r'\b(case)(.+?)(:)', bygroups(Keyword, using(this), Text)),
301 (r'(auto|break|case|const|continue|default|do|else|enum|extern|'
302 r'for|goto|if|register|restricted|return|sizeof|static|struct|'
303 r'switch|typedef|union|volatile|virtual|while|class|private|public|'
304 r'property|import|delete|new|new0|renew|renew0|define|get|set|remote|dllexport|dllimport|stdcall|'
305 r'subclass|__on_register_module|namespace|using|typed_object|any_object|incref|register|watch|'
306 r'stopwatching|firewatchers|watchable|class_designer|class_fixed|class_no_expansion|isset|'
307 r'class_default_property|property_category|class_data|class_property|virtual|thisclass|'
308 r'dbtable|dbindex|database_open|dbfield)\b', Keyword),
309 (r'(int|long|float|short|double|char|unsigned|signed|void)\b',
310 Keyword.Type),
311 (r'(uint|uint16|uint32|uint64|bool|byte|unichar|int64)\b',
312 Keyword.Type),
313 (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
314 (r'(_{0,2}inline|naked|restrict|thread|typename)\b', Keyword.Reserved),
315 (r'__(asm|int8|based|except|int16|stdcall|cdecl|fastcall|int32|'
316 r'declspec|finally|int64|try|leave)\b', Keyword.Reserved),
317 (r'(true|false|null|value|this|NULL)\b', Name.Builtin),
318 ('[a-zA-Z_][a-zA-Z0-9_]*', Name),
319 ],
320 'root': [
321 include('whitespace'),
322 # functions
323 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
324 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
325 r'(\s*\([^;]*?\))' # signature
326 r'(' + _ws + r')({)',
327 bygroups(using(this), Name.Function, using(this), using(this),
328 Punctuation),
329 'function'),
330 # function declarations
331 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
332 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
333 r'(\s*\([^;]*?\))' # signature
334 r'(' + _ws + r')(;)',
335 bygroups(using(this), Name.Function, using(this), using(this),
336 Punctuation)),
337 ('', Text, 'statement'),
338 ],
339 'classname': [
340 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop'),
341 # template specification
342 (r'\s*(?=>)', Text, '#pop'),
343 ],
344 'statement' : [
345 include('whitespace'),
346 include('statements'),
347 ('[{}]', Punctuation),
348 (';', Punctuation, '#pop'),
349 ],
350 'function': [
351 include('whitespace'),
352 include('statements'),
353 (';', Punctuation),
354 ('{', Punctuation, '#push'),
355 ('}', Punctuation, '#pop'),
356 ],
357 'string': [
358 (r'"', String, '#pop'),
359 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
360 (r'[^\\"\n]+', String), # all other characters
361 (r'\\\n', String), # line continuation
362 (r'\\', String), # stray backslash
363 ],
364 'macro': [
365 (r'[^/\n]+', Comment.Preproc),
366 (r'/[*](.|\n)*?[*]/', Comment.Multiline),
367 (r'//.*?\n', Comment.Single, '#pop'),
368 (r'/', Comment.Preproc),
369 (r'(?<=\\)\n', Comment.Preproc),
370 (r'\n', Comment.Preproc, '#pop'),
371 ],
372 'if0': [
373 (r'^\s*#if.*?(?<!\\)\n', Comment.Preproc, '#push'),
374 (r'^\s*#el(?:se|if).*\n', Comment.Preproc, '#pop'),
375 (r'^\s*#endif.*?(?<!\\)\n', Comment.Preproc, '#pop'),
376 (r'.*?\n', Comment),
377 ]
378 }
379
380 stdlib_types = ['size_t', 'ssize_t', 'off_t', 'wchar_t', 'ptrdiff_t',
381 'sig_atomic_t', 'fpos_t', 'clock_t', 'time_t', 'va_list',
382 'jmp_buf', 'FILE', 'DIR', 'div_t', 'ldiv_t', 'mbstate_t',
383 'wctrans_t', 'wint_t', 'wctype_t']
384 c99_types = ['_Bool', '_Complex', 'int8_t', 'int16_t', 'int32_t', 'int64_t',
385 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int_least8_t',
386 'int_least16_t', 'int_least32_t', 'int_least64_t',
387 'uint_least8_t', 'uint_least16_t', 'uint_least32_t',
388 'uint_least64_t', 'int_fast8_t', 'int_fast16_t', 'int_fast32_t',
389 'int_fast64_t', 'uint_fast8_t', 'uint_fast16_t', 'uint_fast32_t',
390 'uint_fast64_t', 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t']
391
392 def __init__(self, **options):
393 self.stdlibhighlighting = get_bool_opt(options,
394 'stdlibhighlighting', True)
395 self.c99highlighting = get_bool_opt(options,
396 'c99highlighting', True)
397 RegexLexer.__init__(self, **options)
398
399 def get_tokens_unprocessed(self, text):
400 for index, token, value in \
401 RegexLexer.get_tokens_unprocessed(self, text):
402 if token is Name:
403 if self.stdlibhighlighting and value in self.stdlib_types:
404 token = Keyword.Type
405 elif self.c99highlighting and value in self.c99_types:
406 token = Keyword.Type
407 yield index, token, value
251 408
252 409
253 class DLexer(RegexLexer): 410 class DLexer(RegexLexer):
254 """ 411 """
255 For D source. 412 For D source.
882 if scanner.match.strip(): 1039 if scanner.match.strip():
883 was_dot = scanner.match == '.' 1040 was_dot = scanner.match == '.'
884 yield scanner.start_pos, token, scanner.match or '' 1041 yield scanner.start_pos, token, scanner.match or ''
885 1042
886 1043
887 class JavaLexer(RegexLexer):
888 """
889 For `Java <http://www.sun.com/java/>`_ source code.
890 """
891
892 name = 'Java'
893 aliases = ['java']
894 filenames = ['*.java']
895 mimetypes = ['text/x-java']
896
897 flags = re.MULTILINE | re.DOTALL
898
899 #: optional Comment or Whitespace
900 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
901
902 tokens = {
903 'root': [
904 # method names
905 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
906 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
907 r'(\s*)(\()', # signature start
908 bygroups(using(this), Name.Function, Text, Operator)),
909 (r'[^\S\n]+', Text),
910 (r'//.*?\n', Comment.Single),
911 (r'/\*.*?\*/', Comment.Multiline),
912 (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
913 (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
914 r'if|goto|instanceof|new|return|switch|this|throw|try|while)\b',
915 Keyword),
916 (r'(abstract|const|enum|extends|final|implements|native|private|'
917 r'protected|public|static|strictfp|super|synchronized|throws|'
918 r'transient|volatile)\b', Keyword.Declaration),
919 (r'(boolean|byte|char|double|float|int|long|short|void)\b',
920 Keyword.Type),
921 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
922 (r'(true|false|null)\b', Keyword.Constant),
923 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'),
924 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
925 (r'"(\\\\|\\"|[^"])*"', String),
926 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
927 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
928 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
929 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
930 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
931 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
932 (r'0x[0-9a-f]+', Number.Hex),
933 (r'[0-9]+L?', Number.Integer),
934 (r'\n', Text)
935 ],
936 'class': [
937 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
938 ],
939 'import': [
940 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
941 ],
942 }
943
944
945 class ScalaLexer(RegexLexer):
946 """
947 For `Scala <http://www.scala-lang.org>`_ source code.
948 """
949
950 name = 'Scala'
951 aliases = ['scala']
952 filenames = ['*.scala']
953 mimetypes = ['text/x-scala']
954
955 flags = re.MULTILINE | re.DOTALL
956
957 #: optional Comment or Whitespace
958 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
959
960 # don't use raw unicode strings!
961 op = '[-~\\^\\*!%&\\\\<>\\|+=:/?@\u00a6-\u00a7\u00a9\u00ac\u00ae\u00b0-\u00b1\u00b6\u00d7\u00f7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+'
962
963 letter = '[a-zA-Z\\$_\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02af\u0370-\u0373\u0376-\u0377\u037b-\u037d\u0386\u0388-\u03f5\u03f7-\u0481\u048a-\u0556\u0561-\u0587\u05d0-\u05f2\u0621-\u063f\u0641-\u064a\u066e-\u066f\u0671-\u06d3\u06d5\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u0904-\u0939\u093d\u0950\u0958-\u0961\u0972-\u097f\u0985-\u09b9\u09bd\u09ce\u09dc-\u09e1\u09f0-\u09f1\u0a05-\u0a39\u0a59-\u0a5e\u0a72-\u0a74\u0a85-\u0ab9\u0abd\u0ad0-\u0ae1\u0b05-\u0b39\u0b3d\u0b5c-\u0b61\u0b71\u0b83-\u0bb9\u0bd0\u0c05-\u0c3d\u0c58-\u0c61\u0c85-\u0cb9\u0cbd\u0cde-\u0ce1\u0d05-\u0d3d\u0d60-\u0d61\u0d7a-\u0d7f\u0d85-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ec4\u0edc-\u0f00\u0f40-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10fa\u1100-\u135a\u1380-\u138f\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]'
964
965 upper = '[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]'
966
967 idrest = r'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
968
969 tokens = {
970 'root': [
971 # method names
972 (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
973 (r"'%s" % idrest, Text.Symbol),
974 (r'[^\S\n]+', Text),
975 (r'//.*?\n', Comment.Single),
976 (r'/\*', Comment.Multiline, 'comment'),
977 (r'@%s' % idrest, Name.Decorator),
978 (r'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
979 r'f(?:inal(?:ly)?|or(?:Some)?)|i(?:f|mplicit)|'
980 r'lazy|match|new|override|pr(?:ivate|otected)'
981 r'|re(?:quires|turn)|s(?:ealed|uper)|'
982 r't(?:h(?:is|row)|ry)|va[lr]|w(?:hile|ith)|yield)\b|'
983 '(<[%:-]|=>|>:|[#=@_\u21D2\u2190])(\b|(?=\\s)|$)', Keyword),
984 (r':(?!%s)' % op, Keyword, 'type'),
985 (r'%s%s\b' % (upper, idrest), Name.Class),
986 (r'(true|false|null)\b', Keyword.Constant),
987 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
988 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
989 (r'"""(?:.|\n)*?"""', String),
990 (r'"(\\\\|\\"|[^"])*"', String),
991 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char),
992 # (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
993 # Name.Attribute)),
994 (idrest, Name),
995 (r'`[^`]+`', Name),
996 (r'\[', Operator, 'typeparam'),
997 (r'[\(\)\{\};,.]', Operator),
998 (op, Operator),
999 (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
1000 Number.Float),
1001 (r'0x[0-9a-f]+', Number.Hex),
1002 (r'[0-9]+L?', Number.Integer),
1003 (r'\n', Text)
1004 ],
1005 'class': [
1006 (r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
1007 bygroups(Name.Class, Text, Operator), 'typeparam'),
1008 (r'[\s\n]+', Text),
1009 (r'{', Operator, '#pop'),
1010 (r'\(', Operator, '#pop'),
1011 (r'%s|%s|`[^`]+`' % (idrest, op), Name.Class, '#pop'),
1012 ],
1013 'type': [
1014 (r'\s+', Text),
1015 ('<[%:]|>:|[#_\u21D2]|forSome|type', Keyword),
1016 (r'([,\);}]|=>|=)([\s\n]*)', bygroups(Operator, Text), '#pop'),
1017 (r'[\(\{]', Operator, '#push'),
1018 (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)(\[)' %
1019 (idrest, op, idrest, op),
1020 bygroups(Keyword.Type, Text, Operator), ('#pop', 'typeparam')),
1021 (r'((?:%s|%s|`[^`]+`)(?:\.(?:%s|%s|`[^`]+`))*)(\s*)$' %
1022 (idrest, op, idrest, op),
1023 bygroups(Keyword.Type, Text), '#pop'),
1024 (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
1025 ],
1026 'typeparam': [
1027 (r'[\s\n,]+', Text),
1028 ('<[%:]|=>|>:|[#_\u21D2]|forSome|type', Keyword),
1029 (r'([\]\)\}])', Operator, '#pop'),
1030 (r'[\(\[\{]', Operator, '#push'),
1031 (r'\.|%s|%s|`[^`]+`' % (idrest, op), Keyword.Type)
1032 ],
1033 'comment': [
1034 (r'[^/\*]+', Comment.Multiline),
1035 (r'/\*', Comment.Multiline, '#push'),
1036 (r'\*/', Comment.Multiline, '#pop'),
1037 (r'[*/]', Comment.Multiline)
1038 ],
1039 'import': [
1040 (r'(%s|\.)+' % idrest, Name.Namespace, '#pop')
1041 ],
1042 }
1043
1044
1045 class DylanLexer(RegexLexer): 1044 class DylanLexer(RegexLexer):
1046 """ 1045 """
1047 For the `Dylan <http://www.opendylan.org/>`_ language. 1046 For the `Dylan <http://www.opendylan.org/>`_ language.
1048 1047
1049 *New in Pygments 0.7.* 1048 *New in Pygments 0.7.*
1057 flags = re.DOTALL 1056 flags = re.DOTALL
1058 1057
1059 tokens = { 1058 tokens = {
1060 'root': [ 1059 'root': [
1061 (r'\b(subclass|abstract|block|c(on(crete|stant)|lass)|domain' 1060 (r'\b(subclass|abstract|block|c(on(crete|stant)|lass)|domain'
1062 r'|ex(c(eption|lude)|port)|f(unction(|al))|generic|handler' 1061 r'|ex(c(eption|lude)|port)|f(unction(al)?)|generic|handler'
1063 r'|i(n(herited|line|stance|terface)|mport)|library|m(acro|ethod)' 1062 r'|i(n(herited|line|stance|terface)|mport)|library|m(acro|ethod)'
1064 r'|open|primary|sealed|si(deways|ngleton)|slot' 1063 r'|open|primary|sealed|si(deways|ngleton)|slot'
1065 r'|v(ariable|irtual))\b', Name.Builtin), 1064 r'|v(ariable|irtual))\b', Name.Builtin),
1066 (r'<\w+>', Keyword.Type), 1065 (r'<\w+>', Keyword.Type),
1067 (r'//.*?\n', Comment.Single), 1066 (r'//.*?\n', Comment.Single),
1068 (r'/\*[\w\W]*?\*/', Comment.Multiline), 1067 (r'/\*[\w\W]*?\*/', Comment.Multiline),
1069 (r'"', String, 'string'), 1068 (r'"', String, 'string'),
1070 (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char), 1069 (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
1071 (r'=>|\b(a(bove|fterwards)|b(e(gin|low)|y)|c(ase|leanup|reate)' 1070 (r'=>|\b(a(bove|fterwards)|b(e(gin|low)|y)|c(ase|leanup|reate)'
1072 r'|define|else(|if)|end|f(inally|or|rom)|i[fn]|l(et|ocal)|otherwise' 1071 r'|define|else(if)?|end|f(inally|or|rom)|i[fn]|l(et|ocal)|otherwise'
1073 r'|rename|s(elect|ignal)|t(hen|o)|u(n(less|til)|se)|wh(en|ile))\b', 1072 r'|rename|s(elect|ignal)|t(hen|o)|u(n(less|til)|se)|wh(en|ile))\b',
1074 Keyword), 1073 Keyword),
1075 (r'([ \t])([!\$%&\*\/:<=>\?~_^a-zA-Z0-9.+\-]*:)', 1074 (r'([ \t])([!\$%&\*\/:<=>\?~_^a-zA-Z0-9.+\-]*:)',
1076 bygroups(Text, Name.Variable)), 1075 bygroups(Text, Name.Variable)),
1077 (r'([ \t]*)(\S+[^:])([ \t]*)(\()([ \t]*)', 1076 (r'([ \t]*)(\S+[^:])([ \t]*)(\()([ \t]*)',
1079 (r'-?[0-9.]+', Number), 1078 (r'-?[0-9.]+', Number),
1080 (r'[(),;]', Punctuation), 1079 (r'[(),;]', Punctuation),
1081 (r'\$[a-zA-Z0-9-]+', Name.Constant), 1080 (r'\$[a-zA-Z0-9-]+', Name.Constant),
1082 (r'[!$%&*/:<>=?~^.+\[\]{}-]+', Operator), 1081 (r'[!$%&*/:<>=?~^.+\[\]{}-]+', Operator),
1083 (r'\s+', Text), 1082 (r'\s+', Text),
1083 (r'#"[a-zA-Z0-9-]+"', Keyword),
1084 (r'#[a-zA-Z0-9-]+', Keyword), 1084 (r'#[a-zA-Z0-9-]+', Keyword),
1085 (r'[a-zA-Z0-9-]+', Name.Variable), 1085 (r'#(\(|\[)', Punctuation),
1086 (r'[a-zA-Z0-9-_]+', Name.Variable),
1086 ], 1087 ],
1087 'string': [ 1088 'string': [
1088 (r'"', String, '#pop'), 1089 (r'"', String, '#pop'),
1089 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), 1090 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1090 (r'[^\\"\n]+', String), # all other characters 1091 (r'[^\\"\n]+', String), # all other characters
1157 r'(\s*\([^;]*?\))' # signature 1158 r'(\s*\([^;]*?\))' # signature
1158 r'(' + _ws + r')({)', 1159 r'(' + _ws + r')({)',
1159 bygroups(using(this), Name.Function, 1160 bygroups(using(this), Name.Function,
1160 using(this), Text, Punctuation), 1161 using(this), Text, Punctuation),
1161 'function'), 1162 'function'),
1163 # methods
1164 (r'^([-+])(\s*)' # method marker
1165 r'(\(.*?\))?(\s*)' # return type
1166 r'([a-zA-Z$_][a-zA-Z0-9$_]*:?)', # begin of method name
1167 bygroups(Keyword, Text, using(this),
1168 Text, Name.Function),
1169 'method'),
1162 # function declarations 1170 # function declarations
1163 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments 1171 (r'((?:[a-zA-Z0-9_*\s])+?(?:\s|[*]))' # return arguments
1164 r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name 1172 r'([a-zA-Z$_][a-zA-Z0-9$_]*)' # method name
1165 r'(\s*\([^;]*?\))' # signature 1173 r'(\s*\([^;]*?\))' # signature
1166 r'(' + _ws + r')(;)', 1174 r'(' + _ws + r')(;)',
1200 include('statements'), 1208 include('statements'),
1201 (';', Punctuation), 1209 (';', Punctuation),
1202 ('{', Punctuation, '#push'), 1210 ('{', Punctuation, '#push'),
1203 ('}', Punctuation, '#pop'), 1211 ('}', Punctuation, '#pop'),
1204 ], 1212 ],
1213 'method': [
1214 include('whitespace'),
1215 (r'(\(.*?\))([a-zA-Z$_][a-zA-Z0-9$_]*)', bygroups(using(this),
1216 Name.Variable)),
1217 (r'[a-zA-Z$_][a-zA-Z0-9$_]*:', Name.Function),
1218 (';', Punctuation, '#pop'),
1219 ('{', Punctuation, 'function'),
1220 ('', Text, '#pop'),
1221 ],
1205 'string': [ 1222 'string': [
1206 (r'"', String, '#pop'), 1223 (r'"', String, '#pop'),
1207 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), 1224 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
1208 (r'[^\\"\n]+', String), # all other characters 1225 (r'[^\\"\n]+', String), # all other characters
1209 (r'\\\n', String), # line continuation 1226 (r'\\\n', String), # line continuation
1223 (r'.*?\n', Comment), 1240 (r'.*?\n', Comment),
1224 ] 1241 ]
1225 } 1242 }
1226 1243
1227 def analyse_text(text): 1244 def analyse_text(text):
1228 if '@"' in text: # strings 1245 if '@import' in text or '@interface' in text or \
1246 '@implementation' in text:
1229 return True 1247 return True
1230 if re.match(r'\[[a-zA-Z0-9.]:', text): # message 1248 elif '@"' in text: # strings
1249 return True
1250 elif re.match(r'\[[a-zA-Z0-9.]:', text): # message
1231 return True 1251 return True
1232 return False 1252 return False
1233 1253
1254
1234 class FortranLexer(RegexLexer): 1255 class FortranLexer(RegexLexer):
1235 ''' 1256 """
1236 Lexer for FORTRAN 90 code. 1257 Lexer for FORTRAN 90 code.
1237 1258
1238 *New in Pygments 0.10.* 1259 *New in Pygments 0.10.*
1239 ''' 1260 """
1240 name = 'Fortran' 1261 name = 'Fortran'
1241 aliases = ['fortran'] 1262 aliases = ['fortran']
1242 filenames = ['*.f', '*.f90'] 1263 filenames = ['*.f', '*.f90', '*.F', '*.F90']
1243 mimetypes = ['text/x-fortran'] 1264 mimetypes = ['text/x-fortran']
1244 flags = re.IGNORECASE 1265 flags = re.IGNORECASE
1245 1266
1246 # Data Types: INTEGER, REAL, COMPLEX, LOGICAL, CHARACTER and DOUBLE PRECISION 1267 # Data Types: INTEGER, REAL, COMPLEX, LOGICAL, CHARACTER and DOUBLE PRECISION
1247 # Operators: **, *, +, -, /, <, >, <=, >=, ==, /= 1268 # Operators: **, *, +, -, /, <, >, <=, >=, ==, /=
1259 include('nums'), 1280 include('nums'),
1260 (r'[\s]+', Text), 1281 (r'[\s]+', Text),
1261 ], 1282 ],
1262 'core': [ 1283 'core': [
1263 # Statements 1284 # Statements
1264 (r'\b(ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|BACKSPACE|BLOCK DATA|' 1285 (r'\b(ACCEPT|ALLOCATABLE|ALLOCATE|ARRAY|ASSIGN|ASYNCHRONOUS|'
1265 r'BYTE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|' 1286 r'BACKSPACE|BIND|BLOCK DATA|BYTE|CALL|CASE|CLOSE|COMMON|CONTAINS|'
1266 r'DEALLOCATE|DECODE|DIMENSION|DO|ENCODE|END FILE|ENDIF|END|ENTRY|' 1287 r'CONTINUE|CYCLE|DATA|DEALLOCATE|DECODE|DEFERRED|DIMENSION|DO|'
1267 r'EQUIVALENCE|EXIT|EXTERNAL|EXTRINSIC|FORALL|FORMAT|FUNCTION|GOTO|' 1288 r'ELSE|ENCODE|END FILE|ENDIF|END|ENTRY|ENUMERATOR|EQUIVALENCE|'
1268 r'IF|IMPLICIT|INCLUDE|INQUIRE|INTENT|INTERFACE|INTRINSIC|MODULE|' 1289 r'EXIT|EXTERNAL|EXTRINSIC|FINAL|FORALL|FORMAT|FUNCTION|GENERIC|'
1269 r'NAMELIST|NULLIFY|NONE|OPEN|OPTIONAL|OPTIONS|PARAMETER|PAUSE|' 1290 r'GOTO|IF|IMPLICIT|IMPORT|INCLUDE|INQUIRE|INTENT|INTERFACE|'
1270 r'POINTER|PRINT|PRIVATE|PROGRAM|PUBLIC|PURE|READ|RECURSIVE|RETURN|' 1291 r'INTRINSIC|MODULE|NAMELIST|NULLIFY|NONE|NON_INTRINSIC|'
1271 r'REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|TARGET|TYPE|USE|' 1292 r'NON_OVERRIDABLE|NOPASS|OPEN|OPTIONAL|OPTIONS|PARAMETER|PASS|'
1272 r'VOLATILE|WHERE|WRITE|WHILE|THEN|ELSE|ENDIF)\s*\b', 1293 r'PAUSE|POINTER|PRINT|PRIVATE|PROGRAM|PROTECTED|PUBLIC|PURE|READ|'
1294 r'RECURSIVE|RETURN|REWIND|SAVE|SELECT|SEQUENCE|STOP|SUBROUTINE|'
1295 r'TARGET|THEN|TYPE|USE|VALUE|VOLATILE|WHERE|WRITE|WHILE)\s*\b',
1273 Keyword), 1296 Keyword),
1274 1297
1275 # Data Types 1298 # Data Types
1276 (r'\b(CHARACTER|COMPLEX|DOUBLE PRECISION|DOUBLE COMPLEX|INTEGER|' 1299 (r'\b(CHARACTER|COMPLEX|DOUBLE PRECISION|DOUBLE COMPLEX|INTEGER|'
1277 r'LOGICAL|REAL)\s*\b', 1300 r'LOGICAL|REAL|C_INT|C_SHORT|C_LONG|C_LONG_LONG|C_SIGNED_CHAR|'
1301 r'C_SIZE_T|C_INT8_T|C_INT16_T|C_INT32_T|C_INT64_T|C_INT_LEAST8_T|'
1302 r'C_INT_LEAST16_T|C_INT_LEAST32_T|C_INT_LEAST64_T|C_INT_FAST8_T|'
1303 r'C_INT_FAST16_T|C_INT_FAST32_T|C_INT_FAST64_T|C_INTMAX_T|'
1304 r'C_INTPTR_T|C_FLOAT|C_DOUBLE|C_LONG_DOUBLE|C_FLOAT_COMPLEX|'
1305 r'C_DOUBLE_COMPLEX|C_LONG_DOUBLE_COMPLEX|C_BOOL|C_CHAR|C_PTR|'
1306 r'C_FUNPTR)\s*\b',
1278 Keyword.Type), 1307 Keyword.Type),
1279 1308
1280 # Operators 1309 # Operators
1281 (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)', Operator), 1310 (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)', Operator),
1282 1311
1284 1313
1285 (r'[(),:&%;]', Punctuation), 1314 (r'[(),:&%;]', Punctuation),
1286 1315
1287 # Intrinsics 1316 # Intrinsics
1288 (r'\b(Abort|Abs|Access|AChar|ACos|AdjustL|AdjustR|AImag|AInt|Alarm|' 1317 (r'\b(Abort|Abs|Access|AChar|ACos|AdjustL|AdjustR|AImag|AInt|Alarm|'
1289 r'All|Allocated|ALog|AMax|AMin|AMod|And|ANInt|Any|' 1318 r'All|Allocated|ALog|AMax|AMin|AMod|And|ANInt|Any|ASin|Associated|'
1290 r'ASin|Associated|ATan|BesJ|BesJN|BesY|BesYN|' 1319 r'ATan|BesJ|BesJN|BesY|BesYN|Bit_Size|BTest|CAbs|CCos|Ceiling|'
1291 r'Bit_Size|BTest|CAbs|CCos|Ceiling|CExp|Char|ChDir|ChMod|CLog|' 1320 r'CExp|Char|ChDir|ChMod|CLog|Cmplx|Command_Argument_Count|Complex|'
1292 r'Cmplx|Complex|Conjg|Cos|CosH|Count|CPU_Time|CShift|CSin|CSqRt|' 1321 r'Conjg|Cos|CosH|Count|CPU_Time|CShift|CSin|CSqRt|CTime|C_Funloc|'
1293 r'CTime|DAbs|DACos|DASin|DATan|Date_and_Time|DbesJ|' 1322 r'C_Loc|C_Associated|C_Null_Ptr|C_Null_Funptr|C_F_Pointer|'
1323 r'C_Null_Char|C_Alert|C_Backspace|C_Form_Feed|C_New_Line|'
1324 r'C_Carriage_Return|C_Horizontal_Tab|C_Vertical_Tab|'
1325 r'DAbs|DACos|DASin|DATan|Date_and_Time|DbesJ|'
1294 r'DbesJ|DbesJN|DbesY|DbesY|DbesYN|Dble|DCos|DCosH|DDiM|DErF|DErFC|' 1326 r'DbesJ|DbesJN|DbesY|DbesY|DbesYN|Dble|DCos|DCosH|DDiM|DErF|DErFC|'
1295 r'DExp|Digits|DiM|DInt|DLog|DLog|DMax|DMin|DMod|DNInt|Dot_Product|' 1327 r'DExp|Digits|DiM|DInt|DLog|DLog|DMax|DMin|DMod|DNInt|Dot_Product|'
1296 r'DProd|DSign|DSinH|DSin|DSqRt|DTanH|DTan|DTime|EOShift|Epsilon|' 1328 r'DProd|DSign|DSinH|DSin|DSqRt|DTanH|DTan|DTime|EOShift|Epsilon|'
1297 r'ErF|ErFC|ETime|Exit|Exp|Exponent|FDate|FGet|FGetC|Float|' 1329 r'ErF|ErFC|ETime|Exit|Exp|Exponent|Extends_Type_Of|FDate|FGet|'
1298 r'Floor|Flush|FNum|FPutC|FPut|Fraction|FSeek|FStat|FTell|' 1330 r'FGetC|Float|Floor|Flush|FNum|FPutC|FPut|Fraction|FSeek|FStat|'
1299 r'GError|GetArg|GetCWD|GetEnv|GetGId|GetLog|GetPId|GetUId|' 1331 r'FTell|GError|GetArg|Get_Command|Get_Command_Argument|'
1300 r'GMTime|HostNm|Huge|IAbs|IAChar|IAnd|IArgC|IBClr|IBits|' 1332 r'Get_Environment_Variable|GetCWD|GetEnv|GetGId|GetLog|GetPId|'
1333 r'GetUId|GMTime|HostNm|Huge|IAbs|IAChar|IAnd|IArgC|IBClr|IBits|'
1301 r'IBSet|IChar|IDate|IDiM|IDInt|IDNInt|IEOr|IErrNo|IFix|Imag|' 1334 r'IBSet|IChar|IDate|IDiM|IDInt|IDNInt|IEOr|IErrNo|IFix|Imag|'
1302 r'ImagPart|Index|Int|IOr|IRand|IsaTty|IShft|IShftC|ISign|' 1335 r'ImagPart|Index|Int|IOr|IRand|IsaTty|IShft|IShftC|ISign|'
1303 r'ITime|Kill|Kind|LBound|Len|Len_Trim|LGe|LGt|Link|LLe|LLt|LnBlnk|' 1336 r'Iso_C_Binding|Is_Iostat_End|Is_Iostat_Eor|ITime|Kill|Kind|'
1304 r'Loc|Log|Log|Logical|Long|LShift|LStat|LTime|MatMul|Max|' 1337 r'LBound|Len|Len_Trim|LGe|LGt|Link|LLe|LLt|LnBlnk|Loc|Log|'
1305 r'MaxExponent|MaxLoc|MaxVal|MClock|Merge|Min|MinExponent|MinLoc|' 1338 r'Logical|Long|LShift|LStat|LTime|MatMul|Max|MaxExponent|MaxLoc|'
1306 r'MinVal|Mod|Modulo|MvBits|Nearest|NInt|Not|Or|Pack|PError|' 1339 r'MaxVal|MClock|Merge|Move_Alloc|Min|MinExponent|MinLoc|MinVal|'
1340 r'Mod|Modulo|MvBits|Nearest|New_Line|NInt|Not|Or|Pack|PError|'
1307 r'Precision|Present|Product|Radix|Rand|Random_Number|Random_Seed|' 1341 r'Precision|Present|Product|Radix|Rand|Random_Number|Random_Seed|'
1308 r'Range|Real|RealPart|Rename|Repeat|Reshape|RRSpacing|RShift|Scale|' 1342 r'Range|Real|RealPart|Rename|Repeat|Reshape|RRSpacing|RShift|'
1309 r'Scan|Second|Selected_Int_Kind|Selected_Real_Kind|Set_Exponent|' 1343 r'Same_Type_As|Scale|Scan|Second|Selected_Int_Kind|'
1310 r'Shape|Short|Sign|Signal|SinH|Sin|Sleep|Sngl|Spacing|Spread|SqRt|' 1344 r'Selected_Real_Kind|Set_Exponent|Shape|Short|Sign|Signal|SinH|'
1311 r'SRand|Stat|Sum|SymLnk|System|System_Clock|Tan|TanH|Time|' 1345 r'Sin|Sleep|Sngl|Spacing|Spread|SqRt|SRand|Stat|Sum|SymLnk|'
1312 r'Tiny|Transfer|Transpose|Trim|TtyNam|UBound|UMask|Unlink|Unpack|' 1346 r'System|System_Clock|Tan|TanH|Time|Tiny|Transfer|Transpose|Trim|'
1313 r'Verify|XOr|ZAbs|ZCos|ZExp|ZLog|ZSin|ZSqRt)\s*\b', 1347 r'TtyNam|UBound|UMask|Unlink|Unpack|Verify|XOr|ZAbs|ZCos|ZExp|'
1348 r'ZLog|ZSin|ZSqRt)\s*\b',
1314 Name.Builtin), 1349 Name.Builtin),
1315 1350
1316 # Booleans 1351 # Booleans
1317 (r'\.(true|false)\.', Name.Builtin), 1352 (r'\.(true|false)\.', Name.Builtin),
1318 # Comparing Operators 1353 # Comparing Operators
2127 (r'"[^"]*"', String), 2162 (r'"[^"]*"', String),
2128 include('attribute'), 2163 include('attribute'),
2129 include('numbers'), 2164 include('numbers'),
2130 (r"'[^']'", String.Character), 2165 (r"'[^']'", String.Character),
2131 (r'([a-z0-9_]+)(\s*|[(,])', bygroups(Name, using(this))), 2166 (r'([a-z0-9_]+)(\s*|[(,])', bygroups(Name, using(this))),
2132 (r"(<>|=>|:=|[\(\)\|:;,.'])", Punctuation), 2167 (r"(<>|=>|:=|[()|:;,.'])", Punctuation),
2133 (r'[*<>+=/&-]', Operator), 2168 (r'[*<>+=/&-]', Operator),
2134 (r'\n+', Text), 2169 (r'\n+', Text),
2135 ], 2170 ],
2136 'numbers' : [ 2171 'numbers' : [
2137 (r'[0-9_]+#[0-9a-f]+#', Number.Hex), 2172 (r'[0-9_]+#[0-9a-f]+#', Number.Hex),
2148 (r'"[^"]+"|[a-z0-9_]+', Name.Function), 2183 (r'"[^"]+"|[a-z0-9_]+', Name.Function),
2149 include('root'), 2184 include('root'),
2150 ], 2185 ],
2151 'end' : [ 2186 'end' : [
2152 ('(if|case|record|loop|select)', Keyword.Reserved), 2187 ('(if|case|record|loop|select)', Keyword.Reserved),
2153 ('"[^"]+"|[a-zA-Z0-9_]+', Name.Function), 2188 ('"[^"]+"|[a-zA-Z0-9_.]+', Name.Function),
2154 ('[\n\s]+', Text), 2189 ('\s+', Text),
2155 (';', Punctuation, '#pop'), 2190 (';', Punctuation, '#pop'),
2156 ], 2191 ],
2157 'type_def': [ 2192 'type_def': [
2158 (r';', Punctuation, '#pop'), 2193 (r';', Punctuation, '#pop'),
2159 (r'\(', Punctuation, 'formal_part'), 2194 (r'\(', Punctuation, 'formal_part'),
2168 Keyword.Reserved)), 2203 Keyword.Reserved)),
2169 include('root'), 2204 include('root'),
2170 ], 2205 ],
2171 'import': [ 2206 'import': [
2172 (r'[a-z0-9_.]+', Name.Namespace, '#pop'), 2207 (r'[a-z0-9_.]+', Name.Namespace, '#pop'),
2208 (r'', Text, '#pop'),
2173 ], 2209 ],
2174 'formal_part' : [ 2210 'formal_part' : [
2175 (r'\)', Punctuation, '#pop'), 2211 (r'\)', Punctuation, '#pop'),
2176 (r'([a-z0-9_]+)(\s*)(,|:[^=])', bygroups(Name.Variable, 2212 (r'[a-z0-9_]+', Name.Variable),
2177 Text, Punctuation)), 2213 (r',|:[^=]', Punctuation),
2178 (r'(in|not|null|out|access)\b', Keyword.Reserved), 2214 (r'(in|not|null|out|access)\b', Keyword.Reserved),
2179 include('root'), 2215 include('root'),
2180 ], 2216 ],
2181 'package': [ 2217 'package': [
2182 ('body', Keyword.Declaration), 2218 ('body', Keyword.Declaration),
2478 (r'""', String.Double), 2514 (r'""', String.Double),
2479 (r'"C?', String.Double, '#pop'), 2515 (r'"C?', String.Double, '#pop'),
2480 (r'[^"]+', String.Double), 2516 (r'[^"]+', String.Double),
2481 ], 2517 ],
2482 } 2518 }
2519
2520
2521 class NimrodLexer(RegexLexer):
2522 """
2523 For `Nimrod <http://nimrod-code.org/>`_ source code.
2524
2525 *New in Pygments 1.5.*
2526 """
2527
2528 name = 'Nimrod'
2529 aliases = ['nimrod', 'nim']
2530 filenames = ['*.nim', '*.nimrod']
2531 mimetypes = ['text/x-nimrod']
2532
2533 flags = re.MULTILINE | re.IGNORECASE | re.UNICODE
2534
2535 def underscorize(words):
2536 newWords = []
2537 new = ""
2538 for word in words:
2539 for ch in word:
2540 new += (ch + "_?")
2541 newWords.append(new)
2542 new = ""
2543 return "|".join(newWords)
2544
2545 keywords = [
2546 'addr', 'and', 'as', 'asm', 'atomic', 'bind', 'block', 'break',
2547 'case', 'cast', 'const', 'continue', 'converter', 'discard',
2548 'distinct', 'div', 'elif', 'else', 'end', 'enum', 'except', 'finally',
2549 'for', 'generic', 'if', 'implies', 'in', 'yield',
2550 'is', 'isnot', 'iterator', 'lambda', 'let', 'macro', 'method',
2551 'mod', 'not', 'notin', 'object', 'of', 'or', 'out', 'proc',
2552 'ptr', 'raise', 'ref', 'return', 'shl', 'shr', 'template', 'try',
2553 'tuple', 'type' , 'when', 'while', 'with', 'without', 'xor'
2554 ]
2555
2556 keywordsPseudo = [
2557 'nil', 'true', 'false'
2558 ]
2559
2560 opWords = [
2561 'and', 'or', 'not', 'xor', 'shl', 'shr', 'div', 'mod', 'in',
2562 'notin', 'is', 'isnot'
2563 ]
2564
2565 types = [
2566 'int', 'int8', 'int16', 'int32', 'int64', 'float', 'float32', 'float64',
2567 'bool', 'char', 'range', 'array', 'seq', 'set', 'string'
2568 ]
2569
2570 tokens = {
2571 'root': [
2572 (r'##.*$', String.Doc),
2573 (r'#.*$', Comment),
2574 (r'\*|=|>|<|\+|-|/|@|\$|~|&|%|\!|\?|\||\\|\[|\]', Operator),
2575 (r'\.\.|\.|,|\[\.|\.\]|{\.|\.}|\(\.|\.\)|{|}|\(|\)|:|\^|`|;',
2576 Punctuation),
2577
2578 # Strings
2579 (r'(?:[\w]+)"', String, 'rdqs'),
2580 (r'"""', String, 'tdqs'),
2581 ('"', String, 'dqs'),
2582
2583 # Char
2584 ("'", String.Char, 'chars'),
2585
2586 # Keywords
2587 (r'(%s)\b' % underscorize(opWords), Operator.Word),
2588 (r'(p_?r_?o_?c_?\s)(?![\(\[\]])', Keyword, 'funcname'),
2589 (r'(%s)\b' % underscorize(keywords), Keyword),
2590 (r'(%s)\b' % underscorize(['from', 'import', 'include']),
2591 Keyword.Namespace),
2592 (r'(v_?a_?r)\b', Keyword.Declaration),
2593 (r'(%s)\b' % underscorize(types), Keyword.Type),
2594 (r'(%s)\b' % underscorize(keywordsPseudo), Keyword.Pseudo),
2595 # Identifiers
2596 (r'\b((?![_\d])\w)(((?!_)\w)|(_(?!_)\w))*', Name),
2597 # Numbers
2598 (r'[0-9][0-9_]*(?=([eE.]|\'[fF](32|64)))',
2599 Number.Float, ('float-suffix', 'float-number')),
2600 (r'0[xX][a-fA-F0-9][a-fA-F0-9_]*', Number.Hex, 'int-suffix'),
2601 (r'0[bB][01][01_]*', Number, 'int-suffix'),
2602 (r'0o[0-7][0-7_]*', Number.Oct, 'int-suffix'),
2603 (r'[0-9][0-9_]*', Number.Integer, 'int-suffix'),
2604 # Whitespace
2605 (r'\s+', Text),
2606 (r'.+$', Error),
2607 ],
2608 'chars': [
2609 (r'\\([\\abcefnrtvl"\']|x[a-fA-F0-9]{2}|[0-9]{1,3})', String.Escape),
2610 (r"'", String.Char, '#pop'),
2611 (r".", String.Char)
2612 ],
2613 'strings': [
2614 (r'(?<!\$)\$(\d+|#|\w+)+', String.Interpol),
2615 (r'[^\\\'"\$\n]+', String),
2616 # quotes, dollars and backslashes must be parsed one at a time
2617 (r'[\'"\\]', String),
2618 # unhandled string formatting sign
2619 (r'\$', String)
2620 # newlines are an error (use "nl" state)
2621 ],
2622 'dqs': [
2623 (r'\\([\\abcefnrtvl"\']|\n|x[a-fA-F0-9]{2}|[0-9]{1,3})',
2624 String.Escape),
2625 (r'"', String, '#pop'),
2626 include('strings')
2627 ],
2628 'rdqs': [
2629 (r'"(?!")', String, '#pop'),
2630 (r'""', String.Escape),
2631 include('strings')
2632 ],
2633 'tdqs': [
2634 (r'"""(?!")', String, '#pop'),
2635 include('strings'),
2636 include('nl')
2637 ],
2638 'funcname': [
2639 (r'((?![\d_])\w)(((?!_)\w)|(_(?!_)\w))*', Name.Function, '#pop'),
2640 (r'`.+`', Name.Function, '#pop')
2641 ],
2642 'nl': [
2643 (r'\n', String)
2644 ],
2645 'float-number': [
2646 (r'\.(?!\.)[0-9_]*', Number.Float),
2647 (r'[eE][+-]?[0-9][0-9_]*', Number.Float),
2648 (r'', Text, '#pop')
2649 ],
2650 'float-suffix': [
2651 (r'\'[fF](32|64)', Number.Float),
2652 (r'', Text, '#pop')
2653 ],
2654 'int-suffix': [
2655 (r'\'[iI](32|64)', Number.Integer.Long),
2656 (r'\'[iI](8|16)', Number.Integer),
2657 (r'', Text, '#pop')
2658 ],
2659 }
2660
2661
2662 class FantomLexer(RegexLexer):
2663 """
2664 For Fantom source code.
2665
2666 *New in Pygments 1.5.*
2667 """
2668 name = 'Fantom'
2669 aliases = ['fan']
2670 filenames = ['*.fan']
2671 mimetypes = ['application/x-fantom']
2672
2673 # often used regexes
2674 def s(str):
2675 return Template(str).substitute(
2676 dict (
2677 pod = r'[\"\w\.]+',
2678 eos = r'\n|;',
2679 id = r'[a-zA-Z_][a-zA-Z0-9_]*',
2680 # all chars which can be part of type definition. Starts with
2681 # either letter, or [ (maps), or | (funcs)
2682 type = r'(?:\[|[a-zA-Z_]|\|)[:\w\[\]\|\->\?]*?',
2683 )
2684 )
2685
2686
2687 tokens = {
2688 'comments': [
2689 (r'(?s)/\*.*?\*/', Comment.Multiline), #Multiline
2690 (r'//.*?\n', Comment.Single), #Single line
2691 #todo: highlight references in fandocs
2692 (r'\*\*.*?\n', Comment.Special), #Fandoc
2693 (r'#.*\n', Comment.Single) #Shell-style
2694 ],
2695 'literals': [
2696 (r'\b-?[\d_]+(ns|ms|sec|min|hr|day)', Number), #Duration
2697 (r'\b-?[\d_]*\.[\d_]+(ns|ms|sec|min|hr|day)', Number),
2698 #Duration with dot
2699 (r'\b-?(\d+)?\.\d+(f|F|d|D)?', Number.Float), #Float/Decimal
2700 (r'\b-?0x[0-9a-fA-F_]+', Number.Hex), #Hex
2701 (r'\b-?[\d_]+', Number.Integer), #Int
2702 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), #Char
2703 (r'"', Punctuation, 'insideStr'), #Opening quote
2704 (r'`', Punctuation, 'insideUri'), #Opening accent
2705 (r'\b(true|false|null)\b', Keyword.Constant), #Bool & null
2706 (r'(?:(\w+)(::))?(\w+)(<\|)(.*?)(\|>)', #DSL
2707 bygroups(Name.Namespace, Punctuation, Name.Class,
2708 Punctuation, String, Punctuation)),
2709 (r'(?:(\w+)(::))?(\w+)?(#)(\w+)?', #Type/slot literal
2710 bygroups(Name.Namespace, Punctuation, Name.Class,
2711 Punctuation, Name.Function)),
2712 (r'\[,\]', Literal), # Empty list
2713 (s(r'($type)(\[,\])'), # Typed empty list
2714 bygroups(using(this, state = 'inType'), Literal)),
2715 (r'\[:\]', Literal), # Empty Map
2716 (s(r'($type)(\[:\])'),
2717 bygroups(using(this, state = 'inType'), Literal)),
2718 ],
2719 'insideStr': [
2720 (r'\\\\', String.Escape), #Escaped backslash
2721 (r'\\"', String.Escape), #Escaped "
2722 (r'\\`', String.Escape), #Escaped `
2723 (r'\$\w+', String.Interpol), #Subst var
2724 (r'\${.*?}', String.Interpol), #Subst expr
2725 (r'"', Punctuation, '#pop'), #Closing quot
2726 (r'.', String) #String content
2727 ],
2728 'insideUri': [ #TODO: remove copy/paste str/uri
2729 (r'\\\\', String.Escape), #Escaped backslash
2730 (r'\\"', String.Escape), #Escaped "
2731 (r'\\`', String.Escape), #Escaped `
2732 (r'\$\w+', String.Interpol), #Subst var
2733 (r'\${.*?}', String.Interpol), #Subst expr
2734 (r'`', Punctuation, '#pop'), #Closing tick
2735 (r'.', String.Backtick) #URI content
2736 ],
2737 'protectionKeywords': [
2738 (r'\b(public|protected|private|internal)\b', Keyword),
2739 ],
2740 'typeKeywords': [
2741 (r'\b(abstract|final|const|native|facet|enum)\b', Keyword),
2742 ],
2743 'methodKeywords': [
2744 (r'\b(abstract|native|once|override|static|virtual|final)\b',
2745 Keyword),
2746 ],
2747 'fieldKeywords': [
2748 (r'\b(abstract|const|final|native|override|static|virtual|'
2749 r'readonly)\b', Keyword)
2750 ],
2751 'otherKeywords': [
2752 (r'\b(try|catch|throw|finally|for|if|else|while|as|is|isnot|'
2753 r'switch|case|default|continue|break|do|return|get|set)\b',
2754 Keyword),
2755 (r'\b(it|this|super)\b', Name.Builtin.Pseudo),
2756 ],
2757 'operators': [
2758 (r'\+\+|\-\-|\+|\-|\*|/|\|\||&&|<=>|<=|<|>=|>|=|!|\[|\]', Operator)
2759 ],
2760 'inType': [
2761 (r'[\[\]\|\->:\?]', Punctuation),
2762 (s(r'$id'), Name.Class),
2763 (r'', Text, '#pop'),
2764
2765 ],
2766 'root': [
2767 include('comments'),
2768 include('protectionKeywords'),
2769 include('typeKeywords'),
2770 include('methodKeywords'),
2771 include('fieldKeywords'),
2772 include('literals'),
2773 include('otherKeywords'),
2774 include('operators'),
2775 (r'using\b', Keyword.Namespace, 'using'), # Using stmt
2776 (r'@\w+', Name.Decorator, 'facet'), # Symbol
2777 (r'(class|mixin)(\s+)(\w+)', bygroups(Keyword, Text, Name.Class),
2778 'inheritance'), # Inheritance list
2779
2780
2781 ### Type var := val
2782 (s(r'($type)([ \t]+)($id)(\s*)(:=)'),
2783 bygroups(using(this, state = 'inType'), Text,
2784 Name.Variable, Text, Operator)),
2785
2786 ### var := val
2787 (s(r'($id)(\s*)(:=)'),
2788 bygroups(Name.Variable, Text, Operator)),
2789
2790 ### .someId( or ->someId( ###
2791 (s(r'(\.|(?:\->))($id)(\s*)(\()'),
2792 bygroups(Operator, Name.Function, Text, Punctuation),
2793 'insideParen'),
2794
2795 ### .someId or ->someId
2796 (s(r'(\.|(?:\->))($id)'),
2797 bygroups(Operator, Name.Function)),
2798
2799 ### new makeXXX ( ####
2800 (r'(new)(\s+)(make\w*)(\s*)(\()',
2801 bygroups(Keyword, Text, Name.Function, Text, Punctuation),
2802 'insideMethodDeclArgs'),
2803
2804 ### Type name ( ####
2805 (s(r'($type)([ \t]+)' #Return type and whitespace
2806 r'($id)(\s*)(\()'), #method name + open brace
2807 bygroups(using(this, state = 'inType'), Text,
2808 Name.Function, Text, Punctuation),
2809 'insideMethodDeclArgs'),
2810
2811 ### ArgType argName, #####
2812 (s(r'($type)(\s+)($id)(\s*)(,)'),
2813 bygroups(using(this, state='inType'), Text, Name.Variable,
2814 Text, Punctuation)),
2815
2816 #### ArgType argName) ####
2817 ## Covered in 'insideParen' state
2818
2819 ### ArgType argName -> ArgType| ###
2820 (s(r'($type)(\s+)($id)(\s*)(\->)(\s*)($type)(\|)'),
2821 bygroups(using(this, state='inType'), Text, Name.Variable,
2822 Text, Punctuation, Text, using(this, state = 'inType'),
2823 Punctuation)),
2824
2825 ### ArgType argName| ###
2826 (s(r'($type)(\s+)($id)(\s*)(\|)'),
2827 bygroups(using(this, state='inType'), Text, Name.Variable,
2828 Text, Punctuation)),
2829
2830 ### Type var
2831 (s(r'($type)([ \t]+)($id)'),
2832 bygroups(using(this, state='inType'), Text,
2833 Name.Variable)),
2834
2835 (r'\(', Punctuation, 'insideParen'),
2836 (r'\{', Punctuation, 'insideBrace'),
2837 (r'.', Text)
2838 ],
2839 'insideParen': [
2840 (r'\)', Punctuation, '#pop'),
2841 include('root'),
2842 ],
2843 'insideMethodDeclArgs': [
2844 (r'\)', Punctuation, '#pop'),
2845 (s(r'($type)(\s+)($id)(\s*)(\))'),
2846 bygroups(using(this, state='inType'), Text, Name.Variable,
2847 Text, Punctuation), '#pop'),
2848 include('root'),
2849 ],
2850 'insideBrace': [
2851 (r'\}', Punctuation, '#pop'),
2852 include('root'),
2853 ],
2854 'inheritance': [
2855 (r'\s+', Text), #Whitespace
2856 (r':|,', Punctuation),
2857 (r'(?:(\w+)(::))?(\w+)',
2858 bygroups(Name.Namespace, Punctuation, Name.Class)),
2859 (r'{', Punctuation, '#pop')
2860 ],
2861 'using': [
2862 (r'[ \t]+', Text), # consume whitespaces
2863 (r'(\[)(\w+)(\])',
2864 bygroups(Punctuation, Comment.Special, Punctuation)), #ffi
2865 (r'(\")?([\w\.]+)(\")?',
2866 bygroups(Punctuation, Name.Namespace, Punctuation)), #podname
2867 (r'::', Punctuation, 'usingClass'),
2868 (r'', Text, '#pop')
2869 ],
2870 'usingClass': [
2871 (r'[ \t]+', Text), # consume whitespaces
2872 (r'(as)(\s+)(\w+)',
2873 bygroups(Keyword.Declaration, Text, Name.Class), '#pop:2'),
2874 (r'[\w\$]+', Name.Class),
2875 (r'', Text, '#pop:2') # jump out to root state
2876 ],
2877 'facet': [
2878 (r'\s+', Text),
2879 (r'{', Punctuation, 'facetFields'),
2880 (r'', Text, '#pop')
2881 ],
2882 'facetFields': [
2883 include('comments'),
2884 include('literals'),
2885 include('operators'),
2886 (r'\s+', Text),
2887 (r'(\s*)(\w+)(\s*)(=)', bygroups(Text, Name, Text, Operator)),
2888 (r'}', Punctuation, '#pop'),
2889 (r'.', Text)
2890 ],
2891 }

eric ide

mercurial