eric6/ThirdParty/Pygments/pygments/lexers/jvm.py

changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
equal deleted inserted replaced
7982:48d210e41c65 7983:54c5cfbb1e29
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-2020 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2021 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
63 'class'), 63 'class'),
64 (r'(var)(\s+)', bygroups(Keyword.Declaration, Text), 64 (r'(var)(\s+)', bygroups(Keyword.Declaration, Text),
65 'var'), 65 'var'),
66 (r'(import(?:\s+static)?)(\s+)', bygroups(Keyword.Namespace, Text), 66 (r'(import(?:\s+static)?)(\s+)', bygroups(Keyword.Namespace, Text),
67 'import'), 67 'import'),
68 (r'"(\\\\|\\"|[^"])*"', String), 68 (r'"', String, 'string'),
69 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 69 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
70 (r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Punctuation, 70 (r'(\.)((?:[^\W\d]|\$)[\w$]*)', bygroups(Punctuation,
71 Name.Attribute)), 71 Name.Attribute)),
72 (r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label), 72 (r'^\s*([^\W\d]|\$)[\w$]*:', Name.Label),
73 (r'([^\W\d]|\$)[\w$]*', Name), 73 (r'([^\W\d]|\$)[\w$]*', Name),
93 'var': [ 93 'var': [
94 (r'([^\W\d]|\$)[\w$]*', Name, '#pop') 94 (r'([^\W\d]|\$)[\w$]*', Name, '#pop')
95 ], 95 ],
96 'import': [ 96 'import': [
97 (r'[\w.]+\*?', Name.Namespace, '#pop') 97 (r'[\w.]+\*?', Name.Namespace, '#pop')
98 ],
99 'string': [
100 (r'[^\\"]+', String),
101 (r'\\\\', String), # Escaped backslash
102 (r'\\"', String), # Escaped quote
103 (r'\\', String), # Bare backslash
104 (r'"', String, '#pop'), # Closing quote
98 ], 105 ],
99 } 106 }
100 107
101 108
102 class AspectJLexer(JavaLexer): 109 class AspectJLexer(JavaLexer):
283 (r'%s%s\b' % (upper, idrest), Name.Class), 290 (r'%s%s\b' % (upper, idrest), Name.Class),
284 (r'(true|false|null)\b', Keyword.Constant), 291 (r'(true|false|null)\b', Keyword.Constant),
285 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'), 292 (r'(import|package)(\s+)', bygroups(Keyword, Text), 'import'),
286 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'), 293 (r'(type)(\s+)', bygroups(Keyword, Text), 'type'),
287 (r'""".*?"""(?!")', String), 294 (r'""".*?"""(?!")', String),
288 (r'"(\\\\|\\"|[^"])*"', String), 295 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
289 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 296 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
290 (r"'%s" % idrest, Text.Symbol), 297 (r"'%s" % idrest, Text.Symbol),
291 (r'[fs]"""', String, 'interptriplestring'), # interpolated strings 298 (r'[fs]"""', String, 'interptriplestring'), # interpolated strings
292 (r'[fs]"', String, 'interpstring'), # interpolated strings 299 (r'[fs]"', String, 'interpstring'), # interpolated strings
293 (r'raw"(\\\\|\\"|[^"])*"', String), # raw strings 300 (r'raw"(\\\\|\\[^\\]|[^"\\])*"', String), # raw strings
294 # (r'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator, 301 # (r'(\.)(%s|%s|`[^`]+`)' % (idrest, op), bygroups(Operator,
295 # Name.Attribute)), 302 # Name.Attribute)),
296 (idrest, Name), 303 (idrest, Name),
297 (r'`[^`]+`', Name), 304 (r'`[^`]+`', Name),
298 (r'\[', Operator, 'typeparam'), 305 (r'\[', Operator, 'typeparam'),
513 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 520 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
514 'class'), 521 'class'),
515 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 522 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
516 (r'""".*?"""', String.Double), 523 (r'""".*?"""', String.Double),
517 (r"'''.*?'''", String.Single), 524 (r"'''.*?'''", String.Single),
518 (r'"(\\\\|\\"|[^"])*"', String.Double), 525 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
519 (r"'(\\\\|\\'|[^'])*'", String.Single), 526 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
520 (r'\$/((?!/\$).)*/\$', String), 527 (r'\$/((?!/\$).)*/\$', String),
521 (r'/(\\\\|\\"|[^/])*/', String), 528 (r'/(\\\\|\\[^\\]|[^/\\])*/', String),
522 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char), 529 (r"'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'", String.Char),
523 (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), 530 (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
524 (r'[a-zA-Z_]\w*:', Name.Label), 531 (r'[a-zA-Z_]\w*:', Name.Label),
525 (r'[a-zA-Z_$]\w*', Name), 532 (r'[a-zA-Z_$]\w*', Name),
526 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator), 533 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
609 (r'#r\[', String.Regex, 'squareRegexp'), 616 (r'#r\[', String.Regex, 'squareRegexp'),
610 617
611 # Symbols 618 # Symbols
612 (r':[\w!:?]+', String.Symbol), 619 (r':[\w!:?]+', String.Symbol),
613 (r'[\w!:?]+:(?![\w!?])', String.Other), 620 (r'[\w!:?]+:(?![\w!?])', String.Other),
614 (r':"(\\\\|\\"|[^"])*"', String.Symbol), 621 (r':"(\\\\|\\[^\\]|[^"\\])*"', String.Symbol),
615 622
616 # Documentation 623 # Documentation
617 (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()' 624 (r'((?<=fn\()|(?<=fnx\()|(?<=method\()|(?<=macro\()|(?<=lecro\()'
618 r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()' 625 r'|(?<=syntax\()|(?<=dmacro\()|(?<=dlecro\()|(?<=dlecrox\()'
619 r'|(?<=dsyntax\())\s*"', String.Doc, 'documentation'), 626 r'|(?<=dsyntax\())\s*"', String.Doc, 'documentation'),
827 (r'-?\d+\.\d+', Number.Float), 834 (r'-?\d+\.\d+', Number.Float),
828 (r'-?\d+', Number.Integer), 835 (r'-?\d+', Number.Integer),
829 (r'0x-?[abcdef\d]+', Number.Hex), 836 (r'0x-?[abcdef\d]+', Number.Hex),
830 837
831 # strings, symbols and characters 838 # strings, symbols and characters
832 (r'"(\\\\|\\"|[^"])*"', String), 839 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
833 (r"'" + valid_name, String.Symbol), 840 (r"'" + valid_name, String.Symbol),
834 (r"\\(.|[a-z]+)", String.Char), 841 (r"\\(.|[a-z]+)", String.Char),
835 842
836 # keywords 843 # keywords
837 (r'::?#?' + valid_name, String.Symbol), 844 (r'::?#?' + valid_name, String.Symbol),
908 Keyword), 915 Keyword),
909 (r'(as|call|define)\b', Keyword.Declaration), 916 (r'(as|call|define)\b', Keyword.Declaration),
910 (r'(true|false|null)\b', Keyword.Constant), 917 (r'(true|false|null)\b', Keyword.Constant),
911 (r'(template)(\s+)', bygroups(Keyword.Declaration, Text), 'template'), 918 (r'(template)(\s+)', bygroups(Keyword.Declaration, Text), 'template'),
912 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 919 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
913 (r'"(\\\\|\\"|[^"])*"', String), 920 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
914 (r'\'(\\\\|\\\'|[^\'])*\'', String), 921 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
915 (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)), 922 (r'(\.)([a-zA-Z_]\w*)', bygroups(Operator, Name.Attribute)),
916 (r'[a-zA-Z_]\w*:', Name.Label), 923 (r'[a-zA-Z_]\w*:', Name.Label),
917 (r'[a-zA-Z_\$]\w*', Name), 924 (r'[a-zA-Z_\$]\w*', Name),
918 (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator), 925 (r'(isa|[.]{3}|[.]{2}|[=#!<>+-/%&;,.\*\\\(\)\[\]\{\}])', Operator),
919 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 926 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
970 (r'(assembly|module|package)(\s+)', bygroups(Keyword.Namespace, Text)), 977 (r'(assembly|module|package)(\s+)', bygroups(Keyword.Namespace, Text)),
971 (r'(true|false|null)\b', Keyword.Constant), 978 (r'(true|false|null)\b', Keyword.Constant),
972 (r'(class|interface|object|alias)(\s+)', 979 (r'(class|interface|object|alias)(\s+)',
973 bygroups(Keyword.Declaration, Text), 'class'), 980 bygroups(Keyword.Declaration, Text), 'class'),
974 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 981 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
975 (r'"(\\\\|\\"|[^"])*"', String), 982 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),
976 (r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char), 983 (r"'\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'", String.Char),
977 (r'".*``.*``.*"', String.Interpol),
978 (r'(\.)([a-z_]\w*)', 984 (r'(\.)([a-z_]\w*)',
979 bygroups(Operator, Name.Attribute)), 985 bygroups(Operator, Name.Attribute)),
980 (r'[a-zA-Z_]\w*:', Name.Label), 986 (r'[a-zA-Z_]\w*:', Name.Label),
981 (r'[a-zA-Z_]\w*', Name), 987 (r'[a-zA-Z_]\w*', Name),
982 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator), 988 (r'[~^*!%&\[\](){}<>|+=:;,./?-]', Operator),
1018 .. versionadded:: 1.5 1024 .. versionadded:: 1.5
1019 """ 1025 """
1020 1026
1021 name = 'Kotlin' 1027 name = 'Kotlin'
1022 aliases = ['kotlin'] 1028 aliases = ['kotlin']
1023 filenames = ['*.kt'] 1029 filenames = ['*.kt', '*.kts']
1024 mimetypes = ['text/x-kotlin'] 1030 mimetypes = ['text/x-kotlin']
1025 1031
1026 flags = re.MULTILINE | re.DOTALL | re.UNICODE 1032 flags = re.MULTILINE | re.DOTALL | re.UNICODE
1027 1033
1028 kt_name = ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' + 1034 kt_name = ('@?[_' + uni.combine('Lu', 'Ll', 'Lt', 'Lm', 'Nl') + ']' +
1040 (r'^\s*\[.*?\]', Name.Attribute), 1046 (r'^\s*\[.*?\]', Name.Attribute),
1041 (r'[^\S\n]+', Text), 1047 (r'[^\S\n]+', Text),
1042 (r'\s+', Text), 1048 (r'\s+', Text),
1043 (r'\\\n', Text), # line continuation 1049 (r'\\\n', Text), # line continuation
1044 (r'//.*?\n', Comment.Single), 1050 (r'//.*?\n', Comment.Single),
1051 (r'^#!/.+?\n', Comment.Single), # shebang for kotlin scripts
1045 (r'/[*].*?[*]/', Comment.Multiline), 1052 (r'/[*].*?[*]/', Comment.Multiline),
1046 (r'""".*?"""', String), 1053 (r'""".*?"""', String),
1047 (r'\n', Text), 1054 (r'\n', Text),
1048 (r'::|!!|\?[:.]', Operator), 1055 (r'::|!!|\?[:.]', Operator),
1049 (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation), 1056 (r'[~!%^&*()+=|\[\]:;,.<>/?-]', Punctuation),
1050 (r'[{}]', Punctuation), 1057 (r'[{}]', Punctuation),
1051 (r'@"(""|[^"])*"', String), 1058 (r'@"(""|[^"])*"', String),
1052 (r'"(\\\\|\\"|[^"\n])*["\n]', String), 1059 (r'"(\\\\|\\[^\\]|[^"\\\n])*["\n]', String),
1053 (r"'\\.'|'[^\\]'", String.Char), 1060 (r"'\\.'|'[^\\]'", String.Char),
1054 (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|" 1061 (r"[0-9](\.[0-9]*)?([eE][+-][0-9]+)?[flFL]?|"
1055 r"0[xX][0-9a-fA-F]+[Ll]?", Number), 1062 r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1056 (r'(object)(\s+)(:)(\s+)', bygroups(Keyword, Text, Punctuation, Text), 'class'), 1063 (r'(object)(\s+)(:)(\s+)', bygroups(Keyword, Text, Punctuation, Text), 'class'),
1057 (r'(companion)(\s+)(object)', bygroups(Keyword, Text, Keyword)), 1064 (r'(companion)(\s+)(object)', bygroups(Keyword, Text, Keyword)),
1141 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text), 1148 (r'(class|interface)(\s+)', bygroups(Keyword.Declaration, Text),
1142 'class'), 1149 'class'),
1143 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 1150 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1144 (r"(''')", String, 'template'), 1151 (r"(''')", String, 'template'),
1145 (r'(\u00BB)', String, 'template'), 1152 (r'(\u00BB)', String, 'template'),
1146 (r'"(\\\\|\\"|[^"])*"', String), 1153 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
1147 (r"'(\\\\|\\'|[^'])*'", String), 1154 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
1148 (r'[a-zA-Z_]\w*:', Name.Label), 1155 (r'[a-zA-Z_]\w*:', Name.Label),
1149 (r'[a-zA-Z_$]\w*', Name), 1156 (r'[a-zA-Z_$]\w*', Name),
1150 (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator), 1157 (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator),
1151 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 1158 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1152 (r'0x[0-9a-fA-F]+', Number.Hex), 1159 (r'0x[0-9a-fA-F]+', Number.Hex),
1610 score += 0.6 1617 score += 0.6
1611 return score 1618 return score
1612 1619
1613 1620
1614 class SarlLexer(RegexLexer): 1621 class SarlLexer(RegexLexer):
1615 """ 1622 """
1616 For `SARL <http://www.sarl.io>`_ source code. 1623 For `SARL <http://www.sarl.io>`_ source code.
1617 1624
1618 .. versionadded:: 2.4 1625 .. versionadded:: 2.4
1619 """ 1626 """
1620 1627
1621 name = 'SARL' 1628 name = 'SARL'
1622 aliases = ['sarl'] 1629 aliases = ['sarl']
1623 filenames = ['*.sarl'] 1630 filenames = ['*.sarl']
1624 mimetypes = ['text/x-sarl'] 1631 mimetypes = ['text/x-sarl']
1625 1632
1626 flags = re.MULTILINE | re.DOTALL 1633 flags = re.MULTILINE | re.DOTALL
1627 1634
1628 tokens = { 1635 tokens = {
1629 'root': [ 1636 'root': [
1630 # method names 1637 # method names
1631 (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments 1638 (r'^(\s*(?:[a-zA-Z_][\w.\[\]]*\s+)+?)' # return arguments
1632 r'([a-zA-Z_$][\w$]*)' # method name 1639 r'([a-zA-Z_$][\w$]*)' # method name
1633 r'(\s*)(\()', # signature start 1640 r'(\s*)(\()', # signature start
1634 bygroups(using(this), Name.Function, Text, Operator)), 1641 bygroups(using(this), Name.Function, Text, Operator)),
1635 (r'[^\S\n]+', Text), 1642 (r'[^\S\n]+', Text),
1636 (r'//.*?\n', Comment.Single), 1643 (r'//.*?\n', Comment.Single),
1637 (r'/\*.*?\*/', Comment.Multiline), 1644 (r'/\*.*?\*/', Comment.Multiline),
1638 (r'@[a-zA-Z_][\w.]*', Name.Decorator), 1645 (r'@[a-zA-Z_][\w.]*', Name.Decorator),
1639 (r'(as|break|case|catch|default|do|else|extends|extension|finally|fires|for|if|implements|instanceof|new|on|requires|return|super|switch|throw|throws|try|typeof|uses|while|with)\b', 1646 (r'(as|break|case|catch|default|do|else|extends|extension|finally|'
1640 Keyword), 1647 r'fires|for|if|implements|instanceof|new|on|requires|return|super|'
1641 (r'(abstract|def|dispatch|final|native|override|private|protected|public|static|strictfp|synchronized|transient|val|var|volatile)\b', Keyword.Declaration), 1648 r'switch|throw|throws|try|typeof|uses|while|with)\b',
1642 (r'(boolean|byte|char|double|float|int|long|short|void)\b', 1649 Keyword),
1643 Keyword.Type), 1650 (r'(abstract|def|dispatch|final|native|override|private|protected|'
1644 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)), 1651 r'public|static|strictfp|synchronized|transient|val|var|volatile)\b',
1645 (r'(false|it|null|occurrence|this|true|void)\b', Keyword.Constant), 1652 Keyword.Declaration),
1646 (r'(agent|annotation|artifact|behavior|capacity|class|enum|event|interface|skill|space)(\s+)', bygroups(Keyword.Declaration, Text), 1653 (r'(boolean|byte|char|double|float|int|long|short|void)\b',
1647 'class'), 1654 Keyword.Type),
1648 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'), 1655 (r'(package)(\s+)', bygroups(Keyword.Namespace, Text)),
1649 (r'"(\\\\|\\"|[^"])*"', String), 1656 (r'(false|it|null|occurrence|this|true|void)\b', Keyword.Constant),
1650 (r"'(\\\\|\\'|[^'])*'", String), 1657 (r'(agent|annotation|artifact|behavior|capacity|class|enum|event|'
1651 (r'[a-zA-Z_]\w*:', Name.Label), 1658 r'interface|skill|space)(\s+)', bygroups(Keyword.Declaration, Text),
1652 (r'[a-zA-Z_$]\w*', Name), 1659 'class'),
1653 (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator), 1660 (r'(import)(\s+)', bygroups(Keyword.Namespace, Text), 'import'),
1654 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), 1661 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),
1655 (r'0x[0-9a-fA-F]+', Number.Hex), 1662 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),
1656 (r'[0-9]+L?', Number.Integer), 1663 (r'[a-zA-Z_]\w*:', Name.Label),
1657 (r'\n', Text) 1664 (r'[a-zA-Z_$]\w*', Name),
1658 ], 1665 (r'[~^*!%&\[\](){}<>\|+=:;,./?-]', Operator),
1659 'class': [ 1666 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
1660 (r'[a-zA-Z_]\w*', Name.Class, '#pop') 1667 (r'0x[0-9a-fA-F]+', Number.Hex),
1661 ], 1668 (r'[0-9]+L?', Number.Integer),
1662 'import': [ 1669 (r'\n', Text)
1663 (r'[\w.]+\*?', Name.Namespace, '#pop') 1670 ],
1664 ], 1671 'class': [
1665 } 1672 (r'[a-zA-Z_]\w*', Name.Class, '#pop')
1673 ],
1674 'import': [
1675 (r'[\w.]+\*?', Name.Namespace, '#pop')
1676 ],
1677 }

eric ide

mercurial