codekingpro/portable-devtools
114k
1"""2 pygments.lexers.scripting3 ~~~~~~~~~~~~~~~~~~~~~~~~~4 5 Lexer for scripting and embedded languages.6 7 :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8 :license: BSD, see LICENSE for details.9"""10 11import re12 13from pygments.lexer import RegexLexer, include, bygroups, default, combined, \14 words15from pygments.token import Text, Comment, Operator, Keyword, Name, String, \16 Number, Punctuation, Error, Whitespace, Other17from pygments.util import get_bool_opt, get_list_opt18 19__all__ = ['LuaLexer', 'LuauLexer', 'MoonScriptLexer', 'ChaiscriptLexer', 'LSLLexer',20 'AppleScriptLexer', 'RexxLexer', 'MOOCodeLexer', 'HybrisLexer',21 'EasytrieveLexer', 'JclLexer', 'MiniScriptLexer']22 23 24def all_lua_builtins():25 from pygments.lexers._lua_builtins import MODULES26 return [w for values in MODULES.values() for w in values]27 28class LuaLexer(RegexLexer):29 """30 For Lua source code.31 32 Additional options accepted:33 34 `func_name_highlighting`35 If given and ``True``, highlight builtin function names36 (default: ``True``).37 `disabled_modules`38 If given, must be a list of module names whose function names39 should not be highlighted. By default all modules are highlighted.40 41 To get a list of allowed modules have a look into the42 `_lua_builtins` module:43 44 .. sourcecode:: pycon45 46 >>> from pygments.lexers._lua_builtins import MODULES47 >>> MODULES.keys()48 ['string', 'coroutine', 'modules', 'io', 'basic', ...]49 """50 51 name = 'Lua'52 url = 'https://www.lua.org/'53 aliases = ['lua']54 filenames = ['*.lua', '*.wlua']55 mimetypes = ['text/x-lua', 'application/x-lua']56 version_added = ''57 58 _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'59 _comment_single = r'(?:--.*$)'60 _space = r'(?:\s+(?!\s))'61 _s = rf'(?:{_comment_multiline}|{_comment_single}|{_space})'62 # A lookahead-safe version of _s that avoids catastrophic backtracking.63 # The _comment_multiline pattern contains [\w\W]*? which, when used64 # inside a lookahead with a * quantifier, causes exponential blowup.65 # This version skips only whitespace; comments between an identifier66 # and a following [.:] or ( are rare enough to sacrifice.67 _s_la = r'\s'68 _name = r'(?:[^\W\d]\w*)'69 70 tokens = {71 'root': [72 # Lua allows a file to start with a shebang.73 (r'#!.*', Comment.Preproc),74 default('base'),75 ],76 'ws': [77 (_comment_multiline, Comment.Multiline),78 (_comment_single, Comment.Single),79 (_space, Whitespace),80 ],81 'base': [82 include('ws'),83 84 (r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex),85 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),86 (r'(?i)\d+e[+-]?\d+', Number.Float),87 (r'\d+', Number.Integer),88 89 # multiline strings90 (r'(?s)\[(=*)\[.*?\]\1\]', String),91 92 (r'::', Punctuation, 'label'),93 (r'\.{3}', Punctuation),94 (r'[=<>|~&+\-*/%#^]+|\.\.', Operator),95 (r'[\[\]{}().,:;]+', Punctuation),96 (r'(and|or|not)\b', Operator.Word),97 98 (words([99 'break', 'do', 'else', 'elseif', 'end', 'for', 'if', 'in',100 'repeat', 'return', 'then', 'until', 'while'101 ], suffix=r'\b'), Keyword.Reserved),102 (r'goto\b', Keyword.Reserved, 'goto'),103 (r'(local)\b', Keyword.Declaration),104 (r'(true|false|nil)\b', Keyword.Constant),105 106 (r'(function)\b', Keyword.Reserved, 'funcname'),107 108 (words(all_lua_builtins(), suffix=r"\b"), Name.Builtin),109 (fr'[A-Za-z_]\w*(?={_s_la}*[.:])', Name.Variable, 'varname'),110 (fr'[A-Za-z_]\w*(?={_s_la}*\()', Name.Function),111 (r'[A-Za-z_]\w*', Name.Variable),112 113 ("'", String.Single, combined('stringescape', 'sqs')),114 ('"', String.Double, combined('stringescape', 'dqs'))115 ],116 117 'varname': [118 include('ws'),119 (r'\.\.', Operator, '#pop'),120 (r'[.:]', Punctuation),121 (rf'{_name}(?={_s_la}*[.:])', Name.Property),122 (rf'{_name}(?={_s_la}*\()', Name.Function, '#pop'),123 (_name, Name.Property, '#pop'),124 ],125 126 'funcname': [127 include('ws'),128 (r'[.:]', Punctuation),129 (rf'{_name}(?={_s_la}*[.:])', Name.Class),130 (_name, Name.Function, '#pop'),131 # inline function132 (r'\(', Punctuation, '#pop'),133 ],134 135 'goto': [136 include('ws'),137 (_name, Name.Label, '#pop'),138 ],139 140 'label': [141 include('ws'),142 (r'::', Punctuation, '#pop'),143 (_name, Name.Label),144 ],145 146 'stringescape': [147 (r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|'148 r'u\{[0-9a-fA-F]+\})', String.Escape),149 ],150 151 'sqs': [152 (r"'", String.Single, '#pop'),153 (r"[^\\']+", String.Single),154 ],155 156 'dqs': [157 (r'"', String.Double, '#pop'),158 (r'[^\\"]+', String.Double),159 ]160 }161 162 def __init__(self, **options):163 self.func_name_highlighting = get_bool_opt(164 options, 'func_name_highlighting', True)165 self.disabled_modules = get_list_opt(options, 'disabled_modules', [])166 167 self._functions = set()168 if self.func_name_highlighting:169 from pygments.lexers._lua_builtins import MODULES170 for mod, func in MODULES.items():171 if mod not in self.disabled_modules:172 self._functions.update(func)173 RegexLexer.__init__(self, **options)174 175 def get_tokens_unprocessed(self, text):176 for index, token, value in \177 RegexLexer.get_tokens_unprocessed(self, text):178 if token is Name.Builtin and value not in self._functions:179 if '.' in value:180 a, b = value.split('.')181 yield index, Name, a182 yield index + len(a), Punctuation, '.'183 yield index + len(a) + 1, Name, b184 else:185 yield index, Name, value186 continue187 yield index, token, value188 189def _luau_make_expression(should_pop, _s, _s_la):190 temp_list = [191 (r'0[xX][\da-fA-F_]*', Number.Hex, '#pop'),192 (r'0[bB][\d_]*', Number.Bin, '#pop'),193 (r'\.?\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?', Number.Float, '#pop'),194 195 (words((196 'true', 'false', 'nil'197 ), suffix=r'\b'), Keyword.Constant, '#pop'),198 199 (r'\[(=*)\[[.\n]*?\]\1\]', String, '#pop'),200 201 (r'(\.)([a-zA-Z_]\w*)(?=%s*[({"\'])', bygroups(Punctuation, Name.Function), '#pop'),202 (r'(\.)([a-zA-Z_]\w*)', bygroups(Punctuation, Name.Variable), '#pop'),203 204 (rf'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?={_s_la}*[({{"\'])', Name.Other, '#pop'),205 (r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*', Name, '#pop'),206 ]207 if should_pop:208 return temp_list209 return [entry[:2] for entry in temp_list]210 211def _luau_make_expression_special(should_pop):212 temp_list = [213 (r'\{', Punctuation, ('#pop', 'closing_brace_base', 'expression')),214 (r'\(', Punctuation, ('#pop', 'closing_parenthesis_base', 'expression')),215 216 (r'::?', Punctuation, ('#pop', 'type_end', 'type_start')),217 218 (r"'", String.Single, ('#pop', 'string_single')),219 (r'"', String.Double, ('#pop', 'string_double')),220 (r'`', String.Backtick, ('#pop', 'string_interpolated')),221 ]222 if should_pop:223 return temp_list224 return [(entry[0], entry[1], entry[2][1:]) for entry in temp_list]225 226class LuauLexer(RegexLexer):227 """228 For Luau source code.229 230 Additional options accepted:231 232 `include_luau_builtins`233 If given and ``True``, automatically highlight Luau builtins234 (default: ``True``).235 `include_roblox_builtins`236 If given and ``True``, automatically highlight Roblox-specific builtins237 (default: ``False``).238 `additional_builtins`239 If given, must be a list of additional builtins to highlight.240 `disabled_builtins`241 If given, must be a list of builtins that will not be highlighted.242 """243 244 name = 'Luau'245 url = 'https://luau-lang.org/'246 aliases = ['luau']247 filenames = ['*.luau']248 version_added = '2.18'249 250 _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'251 _comment_single = r'(?:--.*$)'252 _s = r'(?:{}|{}|{})'.format(_comment_multiline, _comment_single, r'\s+')253 # Lookahead-safe version — avoids catastrophic backtracking from254 # [\w\W]*? inside _comment_multiline when combined with * quantifier.255 _s_la = r'\s'256 257 tokens = {258 'root': [259 (r'#!.*', Comment.Hashbang, 'base'),260 default('base'),261 ],262 263 'ws': [264 (_comment_multiline, Comment.Multiline),265 (_comment_single, Comment.Single),266 (r'\s+', Whitespace),267 ],268 269 'base': [270 include('ws'),271 272 *_luau_make_expression_special(False),273 (r'\.\.\.', Punctuation),274 275 (rf'type\b(?={_s}+[a-zA-Z_])', Keyword.Reserved, 'type_declaration'),276 (rf'export\b(?={_s}+[a-zA-Z_])', Keyword.Reserved),277 278 (r'(?:\.\.|//|[+\-*\/%^<>=])=?', Operator, 'expression'),279 (r'~=', Operator, 'expression'),280 281 (words((282 'and', 'or', 'not'283 ), suffix=r'\b'), Operator.Word, 'expression'),284 285 (words((286 'elseif', 'for', 'if', 'in', 'repeat', 'return', 'until',287 'while'), suffix=r'\b'), Keyword.Reserved, 'expression'),288 (r'local\b', Keyword.Declaration, 'expression'),289 290 (r'function\b', Keyword.Reserved, ('expression', 'func_name')),291 292 (r'[\])};]+', Punctuation),293 294 include('expression_static'),295 *_luau_make_expression(False, _s, _s_la),296 297 (r'[\[.,]', Punctuation, 'expression'),298 ],299 'expression_static': [300 (words((301 'break', 'continue', 'do', 'else', 'elseif', 'end', 'for',302 'if', 'in', 'repeat', 'return', 'then', 'until', 'while'),303 suffix=r'\b'), Keyword.Reserved),304 ],305 'expression': [306 include('ws'),307 308 (r'if\b', Keyword.Reserved, ('ternary', 'expression')),309 310 (r'local\b', Keyword.Declaration),311 *_luau_make_expression_special(True),312 (r'\.\.\.', Punctuation, '#pop'),313 314 (r'function\b', Keyword.Reserved, 'func_name'),315 316 include('expression_static'),317 *_luau_make_expression(True, _s, _s_la),318 319 default('#pop'),320 ],321 'ternary': [322 include('ws'),323 324 (r'else\b', Keyword.Reserved, '#pop'),325 (words((326 'then', 'elseif',327 ), suffix=r'\b'), Operator.Reserved, 'expression'),328 329 default('#pop'),330 ],331 332 'closing_brace_pop': [333 (r'\}', Punctuation, '#pop'),334 ],335 'closing_parenthesis_pop': [336 (r'\)', Punctuation, '#pop'),337 ],338 'closing_gt_pop': [339 (r'>', Punctuation, '#pop'),340 ],341 342 'closing_parenthesis_base': [343 include('closing_parenthesis_pop'),344 include('base'),345 ],346 'closing_parenthesis_type': [347 include('closing_parenthesis_pop'),348 include('type'),349 ],350 'closing_brace_base': [351 include('closing_brace_pop'),352 include('base'),353 ],354 'closing_brace_type': [355 include('closing_brace_pop'),356 include('type'),357 ],358 'closing_gt_type': [359 include('closing_gt_pop'),360 include('type'),361 ],362 363 'string_escape': [364 (r'\\z\s*', String.Escape),365 (r'\\(?:[abfnrtvz\\"\'`\{\n])|[\r\n]{1,2}|x[\da-fA-F]{2}|\d{1,3}|'366 r'u\{\}[\da-fA-F]*\}', String.Escape),367 ],368 'string_single': [369 include('string_escape'),370 371 (r"'", String.Single, "#pop"),372 (r"[^\\']+", String.Single),373 ],374 'string_double': [375 include('string_escape'),376 377 (r'"', String.Double, "#pop"),378 (r'[^\\"]+', String.Double),379 ],380 'string_interpolated': [381 include('string_escape'),382 383 (r'\{', Punctuation, ('closing_brace_base', 'expression')),384 385 (r'`', String.Backtick, "#pop"),386 (r'[^\\`\{]+', String.Backtick),387 ],388 389 'func_name': [390 include('ws'),391 392 (r'[.:]', Punctuation),393 (rf'[a-zA-Z_]\w*(?={_s_la}*[.:])', Name.Class),394 (r'[a-zA-Z_]\w*', Name.Function),395 396 (r'<', Punctuation, 'closing_gt_type'),397 398 (r'\(', Punctuation, '#pop'),399 ],400 401 'type': [402 include('ws'),403 404 (r'\(', Punctuation, 'closing_parenthesis_type'),405 (r'\{', Punctuation, 'closing_brace_type'),406 (r'<', Punctuation, 'closing_gt_type'),407 408 (r"'", String.Single, 'string_single'),409 (r'"', String.Double, 'string_double'),410 411 (r'[|&\.,\[\]:=]+', Punctuation),412 (r'->', Punctuation),413 414 (r'typeof\(', Name.Builtin, ('closing_parenthesis_base',415 'expression')),416 (r'[a-zA-Z_]\w*', Name.Class),417 ],418 'type_start': [419 include('ws'),420 421 (r'\(', Punctuation, ('#pop', 'closing_parenthesis_type')),422 (r'\{', Punctuation, ('#pop', 'closing_brace_type')),423 (r'<', Punctuation, ('#pop', 'closing_gt_type')),424 425 (r"'", String.Single, ('#pop', 'string_single')),426 (r'"', String.Double, ('#pop', 'string_double')),427 428 (r'typeof\(', Name.Builtin, ('#pop', 'closing_parenthesis_base',429 'expression')),430 (r'[a-zA-Z_]\w*', Name.Class, '#pop'),431 ],432 'type_end': [433 include('ws'),434 435 (r'[|&\.]', Punctuation, 'type_start'),436 (r'->', Punctuation, 'type_start'),437 438 (r'<', Punctuation, 'closing_gt_type'),439 440 default('#pop'),441 ],442 'type_declaration': [443 include('ws'),444 445 (r'[a-zA-Z_]\w*', Name.Class),446 (r'<', Punctuation, 'closing_gt_type'),447 448 (r'=', Punctuation, ('#pop', 'type_end', 'type_start')),449 ],450 }451 452 def __init__(self, **options):453 self.include_luau_builtins = get_bool_opt(454 options, 'include_luau_builtins', True)455 self.include_roblox_builtins = get_bool_opt(456 options, 'include_roblox_builtins', False)457 self.additional_builtins = get_list_opt(options, 'additional_builtins', [])458 self.disabled_builtins = get_list_opt(options, 'disabled_builtins', [])459 460 self._builtins = set(self.additional_builtins)461 if self.include_luau_builtins:462 from pygments.lexers._luau_builtins import LUAU_BUILTINS463 self._builtins.update(LUAU_BUILTINS)464 if self.include_roblox_builtins:465 from pygments.lexers._luau_builtins import ROBLOX_BUILTINS466 self._builtins.update(ROBLOX_BUILTINS)467 if self.additional_builtins:468 self._builtins.update(self.additional_builtins)469 self._builtins.difference_update(self.disabled_builtins)470 471 RegexLexer.__init__(self, **options)472 473 def get_tokens_unprocessed(self, text):474 for index, token, value in \475 RegexLexer.get_tokens_unprocessed(self, text):476 if token is Name or token is Name.Other:477 split_value = value.split('.')478 complete_value = []479 new_index = index480 for position in range(len(split_value), 0, -1):481 potential_string = '.'.join(split_value[:position])482 if potential_string in self._builtins:483 yield index, Name.Builtin, potential_string484 new_index += len(potential_string)485 486 if complete_value:487 yield new_index, Punctuation, '.'488 new_index += 1489 break490 complete_value.insert(0, split_value[position - 1])491 492 for position, substring in enumerate(complete_value):493 if position + 1 == len(complete_value):494 if token is Name:495 yield new_index, Name.Variable, substring496 continue497 yield new_index, Name.Function, substring498 continue499 yield new_index, Name.Variable, substring500 new_index += len(substring)501 yield new_index, Punctuation, '.'502 new_index += 1503 504 continue505 yield index, token, value506 507class MoonScriptLexer(LuaLexer):508 """509 For MoonScript source code.510 """511 512 name = 'MoonScript'513 url = 'http://moonscript.org'514 aliases = ['moonscript', 'moon']515 filenames = ['*.moon']516 mimetypes = ['text/x-moonscript', 'application/x-moonscript']517 version_added = '1.5'518 519 tokens = {520 'root': [521 (r'#!(.*?)$', Comment.Preproc),522 default('base'),523 ],524 'base': [525 ('--.*$', Comment.Single),526 (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),527 (r'(?i)\d+e[+-]?\d+', Number.Float),528 (r'(?i)0x[0-9a-f]*', Number.Hex),529 (r'\d+', Number.Integer),530 (r'\n', Whitespace),531 (r'[^\S\n]+', Text),532 (r'(?s)\[(=*)\[.*?\]\1\]', String),533 (r'(->|=>)', Name.Function),534 (r':[a-zA-Z_]\w*', Name.Variable),535 (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),536 (r'[;,]', Punctuation),537 (r'[\[\]{}()]', Keyword.Type),538 (r'[a-zA-Z_]\w*:', Name.Variable),539 (words((540 'class', 'extends', 'if', 'then', 'super', 'do', 'with',541 'import', 'export', 'while', 'elseif', 'return', 'for', 'in',542 'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',543 'break'), suffix=r'\b'),544 Keyword),545 (r'(true|false|nil)\b', Keyword.Constant),546 (r'(and|or|not)\b', Operator.Word),547 (r'(self)\b', Name.Builtin.Pseudo),548 (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),549 (r'[A-Z]\w*', Name.Class), # proper name550 (words(all_lua_builtins(), suffix=r"\b"), Name.Builtin),551 (r'[A-Za-z_]\w*', Name),552 ("'", String.Single, combined('stringescape', 'sqs')),553 ('"', String.Double, combined('stringescape', 'dqs'))554 ],555 'stringescape': [556 (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)557 ],558 'strings': [559 (r'[^#\\\'"]+', String),560 # note that strings are multi-line.561 # hashmarks, quotes and backslashes must be parsed one at a time562 ],563 'interpoling_string': [564 (r'\}', String.Interpol, "#pop"),565 include('base')566 ],567 'dqs': [568 (r'"', String.Double, '#pop'),569 (r'\\.|\'', String), # double-quoted string don't need ' escapes570 (r'#\{', String.Interpol, "interpoling_string"),571 (r'#', String),572 include('strings')573 ],574 'sqs': [575 (r"'", String.Single, '#pop'),576 (r'#|\\.|"', String), # single quoted strings don't need " escapses577 include('strings')578 ]579 }580 581 def get_tokens_unprocessed(self, text):582 # set . as Operator instead of Punctuation583 for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):584 if token == Punctuation and value == ".":585 token = Operator586 yield index, token, value587 588 589class ChaiscriptLexer(RegexLexer):590 """591 For ChaiScript source code.592 """593 594 name = 'ChaiScript'595 url = 'http://chaiscript.com/'596 aliases = ['chaiscript', 'chai']597 filenames = ['*.chai']598 mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']599 version_added = '2.0'600 601 flags = re.DOTALL | re.MULTILINE602 603 tokens = {604 'commentsandwhitespace': [605 (r'\s+', Text),606 (r'//.*?\n', Comment.Single),607 (r'/\*.*?\*/', Comment.Multiline),608 (r'^\#.*?\n', Comment.Single)609 ],610 'slashstartsregex': [611 include('commentsandwhitespace'),612 (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'613 r'([gim]+\b|\B)', String.Regex, '#pop'),614 (r'(?=/)', Text, ('#pop', 'badregex')),615 default('#pop')616 ],617 'badregex': [618 (r'\n', Text, '#pop')619 ],620 'root': [621 include('commentsandwhitespace'),622 (r'\n', Text),623 (r'[^\S\n]+', Text),624 (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'625 r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),626 (r'[{(\[;,]', Punctuation, 'slashstartsregex'),627 (r'[})\].]', Punctuation),628 (r'[=+\-*/]', Operator),629 (r'(for|in|while|do|break|return|continue|if|else|'630 r'throw|try|catch'631 r')\b', Keyword, 'slashstartsregex'),632 (r'(var)\b', Keyword.Declaration, 'slashstartsregex'),633 (r'(attr|def|fun)\b', Keyword.Reserved),634 (r'(true|false)\b', Keyword.Constant),635 (r'(eval|throw)\b', Name.Builtin),636 (r'`\S+`', Name.Builtin),637 (r'[$a-zA-Z_]\w*', Name.Other),638 (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),639 (r'0x[0-9a-fA-F]+', Number.Hex),640 (r'[0-9]+', Number.Integer),641 (r'"', String.Double, 'dqstring'),642 (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),643 ],644 'dqstring': [645 (r'\$\{[^"}]+?\}', String.Interpol),646 (r'\$', String.Double),647 (r'\\\\', String.Double),648 (r'\\"', String.Double),649 (r'[^\\"$]+', String.Double),650 (r'"', String.Double, '#pop'),651 ],652 }653 654 655class LSLLexer(RegexLexer):656 """657 For Second Life's Linden Scripting Language source code.658 """659 660 name = 'LSL'661 aliases = ['lsl']662 filenames = ['*.lsl']663 mimetypes = ['text/x-lsl']664 url = 'https://wiki.secondlife.com/wiki/Linden_Scripting_Language'665 version_added = '2.0'666 667 flags = re.MULTILINE668 669 lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'670 lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'671 lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'672 lsl_events = r'\b(?:state_(?:entry|exit)|touch(?:_(?:start|end))?|(?:land_)?collision(?:_(?:start|end))?|timer|listen|(?:no_)?sensor|control|(?:not_)?at_(?:rot_)?target|money|email|run_time_permissions|changed|attach|dataserver|moving_(?:start|end)|link_message|(?:on|object)_rez|remote_data|http_re(?:sponse|quest)|path_update|transaction_result)\b'673 lsl_functions_builtin = r'\b(?:ll(?:ReturnObjectsBy(?:ID|Owner)|Json(?:2List|[GS]etValue|ValueType)|Sin|Cos|Tan|Atan2|Sqrt|Pow|Abs|Fabs|Frand|Floor|Ceil|Round|Vec(?:Mag|Norm|Dist)|Rot(?:Between|2(?:Euler|Fwd|Left|Up))|(?:Euler|Axes)2Rot|Whisper|(?:Region|Owner)?Say|Shout|Listen(?:Control|Remove)?|Sensor(?:Repeat|Remove)?|Detected(?:Name|Key|Owner|Type|Pos|Vel|Grab|Rot|Group|LinkNumber)|Die|Ground|Wind|(?:[GS]et)(?:AnimationOverride|MemoryLimit|PrimMediaParams|ParcelMusicURL|Object(?:Desc|Name)|PhysicsMaterial|Status|Scale|Color|Alpha|Texture|Pos|Rot|Force|Torque)|ResetAnimationOverride|(?:Scale|Offset|Rotate)Texture|(?:Rot)?Target(?:Remove)?|(?:Stop)?MoveToTarget|Apply(?:Rotational)?Impulse|Set(?:KeyframedMotion|ContentType|RegionPos|(?:Angular)?Velocity|Buoyancy|HoverHeight|ForceAndTorque|TimerEvent|ScriptState|Damage|TextureAnim|Sound(?:Queueing|Radius)|Vehicle(?:Type|(?:Float|Vector|Rotation)Param)|(?:Touch|Sit)?Text|Camera(?:Eye|At)Offset|PrimitiveParams|ClickAction|Link(?:Alpha|Color|PrimitiveParams(?:Fast)?|Texture(?:Anim)?|Camera|Media)|RemoteScriptAccessPin|PayPrice|LocalRot)|ScaleByFactor|Get(?:(?:Max|Min)ScaleFactor|ClosestNavPoint|StaticPath|SimStats|Env|PrimitiveParams|Link(?:PrimitiveParams|Number(?:OfSides)?|Key|Name|Media)|HTTPHeader|FreeURLs|Object(?:Details|PermMask|PrimCount)|Parcel(?:MaxPrims|Details|Prim(?:Count|Owners))|Attached|(?:SPMax|Free|Used)Memory|Region(?:Name|TimeDilation|FPS|Corner|AgentCount)|Root(?:Position|Rotation)|UnixTime|(?:Parcel|Region)Flags|(?:Wall|GMT)clock|SimulatorHostname|BoundingBox|GeometricCenter|Creator|NumberOf(?:Prims|NotecardLines|Sides)|Animation(?:List)?|(?:Camera|Local)(?:Pos|Rot)|Vel|Accel|Omega|Time(?:stamp|OfDay)|(?:Object|CenterOf)?Mass|MassMKS|Energy|Owner|(?:Owner)?Key|SunDirection|Texture(?:Offset|Scale|Rot)|Inventory(?:Number|Name|Key|Type|Creator|PermMask)|Permissions(?:Key)?|StartParameter|List(?:Length|EntryType)|Date|Agent(?:Size|Info|Language|List)|LandOwnerAt|NotecardLine|Script(?:Name|State))|(?:Get|Reset|GetAndReset)Time|PlaySound(?:Slave)?|LoopSound(?:Master|Slave)?|(?:Trigger|Stop|Preload)Sound|(?:(?:Get|Delete)Sub|Insert)String|To(?:Upper|Lower)|Give(?:InventoryList|Money)|RezObject|(?:Stop)?LookAt|Sleep|CollisionFilter|(?:Take|Release)Controls|DetachFromAvatar|AttachToAvatar(?:Temp)?|InstantMessage|(?:GetNext)?Email|StopHover|MinEventDelay|RotLookAt|String(?:Length|Trim)|(?:Start|Stop)Animation|TargetOmega|RequestPermissions|(?:Create|Break)Link|BreakAllLinks|(?:Give|Remove)Inventory|Water|PassTouches|Request(?:Agent|Inventory)Data|TeleportAgent(?:Home|GlobalCoords)?|ModifyLand|CollisionSound|ResetScript|MessageLinked|PushObject|PassCollisions|AxisAngle2Rot|Rot2(?:Axis|Angle)|A(?:cos|sin)|AngleBetween|AllowInventoryDrop|SubStringIndex|List2(?:CSV|Integer|Json|Float|String|Key|Vector|Rot|List(?:Strided)?)|DeleteSubList|List(?:Statistics|Sort|Randomize|(?:Insert|Find|Replace)List)|EdgeOfWorld|AdjustSoundVolume|Key2Name|TriggerSoundLimited|EjectFromLand|(?:CSV|ParseString)2List|OverMyLand|SameGroup|UnSit|Ground(?:Slope|Normal|Contour)|GroundRepel|(?:Set|Remove)VehicleFlags|(?:AvatarOn)?(?:Link)?SitTarget|Script(?:Danger|Profiler)|Dialog|VolumeDetect|ResetOtherScript|RemoteLoadScriptPin|(?:Open|Close)RemoteDataChannel|SendRemoteData|RemoteDataReply|(?:Integer|String)ToBase64|XorBase64|Log(?:10)?|Base64To(?:String|Integer)|ParseStringKeepNulls|RezAtRoot|RequestSimulatorData|ForceMouselook|(?:Load|Release|(?:E|Une)scape)URL|ParcelMedia(?:CommandList|Query)|ModPow|MapDestination|(?:RemoveFrom|AddTo|Reset)Land(?:Pass|Ban)List|(?:Set|Clear)CameraParams|HTTP(?:Request|Response)|TextBox|DetectedTouch(?:UV|Face|Pos|(?:N|Bin)ormal|ST)|(?:MD5|SHA1|DumpList2)String|Request(?:Secure)?URL|Clear(?:Prim|Link)Media|(?:Link)?ParticleSystem|(?:Get|Request)(?:Username|DisplayName)|RegionSayTo|CastRay|GenerateKey|TransferLindenDollars|ManageEstateAccess|(?:Create|Delete)Character|ExecCharacterCmd|Evade|FleeFrom|NavigateTo|PatrolPoints|Pursue|UpdateCharacter|WanderWithin))\b'674 lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'675 lsl_constants_integer = r'\b(?:JSON_APPEND|STATUS_(?:PHYSICS|ROTATE_[XYZ]|PHANTOM|SANDBOX|BLOCK_GRAB(?:_OBJECT)?|(?:DIE|RETURN)_AT_EDGE|CAST_SHADOWS|OK|MALFORMED_PARAMS|TYPE_MISMATCH|BOUNDS_ERROR|NOT_(?:FOUND|SUPPORTED)|INTERNAL_ERROR|WHITELIST_FAILED)|AGENT(?:_(?:BY_(?:LEGACY_|USER)NAME|FLYING|ATTACHMENTS|SCRIPTED|MOUSELOOK|SITTING|ON_OBJECT|AWAY|WALKING|IN_AIR|TYPING|CROUCHING|BUSY|ALWAYS_RUN|AUTOPILOT|LIST_(?:PARCEL(?:_OWNER)?|REGION)))?|CAMERA_(?:PITCH|DISTANCE|BEHINDNESS_(?:ANGLE|LAG)|(?:FOCUS|POSITION)(?:_(?:THRESHOLD|LOCKED|LAG))?|FOCUS_OFFSET|ACTIVE)|ANIM_ON|LOOP|REVERSE|PING_PONG|SMOOTH|ROTATE|SCALE|ALL_SIDES|LINK_(?:ROOT|SET|ALL_(?:OTHERS|CHILDREN)|THIS)|ACTIVE|PASSIVE|SCRIPTED|CONTROL_(?:FWD|BACK|(?:ROT_)?(?:LEFT|RIGHT)|UP|DOWN|(?:ML_)?LBUTTON)|PERMISSION_(?:RETURN_OBJECTS|DEBIT|OVERRIDE_ANIMATIONS|SILENT_ESTATE_MANAGEMENT|TAKE_CONTROLS|TRIGGER_ANIMATION|ATTACH|CHANGE_LINKS|(?:CONTROL|TRACK)_CAMERA|TELEPORT)|INVENTORY_(?:TEXTURE|SOUND|OBJECT|SCRIPT|LANDMARK|CLOTHING|NOTECARD|BODYPART|ANIMATION|GESTURE|ALL|NONE)|CHANGED_(?:INVENTORY|COLOR|SHAPE|SCALE|TEXTURE|LINK|ALLOWED_DROP|OWNER|REGION(?:_START)?|TELEPORT|MEDIA)|OBJECT_(?:(?:PHYSICS|SERVER|STREAMING)_COST|UNKNOWN_DETAIL|CHARACTER_TIME|PHANTOM|PHYSICS|TEMP_ON_REZ|NAME|DESC|POS|PRIM_EQUIVALENCE|RETURN_(?:PARCEL(?:_OWNER)?|REGION)|ROO?T|VELOCITY|OWNER|GROUP|CREATOR|ATTACHED_POINT|RENDER_WEIGHT|PATHFINDING_TYPE|(?:RUNNING|TOTAL)_SCRIPT_COUNT|SCRIPT_(?:MEMORY|TIME))|TYPE_(?:INTEGER|FLOAT|STRING|KEY|VECTOR|ROTATION|INVALID)|(?:DEBUG|PUBLIC)_CHANNEL|ATTACH_(?:AVATAR_CENTER|CHEST|HEAD|BACK|PELVIS|MOUTH|CHIN|NECK|NOSE|BELLY|[LR](?:SHOULDER|HAND|FOOT|EAR|EYE|[UL](?:ARM|LEG)|HIP)|(?:LEFT|RIGHT)_PEC|HUD_(?:CENTER_[12]|TOP_(?:RIGHT|CENTER|LEFT)|BOTTOM(?:_(?:RIGHT|LEFT))?))|LAND_(?:LEVEL|RAISE|LOWER|SMOOTH|NOISE|REVERT)|DATA_(?:ONLINE|NAME|BORN|SIM_(?:POS|STATUS|RATING)|PAYINFO)|PAYMENT_INFO_(?:ON_FILE|USED)|REMOTE_DATA_(?:CHANNEL|REQUEST|REPLY)|PSYS_(?:PART_(?:BF_(?:ZERO|ONE(?:_MINUS_(?:DEST_COLOR|SOURCE_(ALPHA|COLOR)))?|DEST_COLOR|SOURCE_(ALPHA|COLOR))|BLEND_FUNC_(DEST|SOURCE)|FLAGS|(?:START|END)_(?:COLOR|ALPHA|SCALE|GLOW)|MAX_AGE|(?:RIBBON|WIND|INTERP_(?:COLOR|SCALE)|BOUNCE|FOLLOW_(?:SRC|VELOCITY)|TARGET_(?:POS|LINEAR)|EMISSIVE)_MASK)|SRC_(?:MAX_AGE|PATTERN|ANGLE_(?:BEGIN|END)|BURST_(?:RATE|PART_COUNT|RADIUS|SPEED_(?:MIN|MAX))|ACCEL|TEXTURE|TARGET_KEY|OMEGA|PATTERN_(?:DROP|EXPLODE|ANGLE(?:_CONE(?:_EMPTY)?)?)))|VEHICLE_(?:REFERENCE_FRAME|TYPE_(?:NONE|SLED|CAR|BOAT|AIRPLANE|BALLOON)|(?:LINEAR|ANGULAR)_(?:FRICTION_TIMESCALE|MOTOR_DIRECTION)|LINEAR_MOTOR_OFFSET|HOVER_(?:HEIGHT|EFFICIENCY|TIMESCALE)|BUOYANCY|(?:LINEAR|ANGULAR)_(?:DEFLECTION_(?:EFFICIENCY|TIMESCALE)|MOTOR_(?:DECAY_)?TIMESCALE)|VERTICAL_ATTRACTION_(?:EFFICIENCY|TIMESCALE)|BANKING_(?:EFFICIENCY|MIX|TIMESCALE)|FLAG_(?:NO_DEFLECTION_UP|LIMIT_(?:ROLL_ONLY|MOTOR_UP)|HOVER_(?:(?:WATER|TERRAIN|UP)_ONLY|GLOBAL_HEIGHT)|MOUSELOOK_(?:STEER|BANK)|CAMERA_DECOUPLED))|PRIM_(?:TYPE(?:_(?:BOX|CYLINDER|PRISM|SPHERE|TORUS|TUBE|RING|SCULPT))?|HOLE_(?:DEFAULT|CIRCLE|SQUARE|TRIANGLE)|MATERIAL(?:_(?:STONE|METAL|GLASS|WOOD|FLESH|PLASTIC|RUBBER))?|SHINY_(?:NONE|LOW|MEDIUM|HIGH)|BUMP_(?:NONE|BRIGHT|DARK|WOOD|BARK|BRICKS|CHECKER|CONCRETE|TILE|STONE|DISKS|GRAVEL|BLOBS|SIDING|LARGETILE|STUCCO|SUCTION|WEAVE)|TEXGEN_(?:DEFAULT|PLANAR)|SCULPT_(?:TYPE_(?:SPHERE|TORUS|PLANE|CYLINDER|MASK)|FLAG_(?:MIRROR|INVERT))|PHYSICS(?:_(?:SHAPE_(?:CONVEX|NONE|PRIM|TYPE)))?|(?:POS|ROT)_LOCAL|SLICE|TEXT|FLEXIBLE|POINT_LIGHT|TEMP_ON_REZ|PHANTOM|POSITION|SIZE|ROTATION|TEXTURE|NAME|OMEGA|DESC|LINK_TARGET|COLOR|BUMP_SHINY|FULLBRIGHT|TEXGEN|GLOW|MEDIA_(?:ALT_IMAGE_ENABLE|CONTROLS|(?:CURRENT|HOME)_URL|AUTO_(?:LOOP|PLAY|SCALE|ZOOM)|FIRST_CLICK_INTERACT|(?:WIDTH|HEIGHT)_PIXELS|WHITELIST(?:_ENABLE)?|PERMS_(?:INTERACT|CONTROL)|PARAM_MAX|CONTROLS_(?:STANDARD|MINI)|PERM_(?:NONE|OWNER|GROUP|ANYONE)|MAX_(?:URL_LENGTH|WHITELIST_(?:SIZE|COUNT)|(?:WIDTH|HEIGHT)_PIXELS)))|MASK_(?:BASE|OWNER|GROUP|EVERYONE|NEXT)|PERM_(?:TRANSFER|MODIFY|COPY|MOVE|ALL)|PARCEL_(?:MEDIA_COMMAND_(?:STOP|PAUSE|PLAY|LOOP|TEXTURE|URL|TIME|AGENT|UNLOAD|AUTO_ALIGN|TYPE|SIZE|DESC|LOOP_SET)|FLAG_(?:ALLOW_(?:FLY|(?:GROUP_)?SCRIPTS|LANDMARK|TERRAFORM|DAMAGE|CREATE_(?:GROUP_)?OBJECTS)|USE_(?:ACCESS_(?:GROUP|LIST)|BAN_LIST|LAND_PASS_LIST)|LOCAL_SOUND_ONLY|RESTRICT_PUSHOBJECT|ALLOW_(?:GROUP|ALL)_OBJECT_ENTRY)|COUNT_(?:TOTAL|OWNER|GROUP|OTHER|SELECTED|TEMP)|DETAILS_(?:NAME|DESC|OWNER|GROUP|AREA|ID|SEE_AVATARS))|LIST_STAT_(?:MAX|MIN|MEAN|MEDIAN|STD_DEV|SUM(?:_SQUARES)?|NUM_COUNT|GEOMETRIC_MEAN|RANGE)|PAY_(?:HIDE|DEFAULT)|REGION_FLAG_(?:ALLOW_DAMAGE|FIXED_SUN|BLOCK_TERRAFORM|SANDBOX|DISABLE_(?:COLLISIONS|PHYSICS)|BLOCK_FLY|ALLOW_DIRECT_TELEPORT|RESTRICT_PUSHOBJECT)|HTTP_(?:METHOD|MIMETYPE|BODY_(?:MAXLENGTH|TRUNCATED)|CUSTOM_HEADER|PRAGMA_NO_CACHE|VERBOSE_THROTTLE|VERIFY_CERT)|STRING_(?:TRIM(?:_(?:HEAD|TAIL))?)|CLICK_ACTION_(?:NONE|TOUCH|SIT|BUY|PAY|OPEN(?:_MEDIA)?|PLAY|ZOOM)|TOUCH_INVALID_FACE|PROFILE_(?:NONE|SCRIPT_MEMORY)|RC_(?:DATA_FLAGS|DETECT_PHANTOM|GET_(?:LINK_NUM|NORMAL|ROOT_KEY)|MAX_HITS|REJECT_(?:TYPES|AGENTS|(?:NON)?PHYSICAL|LAND))|RCERR_(?:CAST_TIME_EXCEEDED|SIM_PERF_LOW|UNKNOWN)|ESTATE_ACCESS_(?:ALLOWED_(?:AGENT|GROUP)_(?:ADD|REMOVE)|BANNED_AGENT_(?:ADD|REMOVE))|DENSITY|FRICTION|RESTITUTION|GRAVITY_MULTIPLIER|KFM_(?:COMMAND|CMD_(?:PLAY|STOP|PAUSE|SET_MODE)|MODE|FORWARD|LOOP|PING_PONG|REVERSE|DATA|ROTATION|TRANSLATION)|ERR_(?:GENERIC|PARCEL_PERMISSIONS|MALFORMED_PARAMS|RUNTIME_PERMISSIONS|THROTTLED)|CHARACTER_(?:CMD_(?:(?:SMOOTH_)?STOP|JUMP)|DESIRED_(?:TURN_)?SPEED|RADIUS|STAY_WITHIN_PARCEL|LENGTH|ORIENTATION|ACCOUNT_FOR_SKIPPED_FRAMES|AVOIDANCE_MODE|TYPE(?:_(?:[A-D]|NONE))?|MAX_(?:DECEL|TURN_RADIUS|(?:ACCEL|SPEED)))|PURSUIT_(?:OFFSET|FUZZ_FACTOR|GOAL_TOLERANCE|INTERCEPT)|REQUIRE_LINE_OF_SIGHT|FORCE_DIRECT_PATH|VERTICAL|HORIZONTAL|AVOID_(?:CHARACTERS|DYNAMIC_OBSTACLES|NONE)|PU_(?:EVADE_(?:HIDDEN|SPOTTED)|FAILURE_(?:DYNAMIC_PATHFINDING_DISABLED|INVALID_(?:GOAL|START)|NO_(?:NAVMESH|VALID_DESTINATION)|OTHER|TARGET_GONE|(?:PARCEL_)?UNREACHABLE)|(?:GOAL|SLOWDOWN_DISTANCE)_REACHED)|TRAVERSAL_TYPE(?:_(?:FAST|NONE|SLOW))?|CONTENT_TYPE_(?:ATOM|FORM|HTML|JSON|LLSD|RSS|TEXT|XHTML|XML)|GCNP_(?:RADIUS|STATIC)|(?:PATROL|WANDER)_PAUSE_AT_WAYPOINTS|OPT_(?:AVATAR|CHARACTER|EXCLUSION_VOLUME|LEGACY_LINKSET|MATERIAL_VOLUME|OTHER|STATIC_OBSTACLE|WALKABLE)|SIM_STAT_PCT_CHARS_STEPPED)\b'676 lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'677 lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'678 lsl_constants_string = r'\b(?:EOF|JSON_(?:ARRAY|DELETE|FALSE|INVALID|NULL|NUMBER|OBJECT|STRING|TRUE)|NULL_KEY|TEXTURE_(?:BLANK|DEFAULT|MEDIA|PLYWOOD|TRANSPARENT)|URL_REQUEST_(?:GRANTED|DENIED))\b'679 lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'680 lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'681 lsl_invalid_deprecated = r'\b(?:ATTACH_[LR]PEC|DATA_RATING|OBJECT_ATTACHMENT_(?:GEOMETRY_BYTES|SURFACE_AREA)|PRIM_(?:CAST_SHADOWS|MATERIAL_LIGHT|TYPE_LEGACY)|PSYS_SRC_(?:INNER|OUTER)ANGLE|VEHICLE_FLAG_NO_FLY_UP|ll(?:Cloud|Make(?:Explosion|Fountain|Smoke|Fire)|RemoteDataSetRegion|Sound(?:Preload)?|XorBase64Strings(?:Correct)?))\b'682 lsl_invalid_illegal = r'\b(?:event)\b'683 lsl_invalid_unimplemented = r'\b(?:CHARACTER_(?:MAX_ANGULAR_(?:ACCEL|SPEED)|TURN_SPEED_MULTIPLIER)|PERMISSION_(?:CHANGE_(?:JOINTS|PERMISSIONS)|RELEASE_OWNERSHIP|REMAP_CONTROLS)|PRIM_PHYSICS_MATERIAL|PSYS_SRC_OBJ_REL_MASK|ll(?:CollisionSprite|(?:Stop)?PointAt|(?:(?:Refresh|Set)Prim)URL|(?:Take|Release)Camera|RemoteLoadScript))\b'684 lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'685 lsl_reserved_log = r'\b(?:print)\b'686 lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?'687 688 tokens = {689 'root':690 [691 (r'//.*?\n', Comment.Single),692 (r'/\*', Comment.Multiline, 'comment'),693 (r'"', String.Double, 'string'),694 (lsl_keywords, Keyword),695 (lsl_types, Keyword.Type),696 (lsl_states, Name.Class),697 (lsl_events, Name.Builtin),698 (lsl_functions_builtin, Name.Function),699 (lsl_constants_float, Keyword.Constant),700 (lsl_constants_integer, Keyword.Constant),701 (lsl_constants_integer_boolean, Keyword.Constant),702 (lsl_constants_rotation, Keyword.Constant),703 (lsl_constants_string, Keyword.Constant),704 (lsl_constants_vector, Keyword.Constant),705 (lsl_invalid_broken, Error),706 (lsl_invalid_deprecated, Error),707 (lsl_invalid_illegal, Error),708 (lsl_invalid_unimplemented, Error),709 (lsl_reserved_godmode, Keyword.Reserved),710 (lsl_reserved_log, Keyword.Reserved),711 (r'\b([a-zA-Z_]\w*)\b', Name.Variable),712 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),713 (r'(\d+\.\d*|\.\d+)', Number.Float),714 (r'0[xX][0-9a-fA-F]+', Number.Hex),715 (r'\d+', Number.Integer),716 (lsl_operators, Operator),717 (r':=?', Error),718 (r'[,;{}()\[\]]', Punctuation),719 (r'\n+', Whitespace),720 (r'\s+', Whitespace)721 ],722 'comment':723 [724 (r'[^*/]+', Comment.Multiline),725 (r'/\*', Comment.Multiline, '#push'),726 (r'\*/', Comment.Multiline, '#pop'),727 (r'[*/]', Comment.Multiline)728 ],729 'string':730 [731 (r'\\([nt"\\])', String.Escape),732 (r'"', String.Double, '#pop'),733 (r'\\.', Error),734 (r'[^"\\]+', String.Double),735 ]736 }737 738 739class AppleScriptLexer(RegexLexer):740 """741 For AppleScript source code,742 including `AppleScript Studio743 <http://developer.apple.com/documentation/AppleScript/744 Reference/StudioReference>`_.745 Contributed by Andreas Amann <aamann@mac.com>.746 """747 748 name = 'AppleScript'749 url = 'https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html'750 aliases = ['applescript']751 filenames = ['*.applescript']752 version_added = '1.0'753 754 flags = re.MULTILINE | re.DOTALL755 756 Identifiers = r'[a-zA-Z]\w*'757 758 # XXX: use words() for all of these759 Literals = ('AppleScript', 'current application', 'false', 'linefeed',760 'missing value', 'pi', 'quote', 'result', 'return', 'space',761 'tab', 'text item delimiters', 'true', 'version')762 Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ',763 'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',764 'real ', 'record ', 'reference ', 'RGB color ', 'script ',765 'text ', 'unit types', '(?:Unicode )?text', 'string')766 BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month',767 'paragraph', 'word', 'year')768 HandlerParams = ('about', 'above', 'against', 'apart from', 'around',769 'aside from', 'at', 'below', 'beneath', 'beside',770 'between', 'for', 'given', 'instead of', 'on', 'onto',771 'out of', 'over', 'since')772 Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL',773 'choose application', 'choose color', 'choose file( name)?',774 'choose folder', 'choose from list',775 'choose remote application', 'clipboard info',776 'close( access)?', 'copy', 'count', 'current date', 'delay',777 'delete', 'display (alert|dialog)', 'do shell script',778 'duplicate', 'exists', 'get eof', 'get volume settings',779 'info for', 'launch', 'list (disks|folder)', 'load script',780 'log', 'make', 'mount volume', 'new', 'offset',781 'open( (for access|location))?', 'path to', 'print', 'quit',782 'random number', 'read', 'round', 'run( script)?',783 'say', 'scripting components',784 'set (eof|the clipboard to|volume)', 'store script',785 'summarize', 'system attribute', 'system info',786 'the clipboard', 'time to GMT', 'write', 'quoted form')787 References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',788 'first', 'second', 'third', 'fourth', 'fifth', 'sixth',789 'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',790 'before', 'behind', 'every', 'front', 'index', 'last',791 'middle', 'some', 'that', 'through', 'thru', 'where', 'whose')792 Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not",793 "isn't", "isn't equal( to)?", "is not equal( to)?",794 "doesn't equal", "does not equal", "(is )?greater than",795 "comes after", "is not less than or equal( to)?",796 "isn't less than or equal( to)?", "(is )?less than",797 "comes before", "is not greater than or equal( to)?",798 "isn't greater than or equal( to)?",799 "(is )?greater than or equal( to)?", "is not less than",800 "isn't less than", "does not come before",801 "doesn't come before", "(is )?less than or equal( to)?",802 "is not greater than", "isn't greater than",803 "does not come after", "doesn't come after", "starts? with",804 "begins? with", "ends? with", "contains?", "does not contain",805 "doesn't contain", "is in", "is contained by", "is not in",806 "is not contained by", "isn't contained by", "div", "mod",807 "not", "(a )?(ref( to)?|reference to)", "is", "does")808 Control = ('considering', 'else', 'error', 'exit', 'from', 'if',809 'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',810 'try', 'until', 'using terms from', 'while', 'whith',811 'with timeout( of)?', 'with transaction', 'by', 'continue',812 'end', 'its?', 'me', 'my', 'return', 'of', 'as')813 Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get')814 Reserved = ('but', 'put', 'returning', 'the')815 StudioClasses = ('action cell', 'alert reply', 'application', 'box',816 'browser( cell)?', 'bundle', 'button( cell)?', 'cell',817 'clip view', 'color well', 'color-panel',818 'combo box( item)?', 'control',819 'data( (cell|column|item|row|source))?', 'default entry',820 'dialog reply', 'document', 'drag info', 'drawer',821 'event', 'font(-panel)?', 'formatter',822 'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',823 'movie( view)?', 'open-panel', 'outline view', 'panel',824 'pasteboard', 'plugin', 'popup button',825 'progress indicator', 'responder', 'save-panel',826 'scroll view', 'secure text field( cell)?', 'slider',827 'sound', 'split view', 'stepper', 'tab view( item)?',828 'table( (column|header cell|header view|view))',829 'text( (field( cell)?|view))?', 'toolbar( item)?',830 'user-defaults', 'view', 'window')831 StudioEvents = ('accept outline drop', 'accept table drop', 'action',832 'activated', 'alert ended', 'awake from nib', 'became key',833 'became main', 'begin editing', 'bounds changed',834 'cell value', 'cell value changed', 'change cell value',835 'change item value', 'changed', 'child of item',836 'choose menu item', 'clicked', 'clicked toolbar item',837 'closed', 'column clicked', 'column moved',838 'column resized', 'conclude drop', 'data representation',839 'deminiaturized', 'dialog ended', 'document nib name',840 'double clicked', 'drag( (entered|exited|updated))?',841 'drop', 'end editing', 'exposed', 'idle', 'item expandable',842 'item value', 'item value changed', 'items changed',843 'keyboard down', 'keyboard up', 'launched',844 'load data representation', 'miniaturized', 'mouse down',845 'mouse dragged', 'mouse entered', 'mouse exited',846 'mouse moved', 'mouse up', 'moved',847 'number of browser rows', 'number of items',848 'number of rows', 'open untitled', 'opened', 'panel ended',849 'parameters updated', 'plugin loaded', 'prepare drop',850 'prepare outline drag', 'prepare outline drop',851 'prepare table drag', 'prepare table drop',852 'read from file', 'resigned active', 'resigned key',853 'resigned main', 'resized( sub views)?',854 'right mouse down', 'right mouse dragged',855 'right mouse up', 'rows changed', 'scroll wheel',856 'selected tab view item', 'selection changed',857 'selection changing', 'should begin editing',858 'should close', 'should collapse item',859 'should end editing', 'should expand item',860 'should open( untitled)?',861 'should quit( after last window closed)?',862 'should select column', 'should select item',863 'should select row', 'should select tab view item',864 'should selection change', 'should zoom', 'shown',865 'update menu item', 'update parameters',866 'update toolbar item', 'was hidden', 'was miniaturized',867 'will become active', 'will close', 'will dismiss',868 'will display browser cell', 'will display cell',869 'will display item cell', 'will display outline cell',870 'will finish launching', 'will hide', 'will miniaturize',871 'will move', 'will open', 'will pop up', 'will quit',872 'will resign active', 'will resize( sub views)?',873 'will select tab view item', 'will show', 'will zoom',874 'write to file', 'zoomed')875 StudioCommands = ('animate', 'append', 'call method', 'center',876 'close drawer', 'close panel', 'display',877 'display alert', 'display dialog', 'display panel', 'go',878 'hide', 'highlight', 'increment', 'item for',879 'load image', 'load movie', 'load nib', 'load panel',880 'load sound', 'localized string', 'lock focus', 'log',881 'open drawer', 'path for', 'pause', 'perform action',882 'play', 'register', 'resume', 'scroll', 'select( all)?',883 'show', 'size to fit', 'start', 'step back',884 'step forward', 'stop', 'synchronize', 'unlock focus',885 'update')886 StudioProperties = ('accepts arrow key', 'action method', 'active',887 'alignment', 'allowed identifiers',888 'allows branch selection', 'allows column reordering',889 'allows column resizing', 'allows column selection',890 'allows customization',891 'allows editing text attributes',892 'allows empty selection', 'allows mixed state',893 'allows multiple selection', 'allows reordering',894 'allows undo', 'alpha( value)?', 'alternate image',895 'alternate increment value', 'alternate title',896 'animation delay', 'associated file name',897 'associated object', 'auto completes', 'auto display',898 'auto enables items', 'auto repeat',899 'auto resizes( outline column)?',900 'auto save expanded items', 'auto save name',901 'auto save table columns', 'auto saves configuration',902 'auto scroll', 'auto sizes all columns to fit',903 'auto sizes cells', 'background color', 'bezel state',904 'bezel style', 'bezeled', 'border rect', 'border type',905 'bordered', 'bounds( rotation)?', 'box type',906 'button returned', 'button type',907 'can choose directories', 'can choose files',908 'can draw', 'can hide',909 'cell( (background color|size|type))?', 'characters',910 'class', 'click count', 'clicked( data)? column',911 'clicked data item', 'clicked( data)? row',912 'closeable', 'collating', 'color( (mode|panel))',913 'command key down', 'configuration',914 'content(s| (size|view( margins)?))?', 'context',915 'continuous', 'control key down', 'control size',916 'control tint', 'control view',917 'controller visible', 'coordinate system',918 'copies( on scroll)?', 'corner view', 'current cell',919 'current column', 'current( field)? editor',920 'current( menu)? item', 'current row',921 'current tab view item', 'data source',922 'default identifiers', 'delta (x|y|z)',923 'destination window', 'directory', 'display mode',924 'displayed cell', 'document( (edited|rect|view))?',925 'double value', 'dragged column', 'dragged distance',926 'dragged items', 'draws( cell)? background',927 'draws grid', 'dynamically scrolls', 'echos bullets',928 'edge', 'editable', 'edited( data)? column',929 'edited data item', 'edited( data)? row', 'enabled',930 'enclosing scroll view', 'ending page',931 'error handling', 'event number', 'event type',932 'excluded from windows menu', 'executable path',933 'expanded', 'fax number', 'field editor', 'file kind',934 'file name', 'file type', 'first responder',935 'first visible column', 'flipped', 'floating',936 'font( panel)?', 'formatter', 'frameworks path',937 'frontmost', 'gave up', 'grid color', 'has data items',938 'has horizontal ruler', 'has horizontal scroller',939 'has parent data item', 'has resize indicator',940 'has shadow', 'has sub menu', 'has vertical ruler',941 'has vertical scroller', 'header cell', 'header view',942 'hidden', 'hides when deactivated', 'highlights by',943 'horizontal line scroll', 'horizontal page scroll',944 'horizontal ruler view', 'horizontally resizable',945 'icon image', 'id', 'identifier',946 'ignores multiple clicks',947 'image( (alignment|dims when disabled|frame style|scaling))?',948 'imports graphics', 'increment value',949 'indentation per level', 'indeterminate', 'index',950 'integer value', 'intercell spacing', 'item height',951 'key( (code|equivalent( modifier)?|window))?',952 'knob thickness', 'label', 'last( visible)? column',953 'leading offset', 'leaf', 'level', 'line scroll',954 'loaded', 'localized sort', 'location', 'loop mode',955 'main( (bunde|menu|window))?', 'marker follows cell',956 'matrix mode', 'maximum( content)? size',957 'maximum visible columns',958 'menu( form representation)?', 'miniaturizable',959 'miniaturized', 'minimized image', 'minimized title',960 'minimum column width', 'minimum( content)? size',961 'modal', 'modified', 'mouse down state',962 'movie( (controller|file|rect))?', 'muted', 'name',963 'needs display', 'next state', 'next text',964 'number of tick marks', 'only tick mark values',965 'opaque', 'open panel', 'option key down',966 'outline table column', 'page scroll', 'pages across',967 'pages down', 'palette label', 'pane splitter',968 'parent data item', 'parent window', 'pasteboard',969 'path( (names|separator))?', 'playing',970 'plays every frame', 'plays selection only', 'position',971 'preferred edge', 'preferred type', 'pressure',972 'previous text', 'prompt', 'properties',973 'prototype cell', 'pulls down', 'rate',974 'released when closed', 'repeated',975 'requested print time', 'required file type',976 'resizable', 'resized column', 'resource path',977 'returns records', 'reuses columns', 'rich text',978 'roll over', 'row height', 'rulers visible',979 'save panel', 'scripts path', 'scrollable',980 'selectable( identifiers)?', 'selected cell',981 'selected( data)? columns?', 'selected data items?',982 'selected( data)? rows?', 'selected item identifier',983 'selection by rect', 'send action on arrow key',984 'sends action when done editing', 'separates columns',985 'separator item', 'sequence number', 'services menu',986 'shared frameworks path', 'shared support path',987 'sheet', 'shift key down', 'shows alpha',988 'shows state by', 'size( mode)?',989 'smart insert delete enabled', 'sort case sensitivity',990 'sort column', 'sort order', 'sort type',991 'sorted( data rows)?', 'sound', 'source( mask)?',992 'spell checking enabled', 'starting page', 'state',993 'string value', 'sub menu', 'super menu', 'super view',994 'tab key traverses cells', 'tab state', 'tab type',995 'tab view', 'table view', 'tag', 'target( printer)?',996 'text color', 'text container insert',997 'text container origin', 'text returned',998 'tick mark position', 'time stamp',999 'title(d| (cell|font|height|position|rect))?',1000 'tool tip', 'toolbar', 'trailing offset', 'transparent',1001 'treat packages as directories', 'truncated labels',1002 'types', 'unmodified characters', 'update views',1003 'use sort indicator', 'user defaults',1004 'uses data source', 'uses ruler',1005 'uses threaded animation',1006 'uses title from previous column', 'value wraps',1007 'version',1008 'vertical( (line scroll|page scroll|ruler view))?',1009 'vertically resizable', 'view',1010 'visible( document rect)?', 'volume', 'width', 'window',1011 'windows menu', 'wraps', 'zoomable', 'zoomed')1012 1013 tokens = {1014 'root': [1015 (r'\s+', Text),1016 (r'¬\n', String.Escape),1017 (r"'s\s+", Text), # This is a possessive, consider moving1018 (r'(--|#).*?$', Comment),1019 (r'\(\*', Comment.Multiline, 'comment'),1020 (r'[(){}!,.:]', Punctuation),1021 (r'(«)([^»]+)(»)',1022 bygroups(Text, Name.Builtin, Text)),1023 (r'\b((?:considering|ignoring)\s*)'1024 r'(application responses|case|diacriticals|hyphens|'1025 r'numeric strings|punctuation|white space)',1026 bygroups(Keyword, Name.Builtin)),1027 (r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),1028 (r"\b({})\b".format('|'.join(Operators)), Operator.Word),1029 (r'^(\s*(?:on|end)\s+)'1030 r'({})'.format('|'.join(StudioEvents[::-1])),1031 bygroups(Keyword, Name.Function)),1032 (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),1033 (r'\b(as )({})\b'.format('|'.join(Classes)),1034 bygroups(Keyword, Name.Class)),1035 (r'\b({})\b'.format('|'.join(Literals)), Name.Constant),1036 (r'\b({})\b'.format('|'.join(Commands)), Name.Builtin),1037 (r'\b({})\b'.format('|'.join(Control)), Keyword),1038 (r'\b({})\b'.format('|'.join(Declarations)), Keyword),1039 (r'\b({})\b'.format('|'.join(Reserved)), Name.Builtin),1040 (r'\b({})s?\b'.format('|'.join(BuiltIn)), Name.Builtin),1041 (r'\b({})\b'.format('|'.join(HandlerParams)), Name.Builtin),1042 (r'\b({})\b'.format('|'.join(StudioProperties)), Name.Attribute),1043 (r'\b({})s?\b'.format('|'.join(StudioClasses)), Name.Builtin),1044 (r'\b({})\b'.format('|'.join(StudioCommands)), Name.Builtin),1045 (r'\b({})\b'.format('|'.join(References)), Name.Builtin),1046 (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),1047 (rf'\b({Identifiers})\b', Name.Variable),1048 (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),1049 (r'[-+]?\d+', Number.Integer),1050 ],1051 'comment': [1052 (r'\(\*', Comment.Multiline, '#push'),1053 (r'\*\)', Comment.Multiline, '#pop'),1054 ('[^*(]+', Comment.Multiline),1055 ('[*(]', Comment.Multiline),1056 ],1057 }1058 1059 1060class RexxLexer(RegexLexer):1061 """1062 Rexx is a scripting language available for1063 a wide range of different platforms with its roots found on mainframe1064 systems. It is popular for I/O- and data based tasks and can act as glue1065 language to bind different applications together.1066 """1067 name = 'Rexx'1068 url = 'http://www.rexxinfo.org/'1069 aliases = ['rexx', 'arexx']1070 filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']1071 mimetypes = ['text/x-rexx']1072 version_added = '2.0'1073 flags = re.IGNORECASE1074 1075 tokens = {1076 'root': [1077 (r'\s+', Whitespace),1078 (r'/\*', Comment.Multiline, 'comment'),1079 (r'"', String, 'string_double'),1080 (r"'", String, 'string_single'),1081 (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),1082 (r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',1083 bygroups(Name.Function, Whitespace, Operator, Whitespace,1084 Keyword.Declaration)),1085 (r'([a-z_]\w*)(\s*)(:)',1086 bygroups(Name.Label, Whitespace, Operator)),1087 include('function'),1088 include('keyword'),1089 include('operator'),1090 (r'[a-z_]\w*', Text),1091 ],1092 'function': [1093 (words((1094 'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor',1095 'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare',1096 'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr',1097 'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert',1098 'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max',1099 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',1100 'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol',1101 'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word',1102 'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d',1103 'xrange'), suffix=r'(\s*)(\()'),1104 bygroups(Name.Builtin, Whitespace, Operator)),1105 ],1106 'keyword': [1107 (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|'1108 r'interpret|iterate|leave|nop|numeric|off|on|options|parse|'1109 r'pull|push|queue|return|say|select|signal|to|then|trace|until|'1110 r'while)\b', Keyword.Reserved),1111 ],1112 'operator': [1113 (r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'1114 r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'1115 r'¬>>|¬>|¬|\.|,)', Operator),1116 ],1117 'string_double': [1118 (r'[^"\n]+', String),1119 (r'""', String),1120 (r'"', String, '#pop'),1121 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.1122 ],1123 'string_single': [1124 (r'[^\'\n]+', String),1125 (r'\'\'', String),1126 (r'\'', String, '#pop'),1127 (r'\n', Text, '#pop'), # Stray linefeed also terminates strings.1128 ],1129 'comment': [1130 (r'[^*]+', Comment.Multiline),1131 (r'\*/', Comment.Multiline, '#pop'),1132 (r'\*', Comment.Multiline),1133 ]1134 }1135 1136 def _c(s):1137 return re.compile(s, re.MULTILINE)1138 _ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')1139 _ADDRESS_PATTERN = _c(r'^\s*address\s+')1140 _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')1141 _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')1142 _PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')1143 _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')1144 _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')1145 PATTERNS_AND_WEIGHTS = (1146 (_ADDRESS_COMMAND_PATTERN, 0.2),1147 (_ADDRESS_PATTERN, 0.05),1148 (_DO_WHILE_PATTERN, 0.1),1149 (_ELSE_DO_PATTERN, 0.1),1150 (_IF_THEN_DO_PATTERN, 0.1),1151 (_PROCEDURE_PATTERN, 0.5),1152 (_PARSE_ARG_PATTERN, 0.2),1153 )1154 1155 def analyse_text(text):1156 """1157 Check for initial comment and patterns that distinguish Rexx from other1158 C-like languages.1159 """1160 if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):1161 # Header matches MVS Rexx requirements, this is certainly a Rexx1162 # script.1163 return 1.01164 elif text.startswith('/*'):1165 # Header matches general Rexx requirements; the source code might1166 # still be any language using C comments such as C++, C# or Java.1167 lowerText = text.lower()1168 result = sum(weight1169 for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS1170 if pattern.search(lowerText)) + 0.011171 return min(result, 1.0)1172 1173 1174class MOOCodeLexer(RegexLexer):1175 """1176 For MOOCode (the MOO scripting language).1177 """1178 name = 'MOOCode'1179 url = 'http://www.moo.mud.org/'1180 filenames = ['*.moo']1181 aliases = ['moocode', 'moo']1182 mimetypes = ['text/x-moocode']1183 version_added = '0.9'1184 1185 tokens = {1186 'root': [1187 # Numbers1188 (r'(0|[1-9][0-9_]*)', Number.Integer),1189 # Strings1190 (r'"(\\\\|\\[^\\]|[^"\\])*"', String),1191 # exceptions1192 (r'(E_PERM|E_DIV)', Name.Exception),1193 # db-refs1194 (r'((#[-0-9]+)|(\$\w+))', Name.Entity),1195 # Keywords1196 (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'1197 r'|endwhile|break|continue|return|try'1198 r'|except|endtry|finally|in)\b', Keyword),1199 # builtins1200 (r'(random|length)', Name.Builtin),