|
1 # -*- coding: utf-8 -*- |
|
2 """ |
|
3 pygments.lexers.x10 |
|
4 ~~~~~~~~~~~~~~~~~~~ |
|
5 |
|
6 Lexers for the X10 programming language. |
|
7 |
|
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. |
|
9 :license: BSD, see LICENSE for details. |
|
10 """ |
|
11 |
|
12 import re |
|
13 |
|
14 from pygments.lexer import RegexLexer |
|
15 from pygments.token import Text, Comment, Operator, Keyword, Name, String, \ |
|
16 Number, Punctuation, Error |
|
17 |
|
18 __all__ = ['X10Lexer'] |
|
19 |
|
20 class X10Lexer(RegexLexer): |
|
21 """ |
|
22 For the X10 language. |
|
23 |
|
24 .. versionadded:: 0.1 |
|
25 """ |
|
26 |
|
27 name = 'X10' |
|
28 aliases = ['x10', 'xten'] |
|
29 filenames = ['*.x10'] |
|
30 mimetypes = ['text/x-x10'] |
|
31 |
|
32 keywords = ( |
|
33 'as', 'assert', 'async', 'at', 'athome', 'ateach', 'atomic', |
|
34 'break', 'case', 'catch', 'class', 'clocked', 'continue', |
|
35 'def', 'default', 'do', 'else', 'final', 'finally', 'finish', |
|
36 'for', 'goto', 'haszero', 'here', 'if', 'import', 'in', |
|
37 'instanceof', 'interface', 'isref', 'new', 'offer', |
|
38 'operator', 'package', 'return', 'struct', 'switch', 'throw', |
|
39 'try', 'type', 'val', 'var', 'when', 'while' |
|
40 ) |
|
41 |
|
42 types = ( |
|
43 'void' |
|
44 ) |
|
45 |
|
46 values = ( |
|
47 'false', 'null', 'self', 'super', 'this', 'true' |
|
48 ) |
|
49 |
|
50 modifiers = ( |
|
51 'abstract', 'extends', 'implements', 'native', 'offers', |
|
52 'private', 'property', 'protected', 'public', 'static', |
|
53 'throws', 'transient' |
|
54 ) |
|
55 |
|
56 tokens = { |
|
57 'root': [ |
|
58 (r'[^\S\n]+', Text), |
|
59 (r'//.*?\n', Comment.Single), |
|
60 (r'/\*(.|\n)*?\*/', Comment.Multiline), |
|
61 (r'\b(%s)\b' % '|'.join(keywords), Keyword), |
|
62 (r'\b(%s)\b' % '|'.join(types), Keyword.Type), |
|
63 (r'\b(%s)\b' % '|'.join(values), Keyword.Constant), |
|
64 (r'\b(%s)\b' % '|'.join(modifiers), Keyword.Declaration), |
|
65 (r'"(\\\\|\\"|[^"])*"', String), |
|
66 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), |
|
67 (r'.', Text) |
|
68 ], |
|
69 } |