Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
scripting.py1599 linesDownload Raw Back to lexers
1"""2    pygments.lexers.scripting3    ~~~~~~~~~~~~~~~~~~~~~~~~~4 5    Lexer for scripting and embedded languages.6 7    :copyright: Copyright 2006-2024 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 24class LuaLexer(RegexLexer):25    """26    For Lua source code.27 28    Additional options accepted:29 30    `func_name_highlighting`31        If given and ``True``, highlight builtin function names32        (default: ``True``).33    `disabled_modules`34        If given, must be a list of module names whose function names35        should not be highlighted. By default all modules are highlighted.36 37        To get a list of allowed modules have a look into the38        `_lua_builtins` module:39 40        .. sourcecode:: pycon41 42            >>> from pygments.lexers._lua_builtins import MODULES43            >>> MODULES.keys()44            ['string', 'coroutine', 'modules', 'io', 'basic', ...]45    """46 47    name = 'Lua'48    url = 'https://www.lua.org/'49    aliases = ['lua']50    filenames = ['*.lua', '*.wlua']51    mimetypes = ['text/x-lua', 'application/x-lua']52    version_added = ''53 54    _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'55    _comment_single = r'(?:--.*$)'56    _space = r'(?:\s+)'57    _s = rf'(?:{_comment_multiline}|{_comment_single}|{_space})'58    _name = r'(?:[^\W\d]\w*)'59 60    tokens = {61        'root': [62            # Lua allows a file to start with a shebang.63            (r'#!.*', Comment.Preproc),64            default('base'),65        ],66        'ws': [67            (_comment_multiline, Comment.Multiline),68            (_comment_single, Comment.Single),69            (_space, Text),70        ],71        'base': [72            include('ws'),73 74            (r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex),75            (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),76            (r'(?i)\d+e[+-]?\d+', Number.Float),77            (r'\d+', Number.Integer),78 79            # multiline strings80            (r'(?s)\[(=*)\[.*?\]\1\]', String),81 82            (r'::', Punctuation, 'label'),83            (r'\.{3}', Punctuation),84            (r'[=<>|~&+\-*/%#^]+|\.\.', Operator),85            (r'[\[\]{}().,:;]', Punctuation),86            (r'(and|or|not)\b', Operator.Word),87 88            ('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|'89             r'while)\b', Keyword.Reserved),90            (r'goto\b', Keyword.Reserved, 'goto'),91            (r'(local)\b', Keyword.Declaration),92            (r'(true|false|nil)\b', Keyword.Constant),93 94            (r'(function)\b', Keyword.Reserved, 'funcname'),95 96            (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),97 98            ("'", String.Single, combined('stringescape', 'sqs')),99            ('"', String.Double, combined('stringescape', 'dqs'))100        ],101 102        'funcname': [103            include('ws'),104            (r'[.:]', Punctuation),105            (rf'{_name}(?={_s}*[.:])', Name.Class),106            (_name, Name.Function, '#pop'),107            # inline function108            (r'\(', Punctuation, '#pop'),109        ],110 111        'goto': [112            include('ws'),113            (_name, Name.Label, '#pop'),114        ],115 116        'label': [117            include('ws'),118            (r'::', Punctuation, '#pop'),119            (_name, Name.Label),120        ],121 122        'stringescape': [123            (r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|'124             r'u\{[0-9a-fA-F]+\})', String.Escape),125        ],126 127        'sqs': [128            (r"'", String.Single, '#pop'),129            (r"[^\\']+", String.Single),130        ],131 132        'dqs': [133            (r'"', String.Double, '#pop'),134            (r'[^\\"]+', String.Double),135        ]136    }137 138    def __init__(self, **options):139        self.func_name_highlighting = get_bool_opt(140            options, 'func_name_highlighting', True)141        self.disabled_modules = get_list_opt(options, 'disabled_modules', [])142 143        self._functions = set()144        if self.func_name_highlighting:145            from pygments.lexers._lua_builtins import MODULES146            for mod, func in MODULES.items():147                if mod not in self.disabled_modules:148                    self._functions.update(func)149        RegexLexer.__init__(self, **options)150 151    def get_tokens_unprocessed(self, text):152        for index, token, value in \153                RegexLexer.get_tokens_unprocessed(self, text):154            if token is Name:155                if value in self._functions:156                    yield index, Name.Builtin, value157                    continue158                elif '.' in value:159                    a, b = value.split('.')160                    yield index, Name, a161                    yield index + len(a), Punctuation, '.'162                    yield index + len(a) + 1, Name, b163                    continue164            yield index, token, value165 166def _luau_make_expression(should_pop, _s):167    temp_list = [168        (r'0[xX][\da-fA-F_]*', Number.Hex, '#pop'),169        (r'0[bB][\d_]*', Number.Bin, '#pop'),170        (r'\.?\d[\d_]*(?:\.[\d_]*)?(?:[eE][+-]?[\d_]+)?', Number.Float, '#pop'),171 172        (words((173            'true', 'false', 'nil'174        ), suffix=r'\b'), Keyword.Constant, '#pop'),175 176        (r'\[(=*)\[[.\n]*?\]\1\]', String, '#pop'),177 178        (r'(\.)([a-zA-Z_]\w*)(?=%s*[({"\'])', bygroups(Punctuation, Name.Function), '#pop'),179        (r'(\.)([a-zA-Z_]\w*)', bygroups(Punctuation, Name.Variable), '#pop'),180 181        (rf'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?={_s}*[({{"\'])', Name.Other, '#pop'),182        (r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*', Name, '#pop'),183    ]184    if should_pop:185        return temp_list186    return [entry[:2] for entry in temp_list]187 188def _luau_make_expression_special(should_pop):189    temp_list = [190        (r'\{', Punctuation, ('#pop', 'closing_brace_base', 'expression')),191        (r'\(', Punctuation, ('#pop', 'closing_parenthesis_base', 'expression')),192 193        (r'::?', Punctuation, ('#pop', 'type_end', 'type_start')),194 195        (r"'", String.Single, ('#pop', 'string_single')),196        (r'"', String.Double, ('#pop', 'string_double')),197        (r'`', String.Backtick, ('#pop', 'string_interpolated')),198    ]199    if should_pop:200        return temp_list201    return [(entry[0], entry[1], entry[2][1:]) for entry in temp_list]202 203class LuauLexer(RegexLexer):204    """205    For Luau source code.206 207    Additional options accepted:208 209    `include_luau_builtins`210        If given and ``True``, automatically highlight Luau builtins211        (default: ``True``).212    `include_roblox_builtins`213        If given and ``True``, automatically highlight Roblox-specific builtins214        (default: ``False``).215    `additional_builtins`216        If given, must be a list of additional builtins to highlight.217    `disabled_builtins`218        If given, must be a list of builtins that will not be highlighted.219    """220 221    name = 'Luau'222    url = 'https://luau-lang.org/'223    aliases = ['luau']224    filenames = ['*.luau']225    version_added = '2.18'226 227    _comment_multiline = r'(?:--\[(?P<level>=*)\[[\w\W]*?\](?P=level)\])'228    _comment_single = r'(?:--.*$)'229    _s = r'(?:{}|{}|{})'.format(_comment_multiline, _comment_single, r'\s+')230 231    tokens = {232        'root': [233            (r'#!.*', Comment.Hashbang, 'base'),234            default('base'),235        ],236 237        'ws': [238            (_comment_multiline, Comment.Multiline),239            (_comment_single, Comment.Single),240            (r'\s+', Whitespace),241        ],242 243        'base': [244            include('ws'),245 246            *_luau_make_expression_special(False),247            (r'\.\.\.', Punctuation),248 249            (rf'type\b(?={_s}+[a-zA-Z_])', Keyword.Reserved, 'type_declaration'),250            (rf'export\b(?={_s}+[a-zA-Z_])', Keyword.Reserved),251 252            (r'(?:\.\.|//|[+\-*\/%^<>=])=?', Operator, 'expression'),253            (r'~=', Operator, 'expression'),254 255            (words((256                'and', 'or', 'not'257            ), suffix=r'\b'), Operator.Word, 'expression'),258 259            (words((260                'elseif', 'for', 'if', 'in', 'repeat', 'return', 'until',261                'while'), suffix=r'\b'), Keyword.Reserved, 'expression'),262            (r'local\b', Keyword.Declaration, 'expression'),263 264            (r'function\b', Keyword.Reserved, ('expression', 'func_name')),265 266            (r'[\])};]+', Punctuation),267 268            include('expression_static'),269            *_luau_make_expression(False, _s),270 271            (r'[\[.,]', Punctuation, 'expression'),272        ],273        'expression_static': [274            (words((275                'break', 'continue', 'do', 'else', 'elseif', 'end', 'for',276                'if', 'in', 'repeat', 'return', 'then', 'until', 'while'),277                suffix=r'\b'), Keyword.Reserved),278        ],279        'expression': [280            include('ws'),281 282            (r'if\b', Keyword.Reserved, ('ternary', 'expression')),283 284            (r'local\b', Keyword.Declaration),285            *_luau_make_expression_special(True),286            (r'\.\.\.', Punctuation, '#pop'),287 288            (r'function\b', Keyword.Reserved, 'func_name'),289 290            include('expression_static'),291            *_luau_make_expression(True, _s),292 293            default('#pop'),294        ],295        'ternary': [296            include('ws'),297 298            (r'else\b', Keyword.Reserved, '#pop'),299            (words((300                'then', 'elseif',301            ), suffix=r'\b'), Operator.Reserved, 'expression'),302 303            default('#pop'),304        ],305 306        'closing_brace_pop': [307            (r'\}', Punctuation, '#pop'),308        ],309        'closing_parenthesis_pop': [310            (r'\)', Punctuation, '#pop'),311        ],312        'closing_gt_pop': [313            (r'>', Punctuation, '#pop'),314        ],315 316        'closing_parenthesis_base': [317            include('closing_parenthesis_pop'),318            include('base'),319        ],320        'closing_parenthesis_type': [321            include('closing_parenthesis_pop'),322            include('type'),323        ],324        'closing_brace_base': [325            include('closing_brace_pop'),326            include('base'),327        ],328        'closing_brace_type': [329            include('closing_brace_pop'),330            include('type'),331        ],332        'closing_gt_type': [333            include('closing_gt_pop'),334            include('type'),335        ],336 337        'string_escape': [338            (r'\\z\s*', String.Escape),339            (r'\\(?:[abfnrtvz\\"\'`\{\n])|[\r\n]{1,2}|x[\da-fA-F]{2}|\d{1,3}|'340             r'u\{\}[\da-fA-F]*\}', String.Escape),341        ],342        'string_single': [343            include('string_escape'),344 345            (r"'", String.Single, "#pop"),346            (r"[^\\']+", String.Single),347        ],348        'string_double': [349            include('string_escape'),350 351            (r'"', String.Double, "#pop"),352            (r'[^\\"]+', String.Double),353        ],354        'string_interpolated': [355            include('string_escape'),356 357            (r'\{', Punctuation, ('closing_brace_base', 'expression')),358 359            (r'`', String.Backtick, "#pop"),360            (r'[^\\`\{]+', String.Backtick),361        ],362 363        'func_name': [364            include('ws'),365 366            (r'[.:]', Punctuation),367            (rf'[a-zA-Z_]\w*(?={_s}*[.:])', Name.Class),368            (r'[a-zA-Z_]\w*', Name.Function),369 370            (r'<', Punctuation, 'closing_gt_type'),371 372            (r'\(', Punctuation, '#pop'),373        ],374 375        'type': [376            include('ws'),377 378            (r'\(', Punctuation, 'closing_parenthesis_type'),379            (r'\{', Punctuation, 'closing_brace_type'),380            (r'<', Punctuation, 'closing_gt_type'),381 382            (r"'", String.Single, 'string_single'),383            (r'"', String.Double, 'string_double'),384 385            (r'[|&\.,\[\]:=]+', Punctuation),386            (r'->', Punctuation),387 388            (r'typeof\(', Name.Builtin, ('closing_parenthesis_base',389                                         'expression')),390            (r'[a-zA-Z_]\w*', Name.Class),391        ],392        'type_start': [393            include('ws'),394 395            (r'\(', Punctuation, ('#pop', 'closing_parenthesis_type')),396            (r'\{', Punctuation, ('#pop', 'closing_brace_type')),397            (r'<', Punctuation, ('#pop', 'closing_gt_type')),398 399            (r"'", String.Single, ('#pop', 'string_single')),400            (r'"', String.Double, ('#pop', 'string_double')),401 402            (r'typeof\(', Name.Builtin, ('#pop', 'closing_parenthesis_base',403                                         'expression')),404            (r'[a-zA-Z_]\w*', Name.Class, '#pop'),405        ],406        'type_end': [407            include('ws'),408 409            (r'[|&\.]', Punctuation, 'type_start'),410            (r'->', Punctuation, 'type_start'),411 412            (r'<', Punctuation, 'closing_gt_type'),413 414            default('#pop'),415        ],416        'type_declaration': [417            include('ws'),418 419            (r'[a-zA-Z_]\w*', Name.Class),420            (r'<', Punctuation, 'closing_gt_type'),421 422            (r'=', Punctuation, ('#pop', 'type_end', 'type_start')),423        ],424    }425 426    def __init__(self, **options):427        self.include_luau_builtins = get_bool_opt(428            options, 'include_luau_builtins', True)429        self.include_roblox_builtins = get_bool_opt(430            options, 'include_roblox_builtins', False)431        self.additional_builtins = get_list_opt(options, 'additional_builtins', [])432        self.disabled_builtins = get_list_opt(options, 'disabled_builtins', [])433 434        self._builtins = set(self.additional_builtins)435        if self.include_luau_builtins:436            from pygments.lexers._luau_builtins import LUAU_BUILTINS437            self._builtins.update(LUAU_BUILTINS)438        if self.include_roblox_builtins:439            from pygments.lexers._luau_builtins import ROBLOX_BUILTINS440            self._builtins.update(ROBLOX_BUILTINS)441        if self.additional_builtins:442            self._builtins.update(self.additional_builtins)443        self._builtins.difference_update(self.disabled_builtins)444 445        RegexLexer.__init__(self, **options)446 447    def get_tokens_unprocessed(self, text):448        for index, token, value in \449                RegexLexer.get_tokens_unprocessed(self, text):450            if token is Name or token is Name.Other:451                split_value = value.split('.')452                complete_value = []453                new_index = index454                for position in range(len(split_value), 0, -1):455                    potential_string = '.'.join(split_value[:position])456                    if potential_string in self._builtins:457                        yield index, Name.Builtin, potential_string458                        new_index += len(potential_string)459 460                        if complete_value:461                            yield new_index, Punctuation, '.'462                            new_index += 1463                        break464                    complete_value.insert(0, split_value[position - 1])465 466                for position, substring in enumerate(complete_value):467                    if position + 1 == len(complete_value):468                        if token is Name:469                            yield new_index, Name.Variable, substring470                            continue471                        yield new_index, Name.Function, substring472                        continue473                    yield new_index, Name.Variable, substring474                    new_index += len(substring)475                    yield new_index, Punctuation, '.'476                    new_index += 1477 478                continue479            yield index, token, value480 481class MoonScriptLexer(LuaLexer):482    """483    For MoonScript source code.484    """485 486    name = 'MoonScript'487    url = 'http://moonscript.org'488    aliases = ['moonscript', 'moon']489    filenames = ['*.moon']490    mimetypes = ['text/x-moonscript', 'application/x-moonscript']491    version_added = '1.5'492 493    tokens = {494        'root': [495            (r'#!(.*?)$', Comment.Preproc),496            default('base'),497        ],498        'base': [499            ('--.*$', Comment.Single),500            (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float),501            (r'(?i)\d+e[+-]?\d+', Number.Float),502            (r'(?i)0x[0-9a-f]*', Number.Hex),503            (r'\d+', Number.Integer),504            (r'\n', Whitespace),505            (r'[^\S\n]+', Text),506            (r'(?s)\[(=*)\[.*?\]\1\]', String),507            (r'(->|=>)', Name.Function),508            (r':[a-zA-Z_]\w*', Name.Variable),509            (r'(==|!=|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#!.\\:])', Operator),510            (r'[;,]', Punctuation),511            (r'[\[\]{}()]', Keyword.Type),512            (r'[a-zA-Z_]\w*:', Name.Variable),513            (words((514                'class', 'extends', 'if', 'then', 'super', 'do', 'with',515                'import', 'export', 'while', 'elseif', 'return', 'for', 'in',516                'from', 'when', 'using', 'else', 'and', 'or', 'not', 'switch',517                'break'), suffix=r'\b'),518             Keyword),519            (r'(true|false|nil)\b', Keyword.Constant),520            (r'(and|or|not)\b', Operator.Word),521            (r'(self)\b', Name.Builtin.Pseudo),522            (r'@@?([a-zA-Z_]\w*)?', Name.Variable.Class),523            (r'[A-Z]\w*', Name.Class),  # proper name524            (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name),525            ("'", String.Single, combined('stringescape', 'sqs')),526            ('"', String.Double, combined('stringescape', 'dqs'))527        ],528        'stringescape': [529            (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape)530        ],531        'sqs': [532            ("'", String.Single, '#pop'),533            ("[^']+", String)534        ],535        'dqs': [536            ('"', String.Double, '#pop'),537            ('[^"]+', String)538        ]539    }540 541    def get_tokens_unprocessed(self, text):542        # set . as Operator instead of Punctuation543        for index, token, value in LuaLexer.get_tokens_unprocessed(self, text):544            if token == Punctuation and value == ".":545                token = Operator546            yield index, token, value547 548 549class ChaiscriptLexer(RegexLexer):550    """551    For ChaiScript source code.552    """553 554    name = 'ChaiScript'555    url = 'http://chaiscript.com/'556    aliases = ['chaiscript', 'chai']557    filenames = ['*.chai']558    mimetypes = ['text/x-chaiscript', 'application/x-chaiscript']559    version_added = '2.0'560 561    flags = re.DOTALL | re.MULTILINE562 563    tokens = {564        'commentsandwhitespace': [565            (r'\s+', Text),566            (r'//.*?\n', Comment.Single),567            (r'/\*.*?\*/', Comment.Multiline),568            (r'^\#.*?\n', Comment.Single)569        ],570        'slashstartsregex': [571            include('commentsandwhitespace'),572            (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'573             r'([gim]+\b|\B)', String.Regex, '#pop'),574            (r'(?=/)', Text, ('#pop', 'badregex')),575            default('#pop')576        ],577        'badregex': [578            (r'\n', Text, '#pop')579        ],580        'root': [581            include('commentsandwhitespace'),582            (r'\n', Text),583            (r'[^\S\n]+', Text),584            (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|\.\.'585             r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),586            (r'[{(\[;,]', Punctuation, 'slashstartsregex'),587            (r'[})\].]', Punctuation),588            (r'[=+\-*/]', Operator),589            (r'(for|in|while|do|break|return|continue|if|else|'590             r'throw|try|catch'591             r')\b', Keyword, 'slashstartsregex'),592            (r'(var)\b', Keyword.Declaration, 'slashstartsregex'),593            (r'(attr|def|fun)\b', Keyword.Reserved),594            (r'(true|false)\b', Keyword.Constant),595            (r'(eval|throw)\b', Name.Builtin),596            (r'`\S+`', Name.Builtin),597            (r'[$a-zA-Z_]\w*', Name.Other),598            (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),599            (r'0x[0-9a-fA-F]+', Number.Hex),600            (r'[0-9]+', Number.Integer),601            (r'"', String.Double, 'dqstring'),602            (r"'(\\\\|\\[^\\]|[^'\\])*'", String.Single),603        ],604        'dqstring': [605            (r'\$\{[^"}]+?\}', String.Interpol),606            (r'\$', String.Double),607            (r'\\\\', String.Double),608            (r'\\"', String.Double),609            (r'[^\\"$]+', String.Double),610            (r'"', String.Double, '#pop'),611        ],612    }613 614 615class LSLLexer(RegexLexer):616    """617    For Second Life's Linden Scripting Language source code.618    """619 620    name = 'LSL'621    aliases = ['lsl']622    filenames = ['*.lsl']623    mimetypes = ['text/x-lsl']624    url = 'https://wiki.secondlife.com/wiki/Linden_Scripting_Language'625    version_added = '2.0'626 627    flags = re.MULTILINE628 629    lsl_keywords = r'\b(?:do|else|for|if|jump|return|while)\b'630    lsl_types = r'\b(?:float|integer|key|list|quaternion|rotation|string|vector)\b'631    lsl_states = r'\b(?:(?:state)\s+\w+|default)\b'632    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'633    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'634    lsl_constants_float = r'\b(?:DEG_TO_RAD|PI(?:_BY_TWO)?|RAD_TO_DEG|SQRT2|TWO_PI)\b'635    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'636    lsl_constants_integer_boolean = r'\b(?:FALSE|TRUE)\b'637    lsl_constants_rotation = r'\b(?:ZERO_ROTATION)\b'638    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'639    lsl_constants_vector = r'\b(?:TOUCH_INVALID_(?:TEXCOORD|VECTOR)|ZERO_VECTOR)\b'640    lsl_invalid_broken = r'\b(?:LAND_(?:LARGE|MEDIUM|SMALL)_BRUSH)\b'641    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'642    lsl_invalid_illegal = r'\b(?:event)\b'643    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'644    lsl_reserved_godmode = r'\b(?:ll(?:GodLikeRezObject|Set(?:Inventory|Object)PermMask))\b'645    lsl_reserved_log = r'\b(?:print)\b'646    lsl_operators = r'\+\+|\-\-|<<|>>|&&?|\|\|?|\^|~|[!%<>=*+\-/]=?'647 648    tokens = {649        'root':650        [651            (r'//.*?\n',                          Comment.Single),652            (r'/\*',                              Comment.Multiline, 'comment'),653            (r'"',                                String.Double, 'string'),654            (lsl_keywords,                        Keyword),655            (lsl_types,                           Keyword.Type),656            (lsl_states,                          Name.Class),657            (lsl_events,                          Name.Builtin),658            (lsl_functions_builtin,               Name.Function),659            (lsl_constants_float,                 Keyword.Constant),660            (lsl_constants_integer,               Keyword.Constant),661            (lsl_constants_integer_boolean,       Keyword.Constant),662            (lsl_constants_rotation,              Keyword.Constant),663            (lsl_constants_string,                Keyword.Constant),664            (lsl_constants_vector,                Keyword.Constant),665            (lsl_invalid_broken,                  Error),666            (lsl_invalid_deprecated,              Error),667            (lsl_invalid_illegal,                 Error),668            (lsl_invalid_unimplemented,           Error),669            (lsl_reserved_godmode,                Keyword.Reserved),670            (lsl_reserved_log,                    Keyword.Reserved),671            (r'\b([a-zA-Z_]\w*)\b',     Name.Variable),672            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d*', Number.Float),673            (r'(\d+\.\d*|\.\d+)',                 Number.Float),674            (r'0[xX][0-9a-fA-F]+',                Number.Hex),675            (r'\d+',                              Number.Integer),676            (lsl_operators,                       Operator),677            (r':=?',                              Error),678            (r'[,;{}()\[\]]',                     Punctuation),679            (r'\n+',                              Whitespace),680            (r'\s+',                              Whitespace)681        ],682        'comment':683        [684            (r'[^*/]+',                           Comment.Multiline),685            (r'/\*',                              Comment.Multiline, '#push'),686            (r'\*/',                              Comment.Multiline, '#pop'),687            (r'[*/]',                             Comment.Multiline)688        ],689        'string':690        [691            (r'\\([nt"\\])',                      String.Escape),692            (r'"',                                String.Double, '#pop'),693            (r'\\.',                              Error),694            (r'[^"\\]+',                          String.Double),695        ]696    }697 698 699class AppleScriptLexer(RegexLexer):700    """701    For AppleScript source code,702    including `AppleScript Studio703    <http://developer.apple.com/documentation/AppleScript/704    Reference/StudioReference>`_.705    Contributed by Andreas Amann <aamann@mac.com>.706    """707 708    name = 'AppleScript'709    url = 'https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html'710    aliases = ['applescript']711    filenames = ['*.applescript']712    version_added = '1.0'713 714    flags = re.MULTILINE | re.DOTALL715 716    Identifiers = r'[a-zA-Z]\w*'717 718    # XXX: use words() for all of these719    Literals = ('AppleScript', 'current application', 'false', 'linefeed',720                'missing value', 'pi', 'quote', 'result', 'return', 'space',721                'tab', 'text item delimiters', 'true', 'version')722    Classes = ('alias ', 'application ', 'boolean ', 'class ', 'constant ',723               'date ', 'file ', 'integer ', 'list ', 'number ', 'POSIX file ',724               'real ', 'record ', 'reference ', 'RGB color ', 'script ',725               'text ', 'unit types', '(?:Unicode )?text', 'string')726    BuiltIn = ('attachment', 'attribute run', 'character', 'day', 'month',727               'paragraph', 'word', 'year')728    HandlerParams = ('about', 'above', 'against', 'apart from', 'around',729                     'aside from', 'at', 'below', 'beneath', 'beside',730                     'between', 'for', 'given', 'instead of', 'on', 'onto',731                     'out of', 'over', 'since')732    Commands = ('ASCII (character|number)', 'activate', 'beep', 'choose URL',733                'choose application', 'choose color', 'choose file( name)?',734                'choose folder', 'choose from list',735                'choose remote application', 'clipboard info',736                'close( access)?', 'copy', 'count', 'current date', 'delay',737                'delete', 'display (alert|dialog)', 'do shell script',738                'duplicate', 'exists', 'get eof', 'get volume settings',739                'info for', 'launch', 'list (disks|folder)', 'load script',740                'log', 'make', 'mount volume', 'new', 'offset',741                'open( (for access|location))?', 'path to', 'print', 'quit',742                'random number', 'read', 'round', 'run( script)?',743                'say', 'scripting components',744                'set (eof|the clipboard to|volume)', 'store script',745                'summarize', 'system attribute', 'system info',746                'the clipboard', 'time to GMT', 'write', 'quoted form')747    References = ('(in )?back of', '(in )?front of', '[0-9]+(st|nd|rd|th)',748                  'first', 'second', 'third', 'fourth', 'fifth', 'sixth',749                  'seventh', 'eighth', 'ninth', 'tenth', 'after', 'back',750                  'before', 'behind', 'every', 'front', 'index', 'last',751                  'middle', 'some', 'that', 'through', 'thru', 'where', 'whose')752    Operators = ("and", "or", "is equal", "equals", "(is )?equal to", "is not",753                 "isn't", "isn't equal( to)?", "is not equal( to)?",754                 "doesn't equal", "does not equal", "(is )?greater than",755                 "comes after", "is not less than or equal( to)?",756                 "isn't less than or equal( to)?", "(is )?less than",757                 "comes before", "is not greater than or equal( to)?",758                 "isn't greater than or equal( to)?",759                 "(is  )?greater than or equal( to)?", "is not less than",760                 "isn't less than", "does not come before",761                 "doesn't come before", "(is )?less than or equal( to)?",762                 "is not greater than", "isn't greater than",763                 "does not come after", "doesn't come after", "starts? with",764                 "begins? with", "ends? with", "contains?", "does not contain",765                 "doesn't contain", "is in", "is contained by", "is not in",766                 "is not contained by", "isn't contained by", "div", "mod",767                 "not", "(a  )?(ref( to)?|reference to)", "is", "does")768    Control = ('considering', 'else', 'error', 'exit', 'from', 'if',769               'ignoring', 'in', 'repeat', 'tell', 'then', 'times', 'to',770               'try', 'until', 'using terms from', 'while', 'whith',771               'with timeout( of)?', 'with transaction', 'by', 'continue',772               'end', 'its?', 'me', 'my', 'return', 'of', 'as')773    Declarations = ('global', 'local', 'prop(erty)?', 'set', 'get')774    Reserved = ('but', 'put', 'returning', 'the')775    StudioClasses = ('action cell', 'alert reply', 'application', 'box',776                     'browser( cell)?', 'bundle', 'button( cell)?', 'cell',777                     'clip view', 'color well', 'color-panel',778                     'combo box( item)?', 'control',779                     'data( (cell|column|item|row|source))?', 'default entry',780                     'dialog reply', 'document', 'drag info', 'drawer',781                     'event', 'font(-panel)?', 'formatter',782                     'image( (cell|view))?', 'matrix', 'menu( item)?', 'item',783                     'movie( view)?', 'open-panel', 'outline view', 'panel',784                     'pasteboard', 'plugin', 'popup button',785                     'progress indicator', 'responder', 'save-panel',786                     'scroll view', 'secure text field( cell)?', 'slider',787                     'sound', 'split view', 'stepper', 'tab view( item)?',788                     'table( (column|header cell|header view|view))',789                     'text( (field( cell)?|view))?', 'toolbar( item)?',790                     'user-defaults', 'view', 'window')791    StudioEvents = ('accept outline drop', 'accept table drop', 'action',792                    'activated', 'alert ended', 'awake from nib', 'became key',793                    'became main', 'begin editing', 'bounds changed',794                    'cell value', 'cell value changed', 'change cell value',795                    'change item value', 'changed', 'child of item',796                    'choose menu item', 'clicked', 'clicked toolbar item',797                    'closed', 'column clicked', 'column moved',798                    'column resized', 'conclude drop', 'data representation',799                    'deminiaturized', 'dialog ended', 'document nib name',800                    'double clicked', 'drag( (entered|exited|updated))?',801                    'drop', 'end editing', 'exposed', 'idle', 'item expandable',802                    'item value', 'item value changed', 'items changed',803                    'keyboard down', 'keyboard up', 'launched',804                    'load data representation', 'miniaturized', 'mouse down',805                    'mouse dragged', 'mouse entered', 'mouse exited',806                    'mouse moved', 'mouse up', 'moved',807                    'number of browser rows', 'number of items',808                    'number of rows', 'open untitled', 'opened', 'panel ended',809                    'parameters updated', 'plugin loaded', 'prepare drop',810                    'prepare outline drag', 'prepare outline drop',811                    'prepare table drag', 'prepare table drop',812                    'read from file', 'resigned active', 'resigned key',813                    'resigned main', 'resized( sub views)?',814                    'right mouse down', 'right mouse dragged',815                    'right mouse up', 'rows changed', 'scroll wheel',816                    'selected tab view item', 'selection changed',817                    'selection changing', 'should begin editing',818                    'should close', 'should collapse item',819                    'should end editing', 'should expand item',820                    'should open( untitled)?',821                    'should quit( after last window closed)?',822                    'should select column', 'should select item',823                    'should select row', 'should select tab view item',824                    'should selection change', 'should zoom', 'shown',825                    'update menu item', 'update parameters',826                    'update toolbar item', 'was hidden', 'was miniaturized',827                    'will become active', 'will close', 'will dismiss',828                    'will display browser cell', 'will display cell',829                    'will display item cell', 'will display outline cell',830                    'will finish launching', 'will hide', 'will miniaturize',831                    'will move', 'will open', 'will pop up', 'will quit',832                    'will resign active', 'will resize( sub views)?',833                    'will select tab view item', 'will show', 'will zoom',834                    'write to file', 'zoomed')835    StudioCommands = ('animate', 'append', 'call method', 'center',836                      'close drawer', 'close panel', 'display',837                      'display alert', 'display dialog', 'display panel', 'go',838                      'hide', 'highlight', 'increment', 'item for',839                      'load image', 'load movie', 'load nib', 'load panel',840                      'load sound', 'localized string', 'lock focus', 'log',841                      'open drawer', 'path for', 'pause', 'perform action',842                      'play', 'register', 'resume', 'scroll', 'select( all)?',843                      'show', 'size to fit', 'start', 'step back',844                      'step forward', 'stop', 'synchronize', 'unlock focus',845                      'update')846    StudioProperties = ('accepts arrow key', 'action method', 'active',847                        'alignment', 'allowed identifiers',848                        'allows branch selection', 'allows column reordering',849                        'allows column resizing', 'allows column selection',850                        'allows customization',851                        'allows editing text attributes',852                        'allows empty selection', 'allows mixed state',853                        'allows multiple selection', 'allows reordering',854                        'allows undo', 'alpha( value)?', 'alternate image',855                        'alternate increment value', 'alternate title',856                        'animation delay', 'associated file name',857                        'associated object', 'auto completes', 'auto display',858                        'auto enables items', 'auto repeat',859                        'auto resizes( outline column)?',860                        'auto save expanded items', 'auto save name',861                        'auto save table columns', 'auto saves configuration',862                        'auto scroll', 'auto sizes all columns to fit',863                        'auto sizes cells', 'background color', 'bezel state',864                        'bezel style', 'bezeled', 'border rect', 'border type',865                        'bordered', 'bounds( rotation)?', 'box type',866                        'button returned', 'button type',867                        'can choose directories', 'can choose files',868                        'can draw', 'can hide',869                        'cell( (background color|size|type))?', 'characters',870                        'class', 'click count', 'clicked( data)? column',871                        'clicked data item', 'clicked( data)? row',872                        'closeable', 'collating', 'color( (mode|panel))',873                        'command key down', 'configuration',874                        'content(s| (size|view( margins)?))?', 'context',875                        'continuous', 'control key down', 'control size',876                        'control tint', 'control view',877                        'controller visible', 'coordinate system',878                        'copies( on scroll)?', 'corner view', 'current cell',879                        'current column', 'current( field)?  editor',880                        'current( menu)? item', 'current row',881                        'current tab view item', 'data source',882                        'default identifiers', 'delta (x|y|z)',883                        'destination window', 'directory', 'display mode',884                        'displayed cell', 'document( (edited|rect|view))?',885                        'double value', 'dragged column', 'dragged distance',886                        'dragged items', 'draws( cell)? background',887                        'draws grid', 'dynamically scrolls', 'echos bullets',888                        'edge', 'editable', 'edited( data)? column',889                        'edited data item', 'edited( data)? row', 'enabled',890                        'enclosing scroll view', 'ending page',891                        'error handling', 'event number', 'event type',892                        'excluded from windows menu', 'executable path',893                        'expanded', 'fax number', 'field editor', 'file kind',894                        'file name', 'file type', 'first responder',895                        'first visible column', 'flipped', 'floating',896                        'font( panel)?', 'formatter', 'frameworks path',897                        'frontmost', 'gave up', 'grid color', 'has data items',898                        'has horizontal ruler', 'has horizontal scroller',899                        'has parent data item', 'has resize indicator',900                        'has shadow', 'has sub menu', 'has vertical ruler',901                        'has vertical scroller', 'header cell', 'header view',902                        'hidden', 'hides when deactivated', 'highlights by',903                        'horizontal line scroll', 'horizontal page scroll',904                        'horizontal ruler view', 'horizontally resizable',905                        'icon image', 'id', 'identifier',906                        'ignores multiple clicks',907                        'image( (alignment|dims when disabled|frame style|scaling))?',908                        'imports graphics', 'increment value',909                        'indentation per level', 'indeterminate', 'index',910                        'integer value', 'intercell spacing', 'item height',911                        'key( (code|equivalent( modifier)?|window))?',912                        'knob thickness', 'label', 'last( visible)? column',913                        'leading offset', 'leaf', 'level', 'line scroll',914                        'loaded', 'localized sort', 'location', 'loop mode',915                        'main( (bunde|menu|window))?', 'marker follows cell',916                        'matrix mode', 'maximum( content)? size',917                        'maximum visible columns',918                        'menu( form representation)?', 'miniaturizable',919                        'miniaturized', 'minimized image', 'minimized title',920                        'minimum column width', 'minimum( content)? size',921                        'modal', 'modified', 'mouse down state',922                        'movie( (controller|file|rect))?', 'muted', 'name',923                        'needs display', 'next state', 'next text',924                        'number of tick marks', 'only tick mark values',925                        'opaque', 'open panel', 'option key down',926                        'outline table column', 'page scroll', 'pages across',927                        'pages down', 'palette label', 'pane splitter',928                        'parent data item', 'parent window', 'pasteboard',929                        'path( (names|separator))?', 'playing',930                        'plays every frame', 'plays selection only', 'position',931                        'preferred edge', 'preferred type', 'pressure',932                        'previous text', 'prompt', 'properties',933                        'prototype cell', 'pulls down', 'rate',934                        'released when closed', 'repeated',935                        'requested print time', 'required file type',936                        'resizable', 'resized column', 'resource path',937                        'returns records', 'reuses columns', 'rich text',938                        'roll over', 'row height', 'rulers visible',939                        'save panel', 'scripts path', 'scrollable',940                        'selectable( identifiers)?', 'selected cell',941                        'selected( data)? columns?', 'selected data items?',942                        'selected( data)? rows?', 'selected item identifier',943                        'selection by rect', 'send action on arrow key',944                        'sends action when done editing', 'separates columns',945                        'separator item', 'sequence number', 'services menu',946                        'shared frameworks path', 'shared support path',947                        'sheet', 'shift key down', 'shows alpha',948                        'shows state by', 'size( mode)?',949                        'smart insert delete enabled', 'sort case sensitivity',950                        'sort column', 'sort order', 'sort type',951                        'sorted( data rows)?', 'sound', 'source( mask)?',952                        'spell checking enabled', 'starting page', 'state',953                        'string value', 'sub menu', 'super menu', 'super view',954                        'tab key traverses cells', 'tab state', 'tab type',955                        'tab view', 'table view', 'tag', 'target( printer)?',956                        'text color', 'text container insert',957                        'text container origin', 'text returned',958                        'tick mark position', 'time stamp',959                        'title(d| (cell|font|height|position|rect))?',960                        'tool tip', 'toolbar', 'trailing offset', 'transparent',961                        'treat packages as directories', 'truncated labels',962                        'types', 'unmodified characters', 'update views',963                        'use sort indicator', 'user defaults',964                        'uses data source', 'uses ruler',965                        'uses threaded animation',966                        'uses title from previous column', 'value wraps',967                        'version',968                        'vertical( (line scroll|page scroll|ruler view))?',969                        'vertically resizable', 'view',970                        'visible( document rect)?', 'volume', 'width', 'window',971                        'windows menu', 'wraps', 'zoomable', 'zoomed')972 973    tokens = {974        'root': [975            (r'\s+', Text),976            (r'¬\n', String.Escape),977            (r"'s\s+", Text),  # This is a possessive, consider moving978            (r'(--|#).*?$', Comment),979            (r'\(\*', Comment.Multiline, 'comment'),980            (r'[(){}!,.:]', Punctuation),981            (r'(«)([^»]+)(»)',982             bygroups(Text, Name.Builtin, Text)),983            (r'\b((?:considering|ignoring)\s*)'984             r'(application responses|case|diacriticals|hyphens|'985             r'numeric strings|punctuation|white space)',986             bygroups(Keyword, Name.Builtin)),987            (r'(-|\*|\+|&|≠|>=?|<=?|=|≥|≤|/|÷|\^)', Operator),988            (r"\b({})\b".format('|'.join(Operators)), Operator.Word),989            (r'^(\s*(?:on|end)\s+)'990             r'({})'.format('|'.join(StudioEvents[::-1])),991             bygroups(Keyword, Name.Function)),992            (r'^(\s*)(in|on|script|to)(\s+)', bygroups(Text, Keyword, Text)),993            (r'\b(as )({})\b'.format('|'.join(Classes)),994             bygroups(Keyword, Name.Class)),995            (r'\b({})\b'.format('|'.join(Literals)), Name.Constant),996            (r'\b({})\b'.format('|'.join(Commands)), Name.Builtin),997            (r'\b({})\b'.format('|'.join(Control)), Keyword),998            (r'\b({})\b'.format('|'.join(Declarations)), Keyword),999            (r'\b({})\b'.format('|'.join(Reserved)), Name.Builtin),1000            (r'\b({})s?\b'.format('|'.join(BuiltIn)), Name.Builtin),1001            (r'\b({})\b'.format('|'.join(HandlerParams)), Name.Builtin),1002            (r'\b({})\b'.format('|'.join(StudioProperties)), Name.Attribute),1003            (r'\b({})s?\b'.format('|'.join(StudioClasses)), Name.Builtin),1004            (r'\b({})\b'.format('|'.join(StudioCommands)), Name.Builtin),1005            (r'\b({})\b'.format('|'.join(References)), Name.Builtin),1006            (r'"(\\\\|\\[^\\]|[^"\\])*"', String.Double),1007            (rf'\b({Identifiers})\b', Name.Variable),1008            (r'[-+]?(\d+\.\d*|\d*\.\d+)(E[-+][0-9]+)?', Number.Float),1009            (r'[-+]?\d+', Number.Integer),1010        ],1011        'comment': [1012            (r'\(\*', Comment.Multiline, '#push'),1013            (r'\*\)', Comment.Multiline, '#pop'),1014            ('[^*(]+', Comment.Multiline),1015            ('[*(]', Comment.Multiline),1016        ],1017    }1018 1019 1020class RexxLexer(RegexLexer):1021    """1022    Rexx is a scripting language available for1023    a wide range of different platforms with its roots found on mainframe1024    systems. It is popular for I/O- and data based tasks and can act as glue1025    language to bind different applications together.1026    """1027    name = 'Rexx'1028    url = 'http://www.rexxinfo.org/'1029    aliases = ['rexx', 'arexx']1030    filenames = ['*.rexx', '*.rex', '*.rx', '*.arexx']1031    mimetypes = ['text/x-rexx']1032    version_added = '2.0'1033    flags = re.IGNORECASE1034 1035    tokens = {1036        'root': [1037            (r'\s+', Whitespace),1038            (r'/\*', Comment.Multiline, 'comment'),1039            (r'"', String, 'string_double'),1040            (r"'", String, 'string_single'),1041            (r'[0-9]+(\.[0-9]+)?(e[+-]?[0-9])?', Number),1042            (r'([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b',1043             bygroups(Name.Function, Whitespace, Operator, Whitespace,1044                      Keyword.Declaration)),1045            (r'([a-z_]\w*)(\s*)(:)',1046             bygroups(Name.Label, Whitespace, Operator)),1047            include('function'),1048            include('keyword'),1049            include('operator'),1050            (r'[a-z_]\w*', Text),1051        ],1052        'function': [1053            (words((1054                'abbrev', 'abs', 'address', 'arg', 'b2x', 'bitand', 'bitor', 'bitxor',1055                'c2d', 'c2x', 'center', 'charin', 'charout', 'chars', 'compare',1056                'condition', 'copies', 'd2c', 'd2x', 'datatype', 'date', 'delstr',1057                'delword', 'digits', 'errortext', 'form', 'format', 'fuzz', 'insert',1058                'lastpos', 'left', 'length', 'linein', 'lineout', 'lines', 'max',1059                'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',1060                'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol',1061                'time', 'trace', 'translate', 'trunc', 'value', 'verify', 'word',1062                'wordindex', 'wordlength', 'wordpos', 'words', 'x2b', 'x2c', 'x2d',1063                'xrange'), suffix=r'(\s*)(\()'),1064             bygroups(Name.Builtin, Whitespace, Operator)),1065        ],1066        'keyword': [1067            (r'(address|arg|by|call|do|drop|else|end|exit|for|forever|if|'1068             r'interpret|iterate|leave|nop|numeric|off|on|options|parse|'1069             r'pull|push|queue|return|say|select|signal|to|then|trace|until|'1070             r'while)\b', Keyword.Reserved),1071        ],1072        'operator': [1073            (r'(-|//|/|\(|\)|\*\*|\*|\\<<|\\<|\\==|\\=|\\>>|\\>|\\|\|\||\||'1074             r'&&|&|%|\+|<<=|<<|<=|<>|<|==|=|><|>=|>>=|>>|>|¬<<|¬<|¬==|¬=|'1075             r'¬>>|¬>|¬|\.|,)', Operator),1076        ],1077        'string_double': [1078            (r'[^"\n]+', String),1079            (r'""', String),1080            (r'"', String, '#pop'),1081            (r'\n', Text, '#pop'),  # Stray linefeed also terminates strings.1082        ],1083        'string_single': [1084            (r'[^\'\n]+', String),1085            (r'\'\'', String),1086            (r'\'', String, '#pop'),1087            (r'\n', Text, '#pop'),  # Stray linefeed also terminates strings.1088        ],1089        'comment': [1090            (r'[^*]+', Comment.Multiline),1091            (r'\*/', Comment.Multiline, '#pop'),1092            (r'\*', Comment.Multiline),1093        ]1094    }1095 1096    def _c(s):1097        return re.compile(s, re.MULTILINE)1098    _ADDRESS_COMMAND_PATTERN = _c(r'^\s*address\s+command\b')1099    _ADDRESS_PATTERN = _c(r'^\s*address\s+')1100    _DO_WHILE_PATTERN = _c(r'^\s*do\s+while\b')1101    _IF_THEN_DO_PATTERN = _c(r'^\s*if\b.+\bthen\s+do\s*$')1102    _PROCEDURE_PATTERN = _c(r'^\s*([a-z_]\w*)(\s*)(:)(\s*)(procedure)\b')1103    _ELSE_DO_PATTERN = _c(r'\belse\s+do\s*$')1104    _PARSE_ARG_PATTERN = _c(r'^\s*parse\s+(upper\s+)?(arg|value)\b')1105    PATTERNS_AND_WEIGHTS = (1106        (_ADDRESS_COMMAND_PATTERN, 0.2),1107        (_ADDRESS_PATTERN, 0.05),1108        (_DO_WHILE_PATTERN, 0.1),1109        (_ELSE_DO_PATTERN, 0.1),1110        (_IF_THEN_DO_PATTERN, 0.1),1111        (_PROCEDURE_PATTERN, 0.5),1112        (_PARSE_ARG_PATTERN, 0.2),1113    )1114 1115    def analyse_text(text):1116        """1117        Check for initial comment and patterns that distinguish Rexx from other1118        C-like languages.1119        """1120        if re.search(r'/\*\**\s*rexx', text, re.IGNORECASE):1121            # Header matches MVS Rexx requirements, this is certainly a Rexx1122            # script.1123            return 1.01124        elif text.startswith('/*'):1125            # Header matches general Rexx requirements; the source code might1126            # still be any language using C comments such as C++, C# or Java.1127            lowerText = text.lower()1128            result = sum(weight1129                         for (pattern, weight) in RexxLexer.PATTERNS_AND_WEIGHTS1130                         if pattern.search(lowerText)) + 0.011131            return min(result, 1.0)1132 1133 1134class MOOCodeLexer(RegexLexer):1135    """1136    For MOOCode (the MOO scripting language).1137    """1138    name = 'MOOCode'1139    url = 'http://www.moo.mud.org/'1140    filenames = ['*.moo']1141    aliases = ['moocode', 'moo']1142    mimetypes = ['text/x-moocode']1143    version_added = '0.9'1144 1145    tokens = {1146        'root': [1147            # Numbers1148            (r'(0|[1-9][0-9_]*)', Number.Integer),1149            # Strings1150            (r'"(\\\\|\\[^\\]|[^"\\])*"', String),1151            # exceptions1152            (r'(E_PERM|E_DIV)', Name.Exception),1153            # db-refs1154            (r'((#[-0-9]+)|(\$\w+))', Name.Entity),1155            # Keywords1156            (r'\b(if|else|elseif|endif|for|endfor|fork|endfork|while'1157             r'|endwhile|break|continue|return|try'1158             r'|except|endtry|finally|in)\b', Keyword),1159            # builtins1160            (r'(random|length)', Name.Builtin),1161            # special variables1162            (r'(player|caller|this|args)', Name.Variable.Instance),1163            # skip whitespace1164            (r'\s+', Text),1165            (r'\n', Text),1166            # other operators1167            (r'([!;=,{}&|:.\[\]@()<>?]+)', Operator),1168            # function call1169            (r'(\w+)(\()', bygroups(Name.Function, Operator)),1170            # variables1171            (r'(\w+)', Text),1172        ]1173    }1174 1175 1176class HybrisLexer(RegexLexer):1177    """1178    For Hybris source code.1179    """1180 1181    name = 'Hybris'1182    aliases = ['hybris']1183    filenames = ['*.hyb']1184    mimetypes = ['text/x-hybris', 'application/x-hybris']1185    url = 'https://github.com/evilsocket/hybris'1186    version_added = '1.4'1187 1188    flags = re.MULTILINE | re.DOTALL1189 1190    tokens = {1191        'root': [1192            # method names1193            (r'^(\s*(?:function|method|operator\s+)+?)'1194             r'([a-zA-Z_]\w*)'1195             r'(\s*)(\()', bygroups(Keyword, Name.Function, Text, Operator)),1196            (r'[^\S\n]+', Text),1197            (r'//.*?\n', Comment.Single),1198            (r'/\*.*?\*/', Comment.Multiline),1199            (r'@[a-zA-Z_][\w.]*', Name.Decorator),1200            (r'(break|case|catch|next|default|do|else|finally|for|foreach|of|'

Showing the first 1,200 of 1599 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai