ThirdParty/Pygments/pygments/lexers/jvm.py

changeset 4697
c2e9bf425554
parent 4172
4f20dba37ab6
child 5713
6762afd9f963
equal deleted inserted replaced
4696:bf4d19a7cade 4697:c2e9bf425554
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-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 import re 12 import re
13 13
64 (r'"(\\\\|\\"|[^"])*"', String), 64 (r'"(\\\\|\\"|[^"])*"', String),
65 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 65 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
66 (r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Operator, Name.Attribute)), 66 (r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Operator, Name.Attribute)),
67 (r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label), 67 (r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label),
68 (r'([^\W\d]|\$)[\w$]*', Name), 68 (r'([^\W\d]|\$)[\w$]*', Name),
69 (r'([0-9](_*[0-9]+)*\.([0-9](_*[0-9]+)*)?|'
70 r'([0-9](_*[0-9]+)*)?\.[0-9](_*[0-9]+)*)'
71 r'([eE][+\-]?[0-9](_*[0-9]+)*)?[fFdD]?|'
72 r'[0-9][eE][+\-]?[0-9](_*[0-9]+)*[fFdD]?|'
73 r'[0-9]([eE][+\-]?[0-9](_*[0-9]+)*)?[fFdD]|'
74 r'0[xX]([0-9a-fA-F](_*[0-9a-fA-F]+)*\.?|'
75 r'([0-9a-fA-F](_*[0-9a-fA-F]+)*)?\.[0-9a-fA-F](_*[0-9a-fA-F]+)*)'
76 r'[pP][+\-]?[0-9](_*[0-9]+)*[fFdD]?', Number.Float),
77 (r'0[xX][0-9a-fA-F](_*[0-9a-fA-F]+)*[lL]?', Number.Hex),
78 (r'0[bB][01](_*[01]+)*[lL]?', Number.Bin),
79 (r'0(_*[0-7]+)+[lL]?', Number.Oct),
80 (r'0|[1-9](_*[0-9]+)*[lL]?', Number.Integer),
69 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator), 81 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
70 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
71 (r'0x[0-9a-fA-F]+', Number.Hex),
72 (r'[0-9]+(_+[0-9]+)*L?', Number.Integer),
73 (r'\n', Text) 82 (r'\n', Text)
74 ], 83 ],
75 'class': [ 84 'class': [
76 (r'([^\W\d]|\$)[\w$]*', Name.Class, '#pop') 85 (r'([^\W\d]|\$)[\w$]*', Name.Class, '#pop')
77 ], 86 ],
250 259
251 tokens = { 260 tokens = {
252 'root': [ 261 'root': [
253 # method names 262 # method names
254 (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'), 263 (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'),
255 (u"'%s" % idrest, Text.Symbol),
256 (r'[^\S\n]+', Text), 264 (r'[^\S\n]+', Text),
257 (r'//.*?\n', Comment.Single), 265 (r'//.*?\n', Comment.Single),
258 (r'/\*', Comment.Multiline, 'comment'), 266 (r'/\*', Comment.Multiline, 'comment'),
259 (u'@%s' % idrest, Name.Decorator), 267 (u'@%s' % idrest, Name.Decorator),
260 (u'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|' 268 (u'(abstract|ca(?:se|tch)|d(?:ef|o)|e(?:lse|xtends)|'
269 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'), 277 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
270 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'), 278 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
271 (r'""".*?"""(?!")', String), 279 (r'""".*?"""(?!")', String),
272 (r'"(\\\\|\\"|[^"])*"', String), 280 (r'"(\\\\|\\"|[^"])*"', String),
273 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 281 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
282 (u"'%s" % idrest, Text.Symbol),
274 (r'[fs]"""', String, 'interptriplestring'), # interpolated strings 283 (r'[fs]"""', String, 'interptriplestring'), # interpolated strings
275 (r'[fs]"', String, 'interpstring'), # interpolated strings 284 (r'[fs]"', String, 'interpstring'), # interpolated strings
276 (r'raw"(\\\\|\\"|[^"])*"', String), # raw strings 285 (r'raw"(\\\\|\\"|[^"])*"', String), # raw strings
277 # (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator, 286 # (ur'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
278 # Name.Attribute)), 287 # Name.Attribute)),
455 .. versionadded:: 1.5 464 .. versionadded:: 1.5
456 """ 465 """
457 466
458 name = 'Groovy' 467 name = 'Groovy'
459 aliases = ['groovy'] 468 aliases = ['groovy']
460 filenames = ['*.groovy'] 469 filenames = ['*.groovy','*.gradle']
461 mimetypes = ['text/x-groovy'] 470 mimetypes = ['text/x-groovy']
462 471
463 flags = re.MULTILINE | re.DOTALL 472 flags = re.MULTILINE | re.DOTALL
464 473
465 tokens = { 474 tokens = {
933 r'(\s*)(\()', # signature start 942 r'(\s*)(\()', # signature start
934 bygroups(using(this), Name.Function, Text, Operator)), 943 bygroups(using(this), Name.Function, Text, Operator)),
935 (r'[^\S\n]+', Text), 944 (r'[^\S\n]+', Text),
936 (r'//.*?\n', Comment.Single), 945 (r'//.*?\n', Comment.Single),
937 (r'/\*', Comment.Multiline, 'comment'), 946 (r'/\*', Comment.Multiline, 'comment'),
938 (r'(variable|shared|abstract|doc|by|formal|actual|late|native)', 947 (r'(shared|abstract|formal|default|actual|variable|deprecated|small|'
939 Name.Decorator), 948 r'late|literal|doc|by|see|throws|optional|license|tagged|final|native|'
940 (r'(break|case|catch|continue|default|else|finally|for|in|' 949 r'annotation|sealed)\b', Name.Decorator),
941 r'variable|if|return|switch|this|throw|try|while|is|exists|dynamic|' 950 (r'(break|case|catch|continue|else|finally|for|in|'
942 r'nonempty|then|outer|assert)\b', Keyword), 951 r'if|return|switch|this|throw|try|while|is|exists|dynamic|'
943 (r'(abstracts|extends|satisfies|adapts|' 952 r'nonempty|then|outer|assert|let)\b', Keyword),
944 r'super|given|of|out|assign|' 953 (r'(abstracts|extends|satisfies|'
945 r'transient|volatile)\b', Keyword.Declaration), 954 r'super|given|of|out|assign)\b', Keyword.Declaration),
946 (r'(function|value|void)\b', 955 (r'(function|value|void|new)\b',
947 Keyword.Type), 956 Keyword.Type),
948 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), 957 (r'(assembly|module|package)(\s+)', bygroups(Keyword.Namespace, Text)),
949 (r'(true|false|null)\b', Keyword.Constant), 958 (r'(true|false|null)\b', Keyword.Constant),
950 (r'(class|interface|object|alias)(\s+)', 959 (r'(class|interface|object|alias)(\s+)',
951 bygroups(Keyword.Declaration, Text), 'class'), 960 bygroups(Keyword.Declaration, Text), 'class'),
952 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 961 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
953 (r'"(\\\\|\\"|[^"])*"', String), 962 (r'"(\\\\|\\"|[^"])*"', String),
988 } 997 }
989 998
990 999
991 class KotlinLexer(RegexLexer): 1000 class KotlinLexer(RegexLexer):
992 """ 1001 """
993 For `Kotlin <http://kotlin.jetbrains.org/>`_ 1002 For `Kotlin <http://kotlinlang.org/>`_
994 source code. 1003 source code.
995 1004
996 .. versionadded:: 1.5 1005 .. versionadded:: 1.5
997 """ 1006 """
998 1007
1023 (r'"(\\\\|\\"|[^"\n])*["\n]', String), 1032 (r'"(\\\\|\\"|[^"\n])*["\n]', String),
1024 (r"'\\.'|'[^\\]'", String.Char), 1033 (r"'\\.'|'[^\\]'", String.Char),
1025 (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|" 1034 (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|"
1026 r"0[xX][0-9a-fA-F]+[Ll]?", Number), 1035 r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1027 (r'(class)(\s+)(object)', bygroups(Keyword, Text, Keyword)), 1036 (r'(class)(\s+)(object)', bygroups(Keyword, Text, Keyword)),
1028 (r'(class|trait|object)(\s+)', bygroups(Keyword, Text), 'class'), 1037 (r'(class|interface|object)(\s+)', bygroups(Keyword, Text), 'class'),
1029 (r'(package|import)(\s+)', bygroups(Keyword, Text), 'package'), 1038 (r'(package|import)(\s+)', bygroups(Keyword, Text), 'package'),
1030 (r'(val|var)(\s+)', bygroups(Keyword, Text), 'property'), 1039 (r'(val|var)(\s+)', bygroups(Keyword, Text), 'property'),
1031 (r'(fun)(\s+)', bygroups(Keyword, Text), 'function'), 1040 (r'(fun)(\s+)', bygroups(Keyword, Text), 'function'),
1032 (r'(abstract|annotation|as|break|by|catch|class|continue|do|else|' 1041 (r'(abstract|annotation|as|break|by|catch|class|companion|const|'
1033 r'enum|false|final|finally|for|fun|get|if|import|in|inner|' 1042 r'constructor|continue|crossinline|data|do|dynamic|else|enum|'
1034 r'internal|is|null|object|open|out|override|package|private|' 1043 r'external|false|final|finally|for|fun|get|if|import|in|infix|'
1035 r'protected|public|reified|return|set|super|this|throw|trait|' 1044 r'inline|inner|interface|internal|is|lateinit|noinline|null|'
1036 r'true|try|type|val|var|vararg|when|where|while|This)\b', Keyword), 1045 r'object|open|operator|out|override|package|private|protected|'
1046 r'public|reified|return|sealed|set|super|tailrec|this|throw|'
1047 r'true|try|val|var|vararg|when|where|while)\b', Keyword),
1037 (kt_id, Name), 1048 (kt_id, Name),
1038 ], 1049 ],
1039 'package': [ 1050 'package': [
1040 (r'\S+', Name.Namespace, '#pop') 1051 (r'\S+', Name.Namespace, '#pop')
1041 ], 1052 ],

eric ide

mercurial