ThirdParty/Pygments/pygments/lexers/jvm.py

changeset 2426
da76c71624de
parent 1705
b0fbc9300f2b
child 2525
8b507a9a2d40
equal deleted inserted replaced
2425:ace8a08028f3 2426:da76c71624de
3 pygments.lexers.jvm 3 pygments.lexers.jvm
4 ~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~
5 5
6 Pygments lexers for JVM languages. 6 Pygments lexers for JVM languages.
7 7
8 :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2013 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
18 from pygments.util import get_choice_opt 18 from pygments.util import get_choice_opt
19 from pygments import unistring as uni 19 from pygments import unistring as uni
20 20
21 21
22 __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer', 22 __all__ = ['JavaLexer', 'ScalaLexer', 'GosuLexer', 'GosuTemplateLexer',
23 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer'] 23 'GroovyLexer', 'IokeLexer', 'ClojureLexer', 'KotlinLexer',
24 'XtendLexer', 'AspectJLexer', 'CeylonLexer']
24 25
25 26
26 class JavaLexer(RegexLexer): 27 class JavaLexer(RegexLexer):
27 """ 28 """
28 For `Java <http://www.sun.com/java/>`_ source code. 29 For `Java <http://www.sun.com/java/>`_ source code.
33 filenames = ['*.java'] 34 filenames = ['*.java']
34 mimetypes = ['text/x-java'] 35 mimetypes = ['text/x-java']
35 36
36 flags = re.MULTILINE | re.DOTALL 37 flags = re.MULTILINE | re.DOTALL
37 38
38 #: optional Comment or Whitespace
39 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
40
41 tokens = { 39 tokens = {
42 'root': [ 40 'root': [
43 # method names 41 # method names
44 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments 42 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]<>]*\s+)+?)' # return arguments
45 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name 43 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
46 r'(\s*)(\()', # signature start 44 r'(\s*)(\()', # signature start
47 bygroups(using(this), Name.Function, Text, Operator)), 45 bygroups(using(this), Name.Function, Text, Operator)),
48 (r'[^\S\n]+', Text), 46 (r'[^\S\n]+', Text),
49 (r'//.*?\n', Comment.Single), 47 (r'//.*?\n', Comment.Single),
50 (r'/\*.*?\*/', Comment.Multiline), 48 (r'/\*.*?\*/', Comment.Multiline),
51 (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator), 49 (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
60 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), 58 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
61 (r'(true|false|null)\b', Keyword.Constant), 59 (r'(true|false|null)\b', Keyword.Constant),
62 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'), 60 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 'class'),
63 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 61 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
64 (r'"(\\\\|\\"|[^"])*"', String), 62 (r'"(\\\\|\\"|[^"])*"', String),
65 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), 63 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
66 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)), 64 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
67 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label), 65 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
68 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name), 66 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
69 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator), 67 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
70 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 68 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
71 (r'0x[0-9a-f]+', Number.Hex), 69 (r'0x[0-9a-fA-F]+', Number.Hex),
72 (r'[0-9]+L?', Number.Integer), 70 (r'[0-9]+L?', Number.Integer),
73 (r'\n', Text) 71 (r'\n', Text)
74 ], 72 ],
75 'class': [ 73 'class': [
76 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') 74 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
77 ], 75 ],
78 'import': [ 76 'import': [
79 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop') 77 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
80 ], 78 ],
81 } 79 }
80
81
82 class AspectJLexer(JavaLexer):
83 """
84 For `AspectJ <http://www.eclipse.org/aspectj/>`_ source code.
85
86 *New in Pygments 1.6.*
87 """
88
89 name = 'AspectJ'
90 aliases = ['aspectj']
91 filenames = ['*.aj']
92 mimetypes = ['text/x-aspectj']
93
94 aj_keywords = [
95 'aspect', 'pointcut', 'privileged', 'call', 'execution',
96 'initialization', 'preinitialization', 'handler', 'get', 'set',
97 'staticinitialization', 'target', 'args', 'within', 'withincode',
98 'cflow', 'cflowbelow', 'annotation', 'before', 'after', 'around',
99 'proceed', 'throwing', 'returning', 'adviceexecution', 'declare',
100 'parents', 'warning', 'error', 'soft', 'precedence', 'thisJoinPoint',
101 'thisJoinPointStaticPart', 'thisEnclosingJoinPointStaticPart',
102 'issingleton', 'perthis', 'pertarget', 'percflow', 'percflowbelow',
103 'pertypewithin', 'lock', 'unlock', 'thisAspectInstance'
104 ]
105 aj_inter_type = ['parents:', 'warning:', 'error:', 'soft:', 'precedence:']
106 aj_inter_type_annotation = ['@type', '@method', '@constructor', '@field']
107
108 def get_tokens_unprocessed(self, text):
109 for index, token, value in JavaLexer.get_tokens_unprocessed(self, text):
110 if token is Name and value in self.aj_keywords:
111 yield index, Keyword, value
112 elif token is Name.Label and value in self.aj_inter_type:
113 yield index, Keyword, value[:-1]
114 yield index, Operator, value[-1]
115 elif token is Name.Decorator and value in self.aj_inter_type_annotation:
116 yield index, Keyword, value
117 else:
118 yield index, token, value
82 119
83 120
84 class ScalaLexer(RegexLexer): 121 class ScalaLexer(RegexLexer):
85 """ 122 """
86 For `Scala <http://www.scala-lang.org>`_ source code. 123 For `Scala <http://www.scala-lang.org>`_ source code.
91 filenames = ['*.scala'] 128 filenames = ['*.scala']
92 mimetypes = ['text/x-scala'] 129 mimetypes = ['text/x-scala']
93 130
94 flags = re.MULTILINE | re.DOTALL 131 flags = re.MULTILINE | re.DOTALL
95 132
96 #: optional Comment or Whitespace
97 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
98
99 # don't use raw unicode strings! 133 # don't use raw unicode strings!
100 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]+' 134 op = ('[-~\\^\\*!%&\\\\<>\\|+=:/?@\u00a6-\u00a7\u00a9\u00ac\u00ae\u00b0-\u00b1'
101 135 '\u00b6\u00d7\u00f7\u03f6\u0482\u0606-\u0608\u060e-\u060f\u06e9'
102 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]' 136 '\u06fd-\u06fe\u07f6\u09fa\u0b70\u0bf3-\u0bf8\u0bfa\u0c7f\u0cf1-\u0cf2'
103 137 '\u0d79\u0f01-\u0f03\u0f13-\u0f17\u0f1a-\u0f1f\u0f34\u0f36\u0f38'
104 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]' 138 '\u0fbe-\u0fc5\u0fc7-\u0fcf\u109e-\u109f\u1360\u1390-\u1399\u1940'
139 '\u19e0-\u19ff\u1b61-\u1b6a\u1b74-\u1b7c\u2044\u2052\u207a-\u207c'
140 '\u208a-\u208c\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118'
141 '\u211e-\u2123\u2125\u2127\u2129\u212e\u213a-\u213b\u2140-\u2144'
142 '\u214a-\u214d\u214f\u2190-\u2328\u232b-\u244a\u249c-\u24e9\u2500-\u2767'
143 '\u2794-\u27c4\u27c7-\u27e5\u27f0-\u2982\u2999-\u29d7\u29dc-\u29fb'
144 '\u29fe-\u2b54\u2ce5-\u2cea\u2e80-\u2ffb\u3004\u3012-\u3013\u3020'
145 '\u3036-\u3037\u303e-\u303f\u3190-\u3191\u3196-\u319f\u31c0-\u31e3'
146 '\u3200-\u321e\u322a-\u3250\u3260-\u327f\u328a-\u32b0\u32c0-\u33ff'
147 '\u4dc0-\u4dff\ua490-\ua4c6\ua828-\ua82b\ufb29\ufdfd\ufe62\ufe64-\ufe66'
148 '\uff0b\uff1c-\uff1e\uff5c\uff5e\uffe2\uffe4\uffe8-\uffee\ufffc-\ufffd]+')
149
150 letter = ('[a-zA-Z\\$_\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6'
151 '\u00f8-\u02af\u0370-\u0373\u0376-\u0377\u037b-\u037d\u0386'
152 '\u0388-\u03f5\u03f7-\u0481\u048a-\u0556\u0561-\u0587\u05d0-\u05f2'
153 '\u0621-\u063f\u0641-\u064a\u066e-\u066f\u0671-\u06d3\u06d5'
154 '\u06ee-\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5'
155 '\u07b1\u07ca-\u07ea\u0904-\u0939\u093d\u0950\u0958-\u0961'
156 '\u0972-\u097f\u0985-\u09b9\u09bd\u09ce\u09dc-\u09e1\u09f0-\u09f1'
157 '\u0a05-\u0a39\u0a59-\u0a5e\u0a72-\u0a74\u0a85-\u0ab9\u0abd'
158 '\u0ad0-\u0ae1\u0b05-\u0b39\u0b3d\u0b5c-\u0b61\u0b71\u0b83-\u0bb9'
159 '\u0bd0\u0c05-\u0c3d\u0c58-\u0c61\u0c85-\u0cb9\u0cbd\u0cde-\u0ce1'
160 '\u0d05-\u0d3d\u0d60-\u0d61\u0d7a-\u0d7f\u0d85-\u0dc6\u0e01-\u0e30'
161 '\u0e32-\u0e33\u0e40-\u0e45\u0e81-\u0eb0\u0eb2-\u0eb3\u0ebd-\u0ec4'
162 '\u0edc-\u0f00\u0f40-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f'
163 '\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070'
164 '\u1075-\u1081\u108e\u10a0-\u10fa\u1100-\u135a\u1380-\u138f'
165 '\u13a0-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u16ee-\u1711'
166 '\u1720-\u1731\u1740-\u1751\u1760-\u1770\u1780-\u17b3\u17dc'
167 '\u1820-\u1842\u1844-\u18a8\u18aa-\u191c\u1950-\u19a9\u19c1-\u19c7'
168 '\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae-\u1baf'
169 '\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c77\u1d00-\u1d2b\u1d62-\u1d77'
170 '\u1d79-\u1d9a\u1e00-\u1fbc\u1fbe\u1fc2-\u1fcc\u1fd0-\u1fdb'
171 '\u1fe0-\u1fec\u1ff2-\u1ffc\u2071\u207f\u2102\u2107\u210a-\u2113'
172 '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139'
173 '\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c7c'
174 '\u2c80-\u2ce4\u2d00-\u2d65\u2d80-\u2dde\u3006-\u3007\u3021-\u3029'
175 '\u3038-\u303a\u303c\u3041-\u3096\u309f\u30a1-\u30fa\u30ff-\u318e'
176 '\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\ua014\ua016-\ua48c'
177 '\ua500-\ua60b\ua610-\ua61f\ua62a-\ua66e\ua680-\ua697\ua722-\ua76f'
178 '\ua771-\ua787\ua78b-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822'
179 '\ua840-\ua873\ua882-\ua8b3\ua90a-\ua925\ua930-\ua946\uaa00-\uaa28'
180 '\uaa40-\uaa42\uaa44-\uaa4b\uac00-\ud7a3\uf900-\ufb1d\ufb1f-\ufb28'
181 '\ufb2a-\ufd3d\ufd50-\ufdfb\ufe70-\ufefc\uff21-\uff3a\uff41-\uff5a'
182 '\uff66-\uff6f\uff71-\uff9d\uffa0-\uffdc]')
183
184 upper = ('[A-Z\\$_\u00c0-\u00d6\u00d8-\u00de\u0100\u0102\u0104\u0106\u0108'
185 '\u010a\u010c\u010e\u0110\u0112\u0114\u0116\u0118\u011a\u011c'
186 '\u011e\u0120\u0122\u0124\u0126\u0128\u012a\u012c\u012e\u0130'
187 '\u0132\u0134\u0136\u0139\u013b\u013d\u013f\u0141\u0143\u0145'
188 '\u0147\u014a\u014c\u014e\u0150\u0152\u0154\u0156\u0158\u015a'
189 '\u015c\u015e\u0160\u0162\u0164\u0166\u0168\u016a\u016c\u016e'
190 '\u0170\u0172\u0174\u0176\u0178-\u0179\u017b\u017d\u0181-\u0182'
191 '\u0184\u0186-\u0187\u0189-\u018b\u018e-\u0191\u0193-\u0194'
192 '\u0196-\u0198\u019c-\u019d\u019f-\u01a0\u01a2\u01a4\u01a6-\u01a7'
193 '\u01a9\u01ac\u01ae-\u01af\u01b1-\u01b3\u01b5\u01b7-\u01b8\u01bc'
194 '\u01c4\u01c7\u01ca\u01cd\u01cf\u01d1\u01d3\u01d5\u01d7\u01d9'
195 '\u01db\u01de\u01e0\u01e2\u01e4\u01e6\u01e8\u01ea\u01ec\u01ee'
196 '\u01f1\u01f4\u01f6-\u01f8\u01fa\u01fc\u01fe\u0200\u0202\u0204'
197 '\u0206\u0208\u020a\u020c\u020e\u0210\u0212\u0214\u0216\u0218'
198 '\u021a\u021c\u021e\u0220\u0222\u0224\u0226\u0228\u022a\u022c'
199 '\u022e\u0230\u0232\u023a-\u023b\u023d-\u023e\u0241\u0243-\u0246'
200 '\u0248\u024a\u024c\u024e\u0370\u0372\u0376\u0386\u0388-\u038f'
201 '\u0391-\u03ab\u03cf\u03d2-\u03d4\u03d8\u03da\u03dc\u03de\u03e0'
202 '\u03e2\u03e4\u03e6\u03e8\u03ea\u03ec\u03ee\u03f4\u03f7'
203 '\u03f9-\u03fa\u03fd-\u042f\u0460\u0462\u0464\u0466\u0468\u046a'
204 '\u046c\u046e\u0470\u0472\u0474\u0476\u0478\u047a\u047c\u047e'
205 '\u0480\u048a\u048c\u048e\u0490\u0492\u0494\u0496\u0498\u049a'
206 '\u049c\u049e\u04a0\u04a2\u04a4\u04a6\u04a8\u04aa\u04ac\u04ae'
207 '\u04b0\u04b2\u04b4\u04b6\u04b8\u04ba\u04bc\u04be\u04c0-\u04c1'
208 '\u04c3\u04c5\u04c7\u04c9\u04cb\u04cd\u04d0\u04d2\u04d4\u04d6'
209 '\u04d8\u04da\u04dc\u04de\u04e0\u04e2\u04e4\u04e6\u04e8\u04ea'
210 '\u04ec\u04ee\u04f0\u04f2\u04f4\u04f6\u04f8\u04fa\u04fc\u04fe'
211 '\u0500\u0502\u0504\u0506\u0508\u050a\u050c\u050e\u0510\u0512'
212 '\u0514\u0516\u0518\u051a\u051c\u051e\u0520\u0522\u0531-\u0556'
213 '\u10a0-\u10c5\u1e00\u1e02\u1e04\u1e06\u1e08\u1e0a\u1e0c\u1e0e'
214 '\u1e10\u1e12\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1e1e\u1e20\u1e22'
215 '\u1e24\u1e26\u1e28\u1e2a\u1e2c\u1e2e\u1e30\u1e32\u1e34\u1e36'
216 '\u1e38\u1e3a\u1e3c\u1e3e\u1e40\u1e42\u1e44\u1e46\u1e48\u1e4a'
217 '\u1e4c\u1e4e\u1e50\u1e52\u1e54\u1e56\u1e58\u1e5a\u1e5c\u1e5e'
218 '\u1e60\u1e62\u1e64\u1e66\u1e68\u1e6a\u1e6c\u1e6e\u1e70\u1e72'
219 '\u1e74\u1e76\u1e78\u1e7a\u1e7c\u1e7e\u1e80\u1e82\u1e84\u1e86'
220 '\u1e88\u1e8a\u1e8c\u1e8e\u1e90\u1e92\u1e94\u1e9e\u1ea0\u1ea2'
221 '\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6'
222 '\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ec8\u1eca'
223 '\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede'
224 '\u1ee0\u1ee2\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0\u1ef2'
225 '\u1ef4\u1ef6\u1ef8\u1efa\u1efc\u1efe\u1f08-\u1f0f\u1f18-\u1f1d'
226 '\u1f28-\u1f2f\u1f38-\u1f3f\u1f48-\u1f4d\u1f59-\u1f5f'
227 '\u1f68-\u1f6f\u1fb8-\u1fbb\u1fc8-\u1fcb\u1fd8-\u1fdb'
228 '\u1fe8-\u1fec\u1ff8-\u1ffb\u2102\u2107\u210b-\u210d\u2110-\u2112'
229 '\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u2130-\u2133'
230 '\u213e-\u213f\u2145\u2183\u2c00-\u2c2e\u2c60\u2c62-\u2c64\u2c67'
231 '\u2c69\u2c6b\u2c6d-\u2c6f\u2c72\u2c75\u2c80\u2c82\u2c84\u2c86'
232 '\u2c88\u2c8a\u2c8c\u2c8e\u2c90\u2c92\u2c94\u2c96\u2c98\u2c9a'
233 '\u2c9c\u2c9e\u2ca0\u2ca2\u2ca4\u2ca6\u2ca8\u2caa\u2cac\u2cae'
234 '\u2cb0\u2cb2\u2cb4\u2cb6\u2cb8\u2cba\u2cbc\u2cbe\u2cc0\u2cc2'
235 '\u2cc4\u2cc6\u2cc8\u2cca\u2ccc\u2cce\u2cd0\u2cd2\u2cd4\u2cd6'
236 '\u2cd8\u2cda\u2cdc\u2cde\u2ce0\u2ce2\ua640\ua642\ua644\ua646'
237 '\ua648\ua64a\ua64c\ua64e\ua650\ua652\ua654\ua656\ua658\ua65a'
238 '\ua65c\ua65e\ua662\ua664\ua666\ua668\ua66a\ua66c\ua680\ua682'
239 '\ua684\ua686\ua688\ua68a\ua68c\ua68e\ua690\ua692\ua694\ua696'
240 '\ua722\ua724\ua726\ua728\ua72a\ua72c\ua72e\ua732\ua734\ua736'
241 '\ua738\ua73a\ua73c\ua73e\ua740\ua742\ua744\ua746\ua748\ua74a'
242 '\ua74c\ua74e\ua750\ua752\ua754\ua756\ua758\ua75a\ua75c\ua75e'
243 '\ua760\ua762\ua764\ua766\ua768\ua76a\ua76c\ua76e\ua779\ua77b'
244 '\ua77d-\ua77e\ua780\ua782\ua784\ua786\ua78b\uff21-\uff3a]')
105 245
106 idrest = r'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op) 246 idrest = r'%s(?:%s|[0-9])*(?:(?<=_)%s)?' % (letter, letter, op)
107 247
108 tokens = { 248 tokens = {
109 'root': [ 249 'root': [
123 (r':(?!%s)' % op, Keyword, 'type'), 263 (r':(?!%s)' % op, Keyword, 'type'),
124 (r'%s%s\b' % (upper, idrest), Name.Class), 264 (r'%s%s\b' % (upper, idrest), Name.Class),
125 (r'(true|false|null)\b', Keyword.Constant), 265 (r'(true|false|null)\b', Keyword.Constant),
126 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'), 266 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
127 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'), 267 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
128 (r'""".*?"""', String), 268 (r'""".*?"""(?!")', String),
129 (r'"(\\\\|\\"|[^"])*"', String), 269 (r'"(\\\\|\\"|[^"])*"', String),
130 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), 270 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
131 # (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator, 271 # (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
132 # Name.Attribute)), 272 # Name.Attribute)),
133 (idrest, Name), 273 (idrest, Name),
134 (r'`[^`]+`', Name), 274 (r'`[^`]+`', Name),
135 (r'\[', Operator, 'typeparam'), 275 (r'\[', Operator, 'typeparam'),
136 (r'[\(\)\{\};,.#]', Operator), 276 (r'[\(\)\{\};,.#]', Operator),
137 (op, Operator), 277 (op, Operator),
138 (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?', 278 (r'([0-9][0-9]*\.[0-9]*|\.[0-9]+)([eE][+-]?[0-9]+)?[fFdD]?',
139 Number.Float), 279 Number.Float),
140 (r'0x[0-9a-f]+', Number.Hex), 280 (r'0x[0-9a-fA-F]+', Number.Hex),
141 (r'[0-9]+L?', Number.Integer), 281 (r'[0-9]+L?', Number.Integer),
142 (r'\n', Text) 282 (r'\n', Text)
143 ], 283 ],
144 'class': [ 284 'class': [
145 (r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op), 285 (r'(%s|%s|`[^`]+`)(\s*)(\[)' % (idrest, op),
194 aliases = ['gosu'] 334 aliases = ['gosu']
195 filenames = ['*.gs', '*.gsx', '*.gsp', '*.vark'] 335 filenames = ['*.gs', '*.gsx', '*.gsp', '*.vark']
196 mimetypes = ['text/x-gosu'] 336 mimetypes = ['text/x-gosu']
197 337
198 flags = re.MULTILINE | re.DOTALL 338 flags = re.MULTILINE | re.DOTALL
199
200 #: optional Comment or Whitespace
201 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
202 339
203 tokens = { 340 tokens = {
204 'root': [ 341 'root': [
205 # method names 342 # method names
206 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # modifiers etc. 343 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # modifiers etc.
216 r'throw|new|switch|case|default|eval|super|outer|classpath|' 353 r'throw|new|switch|case|default|eval|super|outer|classpath|'
217 r'using)\b', Keyword), 354 r'using)\b', Keyword),
218 (r'(var|delegate|construct|function|private|internal|protected|' 355 (r'(var|delegate|construct|function|private|internal|protected|'
219 r'public|abstract|override|final|static|extends|transient|' 356 r'public|abstract|override|final|static|extends|transient|'
220 r'implements|represents|readonly)\b', Keyword.Declaration), 357 r'implements|represents|readonly)\b', Keyword.Declaration),
221 (r'(property\s+)(get|set|)', Keyword.Declaration), 358 (r'(property\s+)(get|set)?', Keyword.Declaration),
222 (r'(boolean|byte|char|double|float|int|long|short|void|block)\b', 359 (r'(boolean|byte|char|double|float|int|long|short|void|block)\b',
223 Keyword.Type), 360 Keyword.Type),
224 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), 361 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
225 (r'(true|false|null|NaN|Infinity)\b', Keyword.Constant), 362 (r'(true|false|null|NaN|Infinity)\b', Keyword.Constant),
226 (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)', 363 (r'(class|interface|enhancement|enum)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
295 aliases = ['groovy'] 432 aliases = ['groovy']
296 filenames = ['*.groovy'] 433 filenames = ['*.groovy']
297 mimetypes = ['text/x-groovy'] 434 mimetypes = ['text/x-groovy']
298 435
299 flags = re.MULTILINE | re.DOTALL 436 flags = re.MULTILINE | re.DOTALL
300
301 #: optional Comment or Whitespace
302 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
303 437
304 tokens = { 438 tokens = {
305 'root': [ 439 'root': [
306 # method names 440 # method names
307 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments 441 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
327 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 461 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
328 (r'"(\\\\|\\"|[^"])*"', String.Double), 462 (r'"(\\\\|\\"|[^"])*"', String.Double),
329 (r"'(\\\\|\\'|[^'])*'", String.Single), 463 (r"'(\\\\|\\'|[^'])*'", String.Single),
330 (r'\$/((?!/\$).)*/\$', String), 464 (r'\$/((?!/\$).)*/\$', String),
331 (r'/(\\\\|\\"|[^/])*/', String), 465 (r'/(\\\\|\\"|[^/])*/', String),
332 (r"'\\.'|'[^\\]'|'\\u[0-9a-f]{4}'", String.Char), 466 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
333 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)), 467 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
334 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label), 468 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
335 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name), 469 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
336 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator), 470 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
337 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 471 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
338 (r'0x[0-9a-f]+', Number.Hex), 472 (r'0x[0-9a-fA-F]+', Number.Hex),
339 (r'[0-9]+L?', Number.Integer), 473 (r'[0-9]+L?', Number.Integer),
340 (r'\n', Text) 474 (r'\n', Text)
341 ], 475 ],
342 'class': [ 476 'class': [
343 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') 477 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
642 (r'"(\\\\|\\"|[^"])*"', String), 776 (r'"(\\\\|\\"|[^"])*"', String),
643 (r"'" + valid_name, String.Symbol), 777 (r"'" + valid_name, String.Symbol),
644 (r"\\(.|[a-z]+)", String.Char), 778 (r"\\(.|[a-z]+)", String.Char),
645 779
646 # keywords 780 # keywords
647 (r':' + valid_name, String.Symbol), 781 (r'::?' + valid_name, String.Symbol),
648 782
649 # special operators 783 # special operators
650 (r'~@|[`\'#^~&]', Operator), 784 (r'~@|[`\'#^~&@]', Operator),
651 785
652 # highlight the special forms 786 # highlight the special forms
653 (_multi_escape(special_forms), Keyword), 787 (_multi_escape(special_forms), Keyword),
654 788
655 # Technically, only the special forms are 'keywords'. The problem 789 # Technically, only the special forms are 'keywords'. The problem
687 821
688 *New in Pygments 1.5.* 822 *New in Pygments 1.5.*
689 """ 823 """
690 824
691 flags = re.MULTILINE | re.DOTALL 825 flags = re.MULTILINE | re.DOTALL
692
693 #: optional Comment or Whitespace
694 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
695 826
696 tokens = { 827 tokens = {
697 'root': [ 828 'root': [
698 # method names 829 # method names
699 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments 830 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
715 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)), 846 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Operator, Name.Attribute)),
716 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label), 847 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
717 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name), 848 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
718 (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator), 849 (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
719 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 850 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
720 (r'0x[0-9a-f]+', Number.Hex), 851 (r'0x[0-9a-fA-F]+', Number.Hex),
721 (r'[0-9]+L?', Number.Integer), 852 (r'[0-9]+L?', Number.Integer),
722 (r'\n', Text) 853 (r'\n', Text)
723 ], 854 ],
724 'template': [ 855 'template': [
725 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') 856 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
726 ], 857 ],
727 'import': [ 858 'import': [
728 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop') 859 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
860 ],
861 }
862
863
864 class CeylonLexer(RegexLexer):
865 """
866 For `Ceylon <http://ceylon-lang.org/>`_ source code.
867
868 *New in Pygments 1.6.*
869 """
870
871 name = 'Ceylon'
872 aliases = ['ceylon']
873 filenames = ['*.ceylon']
874 mimetypes = ['text/x-ceylon']
875
876 flags = re.MULTILINE | re.DOTALL
877
878 #: optional Comment or Whitespace
879 _ws = r'(?:\s|//.*?\n|/[*].*?[*]/)+'
880
881 tokens = {
882 'root': [
883 # method names
884 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
885 r'([a-zA-Z_][a-zA-Z0-9_]*)' # method name
886 r'(\s*)(\()', # signature start
887 bygroups(using(this), Name.Function, Text, Operator)),
888 (r'[^\S\n]+', Text),
889 (r'//.*?\n', Comment.Single),
890 (r'/\*.*?\*/', Comment.Multiline),
891 (r'(variable|shared|abstract|doc|by|formal|actual)',
892 Name.Decorator),
893 (r'(break|case|catch|continue|default|else|finally|for|in|'
894 r'variable|if|return|switch|this|throw|try|while|is|exists|'
895 r'nonempty|then|outer)\b', Keyword),
896 (r'(abstracts|extends|satisfies|adapts|'
897 r'super|given|of|out|assign|'
898 r'transient|volatile)\b', Keyword.Declaration),
899 (r'(function|value|void)\b',
900 Keyword.Type),
901 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
902 (r'(true|false|null)\b', Keyword.Constant),
903 (r'(class|interface|object)(\s+)',
904 bygroups(Keyword.Declaration, Text), 'class'),
905 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
906 (r'"(\\\\|\\"|[^"])*"', String),
907 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Quoted),
908 (r"`\\.`|`[^\\]`|`\\u[0-9a-fA-F]{4}`", String.Char),
909 (r'(\.)([a-zA-Z_][a-zA-Z0-9_]*)',
910 bygroups(Operator, Name.Attribute)),
911 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
912 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
913 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
914 (r'\d{1,3}(_\d{3})+\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
915 (r'\d{1,3}(_\d{3})+\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
916 Number.Float),
917 (r'[0-9][0-9]*\.\d{1,3}(_\d{3})+[kMGTPmunpf]?', Number.Float),
918 (r'[0-9][0-9]*\.[0-9]+([eE][+-]?[0-9]+)?[kMGTPmunpf]?',
919 Number.Float),
920 (r'0x[0-9a-fA-F]+', Number.Hex),
921 (r'\d{1,3}(_\d{3})+[kMGTP]?', Number.Integer),
922 (r'[0-9]+[kMGTP]?', Number.Integer),
923 (r'\n', Text)
924 ],
925 'class': [
926 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
927 ],
928 'import': [
929 (r'[a-zA-Z0-9_.]+\w+ \{([a-zA-Z,]+|\.\.\.)\}',
930 Name.Namespace, '#pop')
729 ], 931 ],
730 } 932 }
731 933
732 934
733 class KotlinLexer(RegexLexer): 935 class KotlinLexer(RegexLexer):
762 flags = re.MULTILINE | re.DOTALL | re.UNICODE 964 flags = re.MULTILINE | re.DOTALL | re.UNICODE
763 965
764 # for the range of allowed unicode characters in identifiers, 966 # for the range of allowed unicode characters in identifiers,
765 # see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf 967 # see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf
766 968
767 def _escape(st):
768 return st.replace('\\', r'\\').replace('-', r'\-').\
769 replace('[', r'\[').replace(']', r'\]')
770
771 levels = { 969 levels = {
772 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*', 970 'none': '@?[_a-zA-Z][a-zA-Z0-9_]*',
773 'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' + 971 'basic': ('@?[_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + ']' +
774 '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl + 972 '[' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Nl +
775 uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'), 973 uni.Nd + uni.Pc + uni.Cf + uni.Mn + uni.Mc + ']*'),
776 'full': ('@?(?:_|[^' + 974 'full': ('@?(?:_|[^' +
777 _escape(uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl')) + '])' 975 uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl') + '])'
778 + '[^' + _escape(uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 976 + '[^' + uni.allexcept('Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl',
779 'Nl', 'Nd', 'Pc', 'Cf', 'Mn', 977 'Nd', 'Pc', 'Cf', 'Mn', 'Mc') + ']*'),
780 'Mc')) + ']*'),
781 } 978 }
782 979
783 tokens = {} 980 tokens = {}
784 token_variants = True 981 token_variants = True
785 982
843 self._tokens = self.__class__.process_tokendef(level) 1040 self._tokens = self.__class__.process_tokendef(level)
844 else: 1041 else:
845 self._tokens = self._all_tokens[level] 1042 self._tokens = self._all_tokens[level]
846 1043
847 RegexLexer.__init__(self, **options) 1044 RegexLexer.__init__(self, **options)
1045
1046
1047 class XtendLexer(RegexLexer):
1048 """
1049 For `Xtend <http://xtend-lang.org/>`_ source code.
1050
1051 *New in Pygments 1.6.*
1052 """
1053
1054 name = 'Xtend'
1055 aliases = ['xtend']
1056 filenames = ['*.xtend']
1057 mimetypes = ['text/x-xtend']
1058
1059 flags = re.MULTILINE | re.DOTALL
1060
1061 tokens = {
1062 'root': [
1063 # method names
1064 (r'^(\s*(?:[a-zA-Z_][a-zA-Z0-9_\.\[\]]*\s+)+?)' # return arguments
1065 r'([a-zA-Z_$][a-zA-Z0-9_$]*)' # method name
1066 r'(\s*)(\()', # signature start
1067 bygroups(using(this), Name.Function, Text, Operator)),
1068 (r'[^\S\n]+', Text),
1069 (r'//.*?\n', Comment.Single),
1070 (r'/\*.*?\*/', Comment.Multiline),
1071 (r'@[a-zA-Z_][a-zA-Z0-9_\.]*', Name.Decorator),
1072 (r'(assert|break|case|catch|continue|default|do|else|finally|for|'
1073 r'if|goto|instanceof|new|return|switch|this|throw|try|while|IF|'
1074 r'ELSE|ELSEIF|ENDIF|FOR|ENDFOR|SEPARATOR|BEFORE|AFTER)\b',
1075 Keyword),
1076 (r'(def|abstract|const|enum|extends|final|implements|native|private|'
1077 r'protected|public|static|strictfp|super|synchronized|throws|'
1078 r'transient|volatile)\b', Keyword.Declaration),
1079 (r'(boolean|byte|char|double|float|int|long|short|void)\b',
1080 Keyword.Type),
1081 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
1082 (r'(true|false|null)\b', Keyword.Constant),
1083 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
1084 'class'),
1085 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1086 (r"(''')", String, 'template'),
1087 (r"(\u00BB)", String, 'template'),
1088 (r'"(\\\\|\\"|[^"])*"', String),
1089 (r"'(\\\\|\\'|[^'])*'", String),
1090 (r'[a-zA-Z_][a-zA-Z0-9_]*:', Name.Label),
1091 (r'[a-zA-Z_\$][a-zA-Z0-9_]*', Name),
1092 (r'[~\^\*!%&\[\]\(\)\{\}<>\|+=:;,./?-]', Operator),
1093 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1094 (r'0x[0-9a-fA-F]+', Number.Hex),
1095 (r'[0-9]+L?', Number.Integer),
1096 (r'\n', Text)
1097 ],
1098 'class': [
1099 (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
1100 ],
1101 'import': [
1102 (r'[a-zA-Z0-9_.]+\*?', Name.Namespace, '#pop')
1103 ],
1104 'template': [
1105 (r"'''", String, '#pop'),
1106 (r"\u00AB", String, '#pop'),
1107 (r'.', String)
1108 ],
1109 }

eric ide

mercurial