class MapFileLexer(RegexLexer): name = 'mapfile' aliases = ['mapfile'] filenames = ['*.map'] flags = re.IGNORECASE tokens = { 'root': [ (r'\s+', Text), (r'\[.*?\]', Name.Other), (r'[{}\[\]();,-.]+', Punctuation), (r'#.*', Comment), (r'(AND|OR|NOT|EQ|GT|LT|GE|LE|NE|IN|IEQ)\b', Operator.Word), (r'!=|==|<=|>=|=~|&&|\|\||[-~+/*%=<>&^|./\$]', Operator), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), (r'`([^`])*`', Number.Date), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), # (constants, Keyword.Constant), # (r"""[]{}:(),;[]""", Punctuation), # (r'(MAP)\b', Generic.Heading), (keywords, Keyword), (builtins, Name.Builtin), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float), (r'[0-9]+', Number.Integer), ], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings include('strings') ], 'tdqs': [(r'"""', String, '#pop'), include('strings'), include('nl')], 'tsqs': [(r"'''", String, '#pop'), include('strings'), include('nl')], 'strings': [ (r'%(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [(r'\n', String)], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], }
class PythonLexer(RegexLexer): """ For `Python <http://www.python.org>`_ source code. """ name = 'Python' aliases = ['python', 'py', 'sage'] filenames = [ '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage' ] mimetypes = ['text/x-python', 'application/x-python'] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)), (r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)), (r'[^\S\n]+', Text), (r'#.*$', Comment), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('backtick'), ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), ('[uU]?"""', String, combined('stringescape', 'tdqs')), ("[uU]?'''", String, combined('stringescape', 'tsqs')), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (r'(assert|break|continue|del|elif|else|except|exec|' r'finally|for|global|if|lambda|pass|print|raise|' r'return|try|while|yield(\s+from)?|as|with)\b', Keyword), ], 'builtins': [ (r'(?<!\.)(__import__|abs|all|any|apply|basestring|bin|bool|buffer|' r'bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|' r'complex|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|' r'file|filter|float|frozenset|getattr|globals|hasattr|hash|hex|id|' r'input|int|intern|isinstance|issubclass|iter|len|list|locals|' r'long|map|max|min|next|object|oct|open|ord|pow|property|range|' r'raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|' r'sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|' r'vars|xrange|zip)\b', Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True' r')\b', Name.Builtin.Pseudo), (r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|' r'BaseException|DeprecationWarning|EOFError|EnvironmentError|' r'Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|' r'ImportError|ImportWarning|IndentationError|IndexError|KeyError|' r'KeyboardInterrupt|LookupError|MemoryError|NameError|' r'NotImplemented|NotImplementedError|OSError|OverflowError|' r'OverflowWarning|PendingDeprecationWarning|ReferenceError|' r'RuntimeError|RuntimeWarning|StandardError|StopIteration|' r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|' r'TypeError|UnboundLocalError|UnicodeDecodeError|' r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|' r'UnicodeWarning|UserWarning|ValueError|VMSError|Warning|' r'WindowsError|ZeroDivisionError)\b', Name.Exception), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[0-7]+j?', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+j?', Number.Integer)], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[a-zA-Z0-9_.]+', Name.Decorator), ('[a-zA-Z_][a-zA-Z0-9_]*', Name), ], 'funcname': [('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop')], 'classname': [('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')], 'import': [ (r'(?:[ \t]|\\\n)+', Text), (r'as\b', Keyword.Namespace), (r',', Operator), (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace), (r'', Text, '#pop') # all else: go back ], 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'import\b', Keyword.Namespace, '#pop'), # if None occurs here, it's "raise x from None", since None can # never be a module name (r'None\b', Name.Builtin.Pseudo, '#pop'), # sadly, in "raise x from y" y will be highlighted as namespace too (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace), # anything else here also means "raise x from y" and is therefore # not an error (r'', Text, '#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings': [ (r'%(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [(r'\n', String)], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings') ], 'tdqs': [(r'"""', String, '#pop'), include('strings'), include('nl')], 'tsqs': [(r"'''", String, '#pop'), include('strings'), include('nl')], } def analyse_text(text): return shebang_matches(text, r'pythonw?(2(\.\d)?)?')
class BaseLexer(RegexLexer): """Common for both Solidity and Yul.""" tokens = { 'assembly': [ include('comments'), include('numbers'), include('strings'), include('whitespace'), (r'\{', Punctuation, '#push'), (r'\}', Punctuation, '#pop'), (r'[(),]', Punctuation), (r':=|=:', Operator), (r'(let)(\s*)(\w*\b)', bygroups(Operator.Word, Text, Name.Variable)), # evm instructions; ordered by opcode (r'(stop|add|mul|sub|div|sdiv|mod|smod|addmod|mulmod|exp|' r'signextend|' r'lt|gt|slt|sgt|eq|iszero|and|or|xor|not|byte|shl|shr|sar|' r'keccak256|' r'address|balance|origin|caller|' r'callvalue|calldataload|calldatasize|calldatacopy|' r'codesize|codecopy|gasprice|extcodesize|extcodecopy|' r'returndatasize|returndatacopy|extcodehash|' r'blockhash|coinbase|timestamp|number|difficulty|gaslimit|' r'chainid|selfbalance|' r'pop|mload|mstore|mstore8|sload|sstore|' r'pc|msize|gas|' r'log0|log1|log2|log3|log4|' r'create|call|callcode|return|delegatecall|create2|' r'staticcall|revert|' r'invalid|selfdestruct)\b', Name.Function), # obsolete aliases for keccak256 and selfdestruct (r'(sha3|suicide)\b', Name.Function), (r'(case|default|for|if|switch)\b', Keyword), # everything else is either a local/external var, or label ('[a-zA-Z_]\w*', Name) ], 'comment-parse-single': [ include('natspec'), (r'\n', Comment.Single, '#pop'), (r'[^\n]', Comment.Single), ], 'comment-parse-multi': [ include('natspec'), (r'[^*/]', Comment.Multiline), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ], 'comments': [ (r'//', Comment.Single, 'comment-parse-single'), (r'/[*]', Comment.Multiline, 'comment-parse-multi'), ], 'natspec': [ (r'@(author|dev|notice|param|return|title)\b', Comment.Special), ], 'numbers': [ (r'0[xX][0-9a-fA-F]+', Number.Hex), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?', Number.Float), (r'[0-9]+([eE][0-9]+)?', Number.Integer), ], 'string-parse-common': [ # escapes (r'\\(u[0-9a-fA-F]{4}|x..|[^x])', String.Escape), # almost everything else is plain characters (r'[^\\"\'\n]+', String), # line continuation (r'\\\n', String), # stray backslash (r'\\', String) ], 'string-parse-double': [(r'"', String, '#pop'), (r"'", String)], 'string-parse-single': [(r"'", String, '#pop'), (r'"', String)], 'strings': [ # hexadecimal string literals (r"hex'[0-9a-fA-F]+'", String), (r'hex"[0-9a-fA-F]+"', String), # usual strings (r'"', String, combined('string-parse-common', 'string-parse-double')), (r"'", String, combined('string-parse-common', 'string-parse-single')) ], 'whitespace': [(r'\s+', Text)], } # tokens
class JuliaLexer(RegexLexer): """ For `Julia <http://julialang.org/>`_ source code. .. versionadded:: 1.6 """ name = 'Julia' aliases = ['julia', 'jl'] filenames = ['*.jl'] mimetypes = ['text/x-julia', 'application/x-julia'] builtins = [ 'exit', 'whos', 'edit', 'load', 'is', 'isa', 'isequal', 'typeof', 'tuple', 'ntuple', 'uid', 'hash', 'finalizer', 'convert', 'promote', 'subtype', 'typemin', 'typemax', 'realmin', 'realmax', 'sizeof', 'eps', 'promote_type', 'method_exists', 'applicable', 'invoke', 'dlopen', 'dlsym', 'system', 'error', 'throw', 'assert', 'new', 'Inf', 'Nan', 'pi', 'im', ] tokens = { 'root': [ (r'\n', Text), (r'[^\S\n]+', Text), (r'#=', Comment.Multiline, "blockcomment"), (r'#.*$', Comment), (r'[]{}:(),;[@]', Punctuation), (r'\\\n', Text), (r'\\', Text), # keywords (r'(begin|while|for|in|return|break|continue|' r'macro|quote|let|if|elseif|else|try|catch|end|' r'bitstype|ccall|do|using|module|import|export|' r'importall|baremodule|immutable)\b', Keyword), (r'(local|global|const)\b', Keyword.Declaration), (r'(Bool|Int|Int8|Int16|Int32|Int64|Uint|Uint8|Uint16|Uint32|Uint64' r'|Float32|Float64|Complex64|Complex128|Any|Nothing|None)\b', Keyword.Type), # functions (r'(function)((?:\s|\\\s)+)', bygroups(Keyword, Name.Function), 'funcname'), # types (r'(type|typealias|abstract)((?:\s|\\\s)+)', bygroups(Keyword, Name.Class), 'typename'), # operators (r'==|!=|<=|>=|->|&&|\|\||::|<:|[-~+/*%=<>&^|.?!$]', Operator), (r'\.\*|\.\^|\.\\|\.\/|\\', Operator), # builtins ('(' + '|'.join(builtins) + r')\b', Name.Builtin), # backticks (r'`(?s).*?`', String.Backtick), # chars (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|" r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char), # try to match trailing transpose (r'(?<=[.\w)\]])\'+', Operator), # strings (r'(?:[IL])"', String, 'string'), (r'[E]?"', String, combined('stringescape', 'string')), # names (r'@[\w.]+', Name.Decorator), (r'[a-zA-Z_]\w*', Name), # numbers (r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float), (r'(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?', Number.Float), (r'\d+(_\d+)+[eEf][+-]?[0-9]+', Number.Float), (r'\d+[eEf][+-]?[0-9]+', Number.Float), (r'0b[01]+(_[01]+)+', Number.Bin), (r'0b[01]+', Number.Bin), (r'0o[0-7]+(_[0-7]+)+', Number.Oct), (r'0o[0-7]+', Number.Oct), (r'0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+', Number.Hex), (r'0x[a-fA-F0-9]+', Number.Hex), (r'\d+(_\d+)+', Number.Integer), (r'\d+', Number.Integer) ], 'funcname': [ ('[a-zA-Z_]\w*', Name.Function, '#pop'), ('\([^\s\w{]{1,2}\)', Operator, '#pop'), ('[^\s\w{]{1,2}', Operator, '#pop'), ], 'typename': [ ('[a-zA-Z_]\w*', Name.Class, '#pop') ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) ], "blockcomment": [ (r'[^=#]', Comment.Multiline), (r'#=', Comment.Multiline, '#push'), (r'=#', Comment.Multiline, '#pop'), (r'[=#]', Comment.Multiline), ], 'string': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings (r'\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?', String.Interpol), (r'[^\\"$]+', String), # quotes, dollar signs, and backslashes must be parsed one at a time (r'["\\]', String), # unhandled string formatting sign (r'\$', String) ], } def analyse_text(text): return shebang_matches(text, r'julia')
class CythonLexer(RegexLexer): """ For Pyrex and `Cython <http://cython.org>`_ source code. .. versionadded:: 1.1 """ name = 'Cython' aliases = ['cython', 'pyx', 'pyrex'] filenames = ['*.pyx', '*.pxd', '*.pxi'] mimetypes = ['text/x-cython', 'application/x-cython'] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)), (r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)), (r'[^\S\n]+', Text), (r'#.*$', Comment), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'(<)([a-zA-Z0-9.?]+)(>)', bygroups(Punctuation, Keyword.Type, Punctuation)), (r'!=|==|<<|>>|[-~+/*%=<>&^|.?]', Operator), (r'(from)(\d+)(<=)(\s+)(<)(\d+)(:)', bygroups(Keyword, Number.Integer, Operator, Name, Operator, Name, Punctuation)), include('keywords'), (r'(def|property)(\s+)', bygroups(Keyword, Text), 'funcname'), (r'(cp?def)(\s+)', bygroups(Keyword, Text), 'cdef'), # (should actually start a block with only cdefs) (r'(cdef)(:)', bygroups(Keyword, Punctuation)), (r'(class|struct)(\s+)', bygroups(Keyword, Text), 'classname'), (r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'), (r'(c?import)(\s+)', bygroups(Keyword, Text), 'import'), include('builtins'), include('backtick'), ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), ('[uU]?"""', String, combined('stringescape', 'tdqs')), ("[uU]?'''", String, combined('stringescape', 'tsqs')), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(('assert', 'break', 'by', 'continue', 'ctypedef', 'del', 'elif', 'else', 'except', 'except?', 'exec', 'finally', 'for', 'fused', 'gil', 'global', 'if', 'include', 'lambda', 'nogil', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'as', 'with'), suffix=r'\b'), Keyword), (r'(DEF|IF|ELIF|ELSE)\b', Comment.Preproc), ], 'builtins': [ (words( ('__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'unsigned', 'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL' r')\b', Name.Builtin.Pseudo), (words( ('ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Exception), ], 'numbers': [(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer)], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@\w+', Name.Decorator), (r'[a-zA-Z_]\w*', Name), ], 'funcname': [(r'[a-zA-Z_]\w*', Name.Function, '#pop')], 'cdef': [ (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved), (r'(struct|enum|union|class)\b', Keyword), (r'([a-zA-Z_]\w*)(\s*)(?=[(:#=]|$)', bygroups(Name.Function, Text), '#pop'), (r'([a-zA-Z_]\w*)(\s*)(,)', bygroups(Name.Function, Text, Punctuation)), (r'from\b', Keyword, '#pop'), (r'as\b', Keyword), (r':', Punctuation, '#pop'), (r'(?=["\'])', Text, '#pop'), (r'[a-zA-Z_]\w*', Keyword.Type), (r'.', Text), ], 'classname': [(r'[a-zA-Z_]\w*', Name.Class, '#pop')], 'import': [ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), (r'[a-zA-Z_][\w.]*', Name.Namespace), (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), default('#pop') # all else: go back ], 'fromimport': [ (r'(\s+)(c?import)\b', bygroups(Text, Keyword), '#pop'), (r'[a-zA-Z_.][\w.]*', Name.Namespace), # ``cdef foo from "header"``, or ``for foo from 0 < i < 10`` default('#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings': [ (r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsux%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [(r'\n', String)], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings include('strings') ], 'tdqs': [(r'"""', String, '#pop'), include('strings'), include('nl')], 'tsqs': [(r"'''", String, '#pop'), include('strings'), include('nl')], }
class PythonLexer(RegexLexer): """ For `Python <http://www.python.org>`_ source code (version 3.x). .. versionadded:: 0.10 .. versionchanged:: 2.5 This is now the default ``PythonLexer``. It is still available as the alias ``Python3Lexer``. """ name = 'Python' aliases = ['python', 'py', 'sage', 'python3', 'py3'] filenames = [ '*.py', '*.pyw', # Jython '*.jy', # Sage '*.sage', # SCons '*.sc', 'SConstruct', 'SConscript', # Skylark/Starlark (used by Bazel, Buck, and Pants) '*.bzl', 'BUCK', 'BUILD', 'BUILD.bazel', 'WORKSPACE', # Twisted Application infrastructure '*.tac', ] mimetypes = [ 'text/x-python', 'application/x-python', 'text/x-python3', 'application/x-python3' ] flags = re.MULTILINE | re.UNICODE uni_name = "[%s][%s]*" % (uni.xid_start, uni.xid_continue) def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (still valid in Py3) (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsaux%]', String.Interpol), # the new style '{}'.format(...) string formatting ( r'\{' r'((\w+)((\.\w+)|(\[[^\]]+\]))*)?' # field name r'(\![sra])?' # conversion r'(\:(.?[<>=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?' r'\}', String.Interpol), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%{\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r'%|(\{{1,2})', ttype) # newlines are an error (use "nl" state) ] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc)), (r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc)), (r'[^\S\n]+', Text), (r'\A#!.+$', Comment.Hashbang), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('magicfuncs'), include('magicvars'), # raw strings ('(?i)(rb|br|fr|rf|r)(""")', bygroups(String.Affix, String.Double), 'tdqs'), ("(?i)(rb|br|fr|rf|r)(''')", bygroups(String.Affix, String.Single), 'tsqs'), ('(?i)(rb|br|fr|rf|r)(")', bygroups(String.Affix, String.Double), 'dqs'), ("(?i)(rb|br|fr|rf|r)(')", bygroups(String.Affix, String.Single), 'sqs'), # non-raw strings ('([uUbBfF]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ("([uUbBfF]?)(''')", bygroups(String.Affix, String.Single), combined('stringescape', 'tsqs')), ('([uUbBfF]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), ("([uUbBfF]?)(')", bygroups(String.Affix, String.Single), combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(('assert', 'async', 'await', 'break', 'continue', 'del', 'elif', 'else', 'except', 'finally', 'for', 'global', 'if', 'lambda', 'pass', 'raise', 'nonlocal', 'return', 'try', 'while', 'yield', 'yield from', 'as', 'with'), suffix=r'\b'), Keyword), (words(('True', 'False', 'None'), suffix=r'\b'), Keyword.Constant), ], 'builtins': [ (words( ('__import__', 'abs', 'all', 'any', 'bin', 'bool', 'bytearray', 'bytes', 'chr', 'classmethod', 'cmp', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)(self|Ellipsis|NotImplemented|cls)\b', Name.Builtin.Pseudo), ( words( ( 'ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning', 'WindowsError', 'ZeroDivisionError', # new builtin exceptions from PEP 3151 'BlockingIOError', 'ChildProcessError', 'ConnectionError', 'BrokenPipeError', 'ConnectionAbortedError', 'ConnectionRefusedError', 'ConnectionResetError', 'FileExistsError', 'FileNotFoundError', 'InterruptedError', 'IsADirectoryError', 'NotADirectoryError', 'PermissionError', 'ProcessLookupError', 'TimeoutError', # others new in Python 3 'StopAsyncIteration'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Exception), ], 'magicfuncs': [ (words( ('__abs__', '__add__', '__aenter__', '__aexit__', '__aiter__', '__and__', '__anext__', '__await__', '__bool__', '__bytes__', '__call__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__dir__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floordiv__', '__format__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imatmul__', '__imod__', '__imul__', '__index__', '__init__', '__instancecheck__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__length_hint__', '__lshift__', '__lt__', '__matmul__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__next__', '__or__', '__pos__', '__pow__', '__prepare__', '__radd__', '__rand__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmatmul__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__setattr__', '__setitem__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__xor__'), suffix=r'\b'), Name.Function.Magic), ], 'magicvars': [ (words(('__annotations__', '__bases__', '__class__', '__closure__', '__code__', '__defaults__', '__dict__', '__doc__', '__file__', '__func__', '__globals__', '__kwdefaults__', '__module__', '__mro__', '__name__', '__objclass__', '__qualname__', '__self__', '__slots__', '__weakref__'), suffix=r'\b'), Name.Variable.Magic), ], 'numbers': [ (r'(\d(?:_?\d)*\.(?:\d(?:_?\d)*)?|(?:\d(?:_?\d)*)?\.\d(?:_?\d)*)' r'([eE][+-]?\d(?:_?\d)*)?', Number.Float), (r'\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*j?', Number.Float), (r'0[oO](?:_?[0-7])+', Number.Oct), (r'0[bB](?:_?[01])+', Number.Bin), (r'0[xX](?:_?[a-fA-F0-9])+', Number.Hex), (r'\d(?:_?\d)*', Number.Integer), ], 'name': [ (r'@' + uni_name, Name.Decorator), (r'@', Operator), # new matrix multiplication operator (uni_name, Name), ], 'funcname': [ include('magicfuncs'), (uni_name, Name.Function, '#pop'), default('#pop'), ], 'classname': [ (uni_name, Name.Class, '#pop'), ], 'import': [ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), (r'\.', Name.Namespace), (uni_name, Name.Namespace), (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), default('#pop') # all else: go back ], 'fromimport': [ (r'(\s+)(import)\b', bygroups(Text, Keyword.Namespace), '#pop'), (r'\.', Name.Namespace), # if None occurs here, it's "raise x from None", since None can # never be a module name (r'None\b', Name.Builtin.Pseudo, '#pop'), (uni_name, Name.Namespace), default('#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings-single': innerstring_rules(String.Single), 'strings-double': innerstring_rules(String.Double), 'dqs': [ (r'"', String.Double, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings-double') ], 'sqs': [ (r"'", String.Single, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings-single') ], 'tdqs': [(r'"""', String.Double, '#pop'), include('strings-double'), (r'\n', String.Double)], 'tsqs': [(r"'''", String.Single, '#pop'), include('strings-single'), (r'\n', String.Single)], } def analyse_text(text): return shebang_matches(text, r'pythonw?(3(\.\d)?)?')
class QVToLexer(RegexLexer): """ For the `QVT Operational Mapping language <http://www.omg.org/spec/QVT/1.1/>`_. Reference for implementing this: «Meta Object Facility (MOF) 2.0 Query/View/Transformation Specification», Version 1.1 - January 2011 (http://www.omg.org/spec/QVT/1.1/), see §8.4, «Concrete Syntax» in particular. Notable tokens assignments: - Name.Class is assigned to the identifier following any of the following keywords: metamodel, class, exception, primitive, enum, transformation or library - Name.Function is assigned to the names of mappings and queries - Name.Builtin.Pseudo is assigned to the pre-defined variables 'this', 'self' and 'result'. """ # With obvious borrowings & inspiration from the Java, Python and C lexers name = 'QVTO' aliases = ['qvto', 'qvt'] filenames = ['*.qvto'] tokens = { 'root': [ (r'\n', Text), (r'[^\S\n]+', Text), (r'(--|//)(\s*)(directive:)?(.*)$', bygroups(Comment, Comment, Comment.Preproc, Comment)), # Uncomment the following if you want to distinguish between # '/*' and '/**', à la javadoc # (r'/[*]{2}(.|\n)*?[*]/', Comment.Multiline), (r'/[*](.|\n)*?[*]/', Comment.Multiline), (r'\\\n', Text), (r'(and|not|or|xor|##?)\b', Operator.Word), (r'(:{1,2}=|[-+]=)\b', Operator.Word), (r'(@|<<|>>)\b', Keyword), # stereotypes (r'!=|<>|==|=|!->|->|>=|<=|[.]{3}|[+/*%=<>&|.~]', Operator), (r'[]{}:(),;[]', Punctuation), (r'(true|false|unlimited|null)\b', Keyword.Constant), (r'(this|self|result)\b', Name.Builtin.Pseudo), (r'(var)\b', Keyword.Declaration), (r'(from|import)\b', Keyword.Namespace, 'fromimport'), (r'(metamodel|class|exception|primitive|enum|transformation|' r'library)(\s+)(\w+)', bygroups(Keyword.Word, Text, Name.Class)), (r'(exception)(\s+)(\w+)', bygroups(Keyword.Word, Text, Name.Exception)), (r'(main)\b', Name.Function), (r'(mapping|helper|query)(\s+)', bygroups(Keyword.Declaration, Text), 'operation'), (r'(assert)(\s+)\b', bygroups(Keyword, Text), 'assert'), (r'(Bag|Collection|Dict|OrderedSet|Sequence|Set|Tuple|List)\b', Keyword.Type), include('keywords'), ('"', String, combined('stringescape', 'dqs')), ("'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), # (r'([a-zA-Z_]\w*)(::)([a-zA-Z_]\w*)', # bygroups(Text, Text, Text)), ], 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'[a-zA-Z_][\w.]*', Name.Namespace), default('#pop'), ], 'operation': [(r'::', Text), (r'(.*::)([a-zA-Z_]\w*)([ \t]*)(\()', bygroups(Text, Name.Function, Text, Punctuation), '#pop')], 'assert': [ (r'(warning|error|fatal)\b', Keyword, '#pop'), default('#pop'), # all else: go back ], 'keywords': [ (words( ('abstract', 'access', 'any', 'assert', 'blackbox', 'break', 'case', 'collect', 'collectNested', 'collectOne', 'collectselect', 'collectselectOne', 'composes', 'compute', 'configuration', 'constructor', 'continue', 'datatype', 'default', 'derived', 'disjuncts', 'do', 'elif', 'else', 'end', 'endif', 'except', 'exists', 'extends', 'forAll', 'forEach', 'forOne', 'from', 'if', 'implies', 'in', 'inherits', 'init', 'inout', 'intermediate', 'invresolve', 'invresolveIn', 'invresolveone', 'invresolveoneIn', 'isUnique', 'iterate', 'late', 'let', 'literal', 'log', 'map', 'merges', 'modeltype', 'new', 'object', 'one', 'ordered', 'out', 'package', 'population', 'property', 'raise', 'readonly', 'references', 'refines', 'reject', 'resolve', 'resolveIn', 'resolveone', 'resolveoneIn', 'return', 'select', 'selectOne', 'sortedBy', 'static', 'switch', 'tag', 'then', 'try', 'typedef', 'unlimited', 'uses', 'when', 'where', 'while', 'with', 'xcollect', 'xmap', 'xselect'), suffix=r'\b'), Keyword), ], # There is no need to distinguish between String.Single and # String.Double: 'strings' is factorised for 'dqs' and 'sqs' 'strings': [ (r'[^\\\'"\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), ], 'stringescape': [(r'\\([\\btnfr"\']|u[0-3][0-7]{2}|u[0-7]{1,2})', String.Escape)], 'dqs': [ # double-quoted string (r'"', String, '#pop'), (r'\\\\|\\"', String.Escape), include('strings') ], 'sqs': [ # single-quoted string (r"'", String, '#pop'), (r"\\\\|\\'", String.Escape), include('strings') ], 'name': [ ('[a-zA-Z_]\w*', Name), ], # numbers: excerpt taken from the python lexer 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'\d+[eE][+-]?[0-9]+', Number.Float), (r'\d+', Number.Integer)], }
class AutohotkeyLexer(RegexLexer): """ For `autohotkey <http://www.autohotkey.com/>`_ source code. .. versionadded:: 1.4 """ name = 'autohotkey' aliases = ['ahk', 'autohotkey'] filenames = ['*.ahk', '*.ahkl'] mimetypes = ['text/x-autohotkey'] tokens = { 'root': [ (r'^(\s*)(/\*)', bygroups(Text, Comment.Multiline), 'incomment'), (r'^(\s*)(\()', bygroups(Text, Generic), 'incontinuation'), (r'\s+;.*?$', Comment.Singleline), (r'^;.*?$', Comment.Singleline), (r'[]{}(),;[]', Punctuation), (r'(in|is|and|or|not)\b', Operator.Word), (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable), (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), include('commands'), include('labels'), include('builtInFunctions'), include('builtInVariables'), (r'"', String, combined('stringescape', 'dqs')), include('numbers'), (r'[a-zA-Z_#@$][\w#@$]*', Name), (r'\\|\'', Text), (r'\`([,%`abfnrtv\-+;])', String.Escape), include('garbage'), ], 'incomment': [(r'^\s*\*/', Comment.Multiline, '#pop'), (r'[^*/]', Comment.Multiline), (r'[*/]', Comment.Multiline)], 'incontinuation': [ (r'^\s*\)', Generic, '#pop'), (r'[^)]', Generic), (r'[)]', Generic), ], 'commands': [ (r'(?i)^(\s*)(global|local|static|' r'#AllowSameLineComments|#ClipboardTimeout|#CommentFlag|' r'#ErrorStdOut|#EscapeChar|#HotkeyInterval|#HotkeyModifierTimeout|' r'#Hotstring|#IfWinActive|#IfWinExist|#IfWinNotActive|' r'#IfWinNotExist|#IncludeAgain|#Include|#InstallKeybdHook|' r'#InstallMouseHook|#KeyHistory|#LTrim|#MaxHotkeysPerInterval|' r'#MaxMem|#MaxThreads|#MaxThreadsBuffer|#MaxThreadsPerHotkey|' r'#NoEnv|#NoTrayIcon|#Persistent|#SingleInstance|#UseHook|' r'#WinActivateForce|AutoTrim|BlockInput|Break|Click|ClipWait|' r'Continue|Control|ControlClick|ControlFocus|ControlGetFocus|' r'ControlGetPos|ControlGetText|ControlGet|ControlMove|ControlSend|' r'ControlSendRaw|ControlSetText|CoordMode|Critical|' r'DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|' r'DriveSpaceFree|Edit|Else|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|' r'EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|' r'FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|' r'FileDelete|FileGetAttrib|FileGetShortcut|FileGetSize|' r'FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|' r'FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|' r'FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|' r'FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|' r'GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|' r'GuiControlGet|Hotkey|IfEqual|IfExist|IfGreaterOrEqual|IfGreater|' r'IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|' r'IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|' r'IfWinNotExist|If |ImageSearch|IniDelete|IniRead|IniWrite|' r'InputBox|Input|KeyHistory|KeyWait|ListHotkeys|ListLines|' r'ListVars|Loop|Menu|MouseClickDrag|MouseClick|MouseGetPos|' r'MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|' r'PixelSearch|PostMessage|Process|Progress|Random|RegDelete|' r'RegRead|RegWrite|Reload|Repeat|Return|RunAs|RunWait|Run|' r'SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|Send|' r'SetBatchLines|SetCapslockState|SetControlDelay|' r'SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|' r'SetMouseDelay|SetNumlockState|SetScrollLockState|' r'SetStoreCapslockMode|SetTimer|SetTitleMatchMode|' r'SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|' r'SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|' r'SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|' r'SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|' r'StringGetPos|StringLeft|StringLen|StringLower|StringMid|' r'StringReplace|StringRight|StringSplit|StringTrimLeft|' r'StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|' r'Transform|TrayTip|URLDownloadToFile|While|WinActivate|' r'WinActivateBottom|WinClose|WinGetActiveStats|WinGetActiveTitle|' r'WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinGet|WinHide|' r'WinKill|WinMaximize|WinMenuSelectItem|WinMinimizeAllUndo|' r'WinMinimizeAll|WinMinimize|WinMove|WinRestore|WinSetTitle|' r'WinSet|WinShow|WinWaitActive|WinWaitClose|WinWaitNotActive|' r'WinWait)\b', bygroups(Text, Name.Builtin)), ], 'builtInFunctions': [ (r'(?i)(Abs|ACos|Asc|ASin|ATan|Ceil|Chr|Cos|DllCall|Exp|FileExist|' r'Floor|GetKeyState|IL_Add|IL_Create|IL_Destroy|InStr|IsFunc|' r'IsLabel|Ln|Log|LV_Add|LV_Delete|LV_DeleteCol|LV_GetCount|' r'LV_GetNext|LV_GetText|LV_Insert|LV_InsertCol|LV_Modify|' r'LV_ModifyCol|LV_SetImageList|Mod|NumGet|NumPut|OnMessage|' r'RegExMatch|RegExReplace|RegisterCallback|Round|SB_SetIcon|' r'SB_SetParts|SB_SetText|Sin|Sqrt|StrLen|SubStr|Tan|TV_Add|' r'TV_Delete|TV_GetChild|TV_GetCount|TV_GetNext|TV_Get|' r'TV_GetParent|TV_GetPrev|TV_GetSelection|TV_GetText|TV_Modify|' r'VarSetCapacity|WinActive|WinExist|Object|ComObjActive|' r'ComObjArray|ComObjEnwrap|ComObjUnwrap|ComObjParameter|' r'ComObjType|ComObjConnect|ComObjCreate|ComObjGet|ComObjError|' r'ComObjValue|Insert|MinIndex|MaxIndex|Remove|SetCapacity|' r'GetCapacity|GetAddress|_NewEnum|FileOpen|Read|Write|ReadLine|' r'WriteLine|ReadNumType|WriteNumType|RawRead|RawWrite|Seek|Tell|' r'Close|Next|IsObject|StrPut|StrGet|Trim|LTrim|RTrim)\b', Name.Function), ], 'builtInVariables': [ (r'(?i)(A_AhkPath|A_AhkVersion|A_AppData|A_AppDataCommon|' r'A_AutoTrim|A_BatchLines|A_CaretX|A_CaretY|A_ComputerName|' r'A_ControlDelay|A_Cursor|A_DDDD|A_DDD|A_DD|A_DefaultMouseSpeed|' r'A_Desktop|A_DesktopCommon|A_DetectHiddenText|' r'A_DetectHiddenWindows|A_EndChar|A_EventInfo|A_ExitReason|' r'A_FormatFloat|A_FormatInteger|A_Gui|A_GuiEvent|A_GuiControl|' r'A_GuiControlEvent|A_GuiHeight|A_GuiWidth|A_GuiX|A_GuiY|A_Hour|' r'A_IconFile|A_IconHidden|A_IconNumber|A_IconTip|A_Index|' r'A_IPAddress1|A_IPAddress2|A_IPAddress3|A_IPAddress4|A_ISAdmin|' r'A_IsCompiled|A_IsCritical|A_IsPaused|A_IsSuspended|A_KeyDelay|' r'A_Language|A_LastError|A_LineFile|A_LineNumber|A_LoopField|' r'A_LoopFileAttrib|A_LoopFileDir|A_LoopFileExt|A_LoopFileFullPath|' r'A_LoopFileLongPath|A_LoopFileName|A_LoopFileShortName|' r'A_LoopFileShortPath|A_LoopFileSize|A_LoopFileSizeKB|' r'A_LoopFileSizeMB|A_LoopFileTimeAccessed|A_LoopFileTimeCreated|' r'A_LoopFileTimeModified|A_LoopReadLine|A_LoopRegKey|' r'A_LoopRegName|A_LoopRegSubkey|A_LoopRegTimeModified|' r'A_LoopRegType|A_MDAY|A_Min|A_MM|A_MMM|A_MMMM|A_Mon|A_MouseDelay|' r'A_MSec|A_MyDocuments|A_Now|A_NowUTC|A_NumBatchLines|A_OSType|' r'A_OSVersion|A_PriorHotkey|A_ProgramFiles|A_Programs|' r'A_ProgramsCommon|A_ScreenHeight|A_ScreenWidth|A_ScriptDir|' r'A_ScriptFullPath|A_ScriptName|A_Sec|A_Space|A_StartMenu|' r'A_StartMenuCommon|A_Startup|A_StartupCommon|A_StringCaseSense|' r'A_Tab|A_Temp|A_ThisFunc|A_ThisHotkey|A_ThisLabel|A_ThisMenu|' r'A_ThisMenuItem|A_ThisMenuItemPos|A_TickCount|A_TimeIdle|' r'A_TimeIdlePhysical|A_TimeSincePriorHotkey|A_TimeSinceThisHotkey|' r'A_TitleMatchMode|A_TitleMatchModeSpeed|A_UserName|A_WDay|' r'A_WinDelay|A_WinDir|A_WorkingDir|A_YDay|A_YEAR|A_YWeek|A_YYYY|' r'Clipboard|ClipboardAll|ComSpec|ErrorLevel|ProgramFiles|True|' r'False|A_IsUnicode|A_FileEncoding|A_OSVersion|A_PtrSize)\b', Name.Variable), ], 'labels': [ # hotkeys and labels # technically, hotkey names are limited to named keys and buttons (r'(^\s*)([^:\s("]+?:{1,2})', bygroups(Text, Name.Label)), (r'(^\s*)(::[^:\s]+?::)', bygroups(Text, Name.Label)), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'\d+[eE][+-]?[0-9]+', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer)], 'stringescape': [ (r'\"\"|\`([,%`abfnrtv])', String.Escape), ], 'strings': [ (r'[^"\n]+', String), ], 'dqs': [(r'"', String, '#pop'), include('strings')], 'garbage': [ (r'[^\S\n]', Text), # (r'.', Text), # no cheating ], }
class NESTMLLexer(RegexLexer): """Based on the Pygments PythonLexer""" name = "NESTML" filenames = ['*.nestml'] def innerstring_rules(ttype): return [ # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r'%', ttype), # newlines are an error (use "nl" state) ] tokens = { 'root': [ (r'\n', Text), (r'[^\S\n]+', Text), (r'#.*$', Comment.Single), (r'//.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'!=|[-~+/*%=<>&^|.]', Operator), include('keywords'), include('builtins'), ('([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), 'tdqs'), ('([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), 'dqs'), ('([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ('([uUbB]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), include('name'), include('numbers'), ], 'keywords': [ (words(("recordable", "kernel", "neuron", "state", "parameters", "internals", "update", "equations", "input", "output", "current", "spike", "inhibitory", "excitatory", "end", "function", "return", "if", "elif", "else", "for", "while", "in", "step", "and", "or", "not"), suffix=r'\b'), Keyword), ], 'types': [ (words(( "integer", "real", "string", "boolean", "void", "A", "AA", "Angstrom", "Bq", "C", "Celsius", "Ci", "EA", "EC", "EF", "EH", "EHz", "EJ", "EK", "EL", "EN", "EOhm", "EPa", "ES", "ET", "EV", "EW", "EWb", "Ea", "Earcmin", "Earcsec", "Ecd", "Ed", "Edeg", "EeV", "Eg", "Eh", "El", "Elm", "Elx", "Em", "Emin", "Emol", "Eohm", "Erad", "Es", "Esr", "Eyr", "F", "Farad", "GA", "GC", "GF", "GH", "GHz", "GJ", "GK", "GL", "GN", "GOhm", "GPa", "GS", "GT", "GV", "GW", "GWb", "Ga", "Garcmin", "Garcsec", "Gcd", "Gd", "Gdeg", "GeV", "Gg", "Gh", "Gl", "Glm", "Glx", "Gm", "Gmin", "Gmol", "Gohm", "Grad", "Gs", "Gsr", "Gyr", "H", "Henry", "Hertz", "Hz", "J", "Joule", "K", "Kelvin", "L", "MA", "MC", "MF", "MH", "MHz", "MJ", "MK", "ML", "MN", "MOhm", "MPa", "MS", "MT", "MV", "MW", "MWb", "Ma", "Marcmin", "Marcsec", "Mcd", "Md", "Mdeg", "MeV", "Mg", "Mh", "Ml", "Mlm", "Mlx", "Mm", "Mmin", "Mmol", "Mohm", "Mrad", "Ms", "Msr", "Myr", "N", "Newton", "Ohm", "PA", "PC", "PF", "PH", "PHz", "PJ", "PK", "PL", "PN", "POhm", "PPa", "PS", "PT", "PV", "PW", "PWb", "Pa", "Parcmin", "Parcsec", "Pascal", "Pcd", "Pd", "Pdeg", "PeV", "Pg", "Ph", "Pl", "Plm", "Plx", "Pm", "Pmin", "Pmol", "Pohm", "Prad", "Ps", "Psr", "Pyr", "S", "Siemens", "T", "TA", "TC", "TF", "TH", "THz", "TJ", "TK", "TL", "TN", "TOhm", "TPa", "TS", "TT", "TV", "TW", "TWb", "Ta", "Tarcmin", "Tarcsec", "Tcd", "Td", "Tdeg", "TeV", "Tesla", "Tg", "Th", "Tl", "Tlm", "Tlx", "Tm", "Tmin", "Tmol", "Tohm", "Trad", "Ts", "Tsr", "Tyr", "V", "Volt", "W", "Watt", "Wb", "Weber", "YA", "YC", "YF", "YH", "YHz", "YJ", "YK", "YL", "YN", "YOhm", "YPa", "YS", "YT", "YV", "YW", "YWb", "Ya", "Yarcmin", "Yarcsec", "Ycd", "Yd", "Ydeg", "YeV", "Yg", "Yh", "Yl", "Ylm", "Ylx", "Ym", "Ymin", "Ymol", "Yohm", "Yrad", "Ys", "Ysr", "Yyr", "ZA", "ZC", "ZF", "ZH", "ZHz", "ZJ", "ZK", "ZL", "ZN", "ZOhm", "ZPa", "ZS", "ZT", "ZV", "ZW", "ZWb", "Za", "Zarcmin", "Zarcsec", "Zcd", "Zd", "Zdeg", "ZeV", "Zg", "Zh", "Zl", "Zlm", "Zlx", "Zm", "Zmin", "Zmol", "Zohm", "Zrad", "Zs", "Zsr", "Zyr", "a", "aA", "aC", "aF", "aH", "aHz", "aJ", "aK", "aL", "aN", "aOhm", "aPa", "aS", "aT", "aV", "aW", "aWb", "aa", "aarcmin", "aarcsec", "acd", "ad", "adeg", "aeV", "ag", "ah", "al", "alm", "alx", "am", "amin", "amol", "amp", "ampere", "angstrom", "annum", "aohm", "arad", "arcmin", "arcminute", "arcsec", "arcsecond", "asr", "attoFarad", "attoHenry", "attoHertz", "attoJoule", "attoKelvin", "attoNewton", "attoOhm", "attoPascal", "attoSiemens", "attoTesla", "attoVolt", "attoWatt", "attoWeber", "attoamp", "attoampere", "attoannum", "attoarcminute", "attoarcsecond", "attocandela", "attocoulomb", "attoday", "attodegree", "attoelectronvolt", "attofarad", "attogram", "attohenry", "attohertz", "attohour", "attohr", "attojoule", "attoliter", "attolumen", "attolux", "attometer", "attominute", "attomole", "attonewton", "attopascal", "attoradian", "attosecond", "attosiemens", "attosteradian", "attotesla", "attovolt", "attowatt", "attoweber", "attoyear", "ayr", "bar", "bases", "becquerel", "cA", "cC", "cF", "cH", "cHz", "cJ", "cK", "cL", "cN", "cOhm", "cPa", "cS", "cT", "cV", "cW", "cWb", "ca", "candela", "carcmin", "carcsec", "ccd", "cd", "cdeg", "ceV", "centiFarad", "centiHenry", "centiHertz", "centiJoule", "centiKelvin", "centiNewton", "centiOhm", "centiPascal", "centiSiemens", "centiTesla", "centiVolt", "centiWatt", "centiWeber", "centiamp", "centiampere", "centiannum", "centiarcminute", "centiarcsecond", "centicandela", "centicoulomb", "centiday", "centidegree", "centielectronvolt", "centifarad", "centigram", "centihenry", "centihertz", "centihour", "centihr", "centijoule", "centiliter", "centilumen", "centilux", "centimeter", "centiminute", "centimole", "centinewton", "centipascal", "centiradian", "centisecond", "centisiemens", "centisteradian", "centitesla", "centivolt", "centiwatt", "centiweber", "centiyear", "cg", "ch", "cl", "clm", "clx", "cm", "cmin", "cmol", "cohm", "coulomb", "crad", "cs", "csr", "curie", "cyr", "d", "dA", "dC", "dF", "dH", "dHz", "dJ", "dK", "dL", "dN", "dOhm", "dPa", "dS", "dT", "dV", "dW", "dWb", "da", "daA", "daC", "daF", "daH", "daHz", "daJ", "daK", "daL", "daN", "daOhm", "daPa", "daS", "daT", "daV", "daW", "daWb", "daa", "daarcmin", "daarcsec", "dacd", "dad", "dadeg", "daeV", "dag", "dah", "dal", "dalm", "dalx", "dam", "damin", "damol", "daohm", "darad", "darcmin", "darcsec", "das", "dasr", "day", "dayr", "dcd", "dd", "ddeg", "deV", "decaFarad", "decaHenry", "decaHertz", "decaJoule", "decaKelvin", "decaNewton", "decaOhm", "decaPascal", "decaSiemens", "decaTesla", "decaVolt", "decaWatt", "decaWeber", "decaamp", "decaampere", "decaannum", "decaarcminute", "decaarcsecond", "decacandela", "decacoulomb", "decaday", "decadegree", "decaelectronvolt", "decafarad", "decagram", "decahenry", "decahertz", "decahour", "decahr", "decajoule", "decaliter", "decalumen", "decalux", "decameter", "decaminute", "decamole", "decanewton", "decapascal", "decaradian", "decasecond", "decasiemens", "decasteradian", "decatesla", "decavolt", "decawatt", "decaweber", "decayear", "deciFarad", "deciHenry", "deciHertz", "deciJoule", "deciKelvin", "deciNewton", "deciOhm", "deciPascal", "deciSiemens", "deciTesla", "deciVolt", "deciWatt", "deciWeber", "deciamp", "deciampere", "deciannum", "deciarcminute", "deciarcsecond", "decicandela", "decicoulomb", "deciday", "decidegree", "decielectronvolt", "decifarad", "decigram", "decihenry", "decihertz", "decihour", "decihr", "decijoule", "deciliter", "decilumen", "decilux", "decimeter", "deciminute", "decimole", "decinewton", "decipascal", "deciradian", "decisecond", "decisiemens", "decisteradian", "decitesla", "decivolt", "deciwatt", "deciweber", "deciyear", "deg", "deg_C", "degree", "dekaFarad", "dekaHenry", "dekaHertz", "dekaJoule", "dekaKelvin", "dekaNewton", "dekaOhm", "dekaPascal", "dekaSiemens", "dekaTesla", "dekaVolt", "dekaWatt", "dekaWeber", "dekaamp", "dekaampere", "dekaannum", "dekaarcminute", "dekaarcsecond", "dekacandela", "dekacoulomb", "dekaday", "dekadegree", "dekaelectronvolt", "dekafarad", "dekagram", "dekahenry", "dekahertz", "dekahour", "dekahr", "dekajoule", "dekaliter", "dekalumen", "dekalux", "dekameter", "dekaminute", "dekamole", "dekanewton", "dekapascal", "dekaradian", "dekasecond", "dekasiemens", "dekasteradian", "dekatesla", "dekavolt", "dekawatt", "dekaweber", "dekayear", "dg", "dh", "division", "dl", "dlm", "dlx", "dm", "dmin", "dmol", "dohm", "drad", "ds", "dsr", "dyr", "eV", "electronvolt", "exaFarad", "exaHenry", "exaHertz", "exaJoule", "exaKelvin", "exaNewton", "exaOhm", "exaPascal", "exaSiemens", "exaTesla", "exaVolt", "exaWatt", "exaWeber", "exaamp", "exaampere", "exaannum", "exaarcminute", "exaarcsecond", "exacandela", "exacoulomb", "exaday", "exadegree", "exaelectronvolt", "exafarad", "exagram", "exahenry", "exahertz", "exahour", "exahr", "exajoule", "exaliter", "exalumen", "exalux", "exameter", "examinute", "examole", "exanewton", "exapascal", "exaradian", "exasecond", "exasiemens", "exasteradian", "exatesla", "exavolt", "exawatt", "exaweber", "exayear", "fA", "fC", "fF", "fH", "fHz", "fJ", "fK", "fL", "fN", "fOhm", "fPa", "fS", "fT", "fV", "fW", "fWb", "fa", "farad", "farcmin", "farcsec", "fcd", "fd", "fdeg", "feV", "femtoFarad", "femtoHenry", "femtoHertz", "femtoJoule", "femtoKelvin", "femtoNewton", "femtoOhm", "femtoPascal", "femtoSiemens", "femtoTesla", "femtoVolt", "femtoWatt", "femtoWeber", "femtoamp", "femtoampere", "femtoannum", "femtoarcminute", "femtoarcsecond", "femtocandela", "femtocoulomb", "femtoday", "femtodegree", "femtoelectronvolt", "femtofarad", "femtogram", "femtohenry", "femtohertz", "femtohour", "femtohr", "femtojoule", "femtoliter", "femtolumen", "femtolux", "femtometer", "femtominute", "femtomole", "femtonewton", "femtopascal", "femtoradian", "femtosecond", "femtosiemens", "femtosteradian", "femtotesla", "femtovolt", "femtowatt", "femtoweber", "femtoyear", "fg", "fh", "fl", "flm", "flx", "fm", "fmin", "fmol", "fohm", "fortnight", "frad", "fs", "fsr", "fyr", "g", "gigaFarad", "gigaHenry", "gigaHertz", "gigaJoule", "gigaKelvin", "gigaNewton", "gigaOhm", "gigaPascal", "gigaSiemens", "gigaTesla", "gigaVolt", "gigaWatt", "gigaWeber", "gigaamp", "gigaampere", "gigaannum", "gigaarcminute", "gigaarcsecond", "gigacandela", "gigacoulomb", "gigaday", "gigadegree", "gigaelectronvolt", "gigafarad", "gigagram", "gigahenry", "gigahertz", "gigahour", "gigahr", "gigajoule", "gigaliter", "gigalumen", "gigalux", "gigameter", "gigaminute", "gigamole", "giganewton", "gigapascal", "gigaradian", "gigasecond", "gigasiemens", "gigasteradian", "gigatesla", "gigavolt", "gigawatt", "gigaweber", "gigayear", "gram", "h", "hA", "hC", "hF", "hH", "hHz", "hJ", "hK", "hL", "hN", "hOhm", "hPa", "hS", "hT", "hV", "hW", "hWb", "ha", "harcmin", "harcsec", "hcd", "hd", "hdeg", "heV", "hectoFarad", "hectoHenry", "hectoHertz", "hectoJoule", "hectoKelvin", "hectoNewton", "hectoOhm", "hectoPascal", "hectoSiemens", "hectoTesla", "hectoVolt", "hectoWatt", "hectoWeber", "hectoamp", "hectoampere", "hectoannum", "hectoarcminute", "hectoarcsecond", "hectocandela", "hectocoulomb", "hectoday", "hectodegree", "hectoelectronvolt", "hectofarad", "hectogram", "hectohenry", "hectohertz", "hectohour", "hectohr", "hectojoule", "hectoliter", "hectolumen", "hectolux", "hectometer", "hectominute", "hectomole", "hectonewton", "hectopascal", "hectoradian", "hectosecond", "hectosiemens", "hectosteradian", "hectotesla", "hectovolt", "hectowatt", "hectoweber", "hectoyear", "henry", "hertz", "hg", "hh", "hl", "hlm", "hlx", "hm", "hmin", "hmol", "hohm", "hour", "hourangle", "hr", "hrad", "hs", "hsr", "hyr", "joule", "kA", "kC", "kF", "kH", "kHz", "kJ", "kK", "kL", "kN", "kOhm", "kPa", "kS", "kT", "kV", "kW", "kWb", "ka", "karcmin", "karcsec", "kcd", "kd", "kdeg", "keV", "kg", "kh", "kiloFarad", "kiloHenry", "kiloHertz", "kiloJoule", "kiloKelvin", "kiloNewton", "kiloOhm", "kiloPascal", "kiloSiemens", "kiloTesla", "kiloVolt", "kiloWatt", "kiloWeber", "kiloamp", "kiloampere", "kiloannum", "kiloarcminute", "kiloarcsecond", "kilocandela", "kilocoulomb", "kiloday", "kilodegree", "kiloelectronvolt", "kilofarad", "kilogram", "kilohenry", "kilohertz", "kilohour", "kilohr", "kilojoule", "kiloliter", "kilolumen", "kilolux", "kilometer", "kilominute", "kilomole", "kilonewton", "kilopascal", "kiloradian", "kilosecond", "kilosiemens", "kilosteradian", "kilotesla", "kilovolt", "kilowatt", "kiloweber", "kiloyear", "kl", "klm", "klx", "km", "kmin", "kmol", "kohm", "krad", "ks", "ksr", "kyr", "l", "liter", "lm", "lumen", "lux", "lx", "m", "mA", "mC", "mF", "mH", "mHz", "mJ", "mK", "mL", "mN", "mOhm", "mPa", "mS", "mT", "mV", "mW", "mWb", "ma", "marcmin", "marcsec", "mas", "mcd", "md", "mdeg", "meV", "megaFarad", "megaHenry", "megaHertz", "megaJoule", "megaKelvin", "megaNewton", "megaOhm", "megaPascal", "megaSiemens", "megaTesla", "megaVolt", "megaWatt", "megaWeber", "megaamp", "megaampere", "megaannum", "megaarcminute", "megaarcsecond", "megacandela", "megacoulomb", "megaday", "megadegree", "megaelectronvolt", "megafarad", "megagram", "megahenry", "megahertz", "megahour", "megahr", "megajoule", "megaliter", "megalumen", "megalux", "megameter", "megaminute", "megamole", "meganewton", "megapascal", "megaradian", "megasecond", "megasiemens", "megasteradian", "megatesla", "megavolt", "megawatt", "megaweber", "megayear", "meter", "mg", "mh", "microFarad", "microHenry", "microHertz", "microJoule", "microKelvin", "microNewton", "microOhm", "microPascal", "microSiemens", "microTesla", "microVolt", "microWatt", "microWeber", "microamp", "microampere", "microannum", "microarcminute", "microarcsecond", "microcandela", "microcoulomb", "microday", "microdegree", "microelectronvolt", "microfarad", "microgram", "microhenry", "microhertz", "microhour", "microhr", "microjoule", "microliter", "microlumen", "microlux", "micrometer", "microminute", "micromole", "micron", "micronewton", "micropascal", "microradian", "microsecond", "microsiemens", "microsteradian", "microtesla", "microvolt", "microwatt", "microweber", "microyear", "milliFarad", "milliHenry", "milliHertz", "milliJoule", "milliKelvin", "milliNewton", "milliOhm", "milliPascal", "milliSiemens", "milliTesla", "milliVolt", "milliWatt", "milliWeber", "milliamp", "milliampere", "milliannum", "milliarcminute", "milliarcsecond", "millicandela", "millicoulomb", "milliday", "millidegree", "millielectronvolt", "millifarad", "milligram", "millihenry", "millihertz", "millihour", "millihr", "millijoule", "milliliter", "millilumen", "millilux", "millimeter", "milliminute", "millimole", "millinewton", "millipascal", "milliradian", "millisecond", "millisiemens", "millisteradian", "millitesla", "millivolt", "milliwatt", "milliweber", "milliyear", "min", "minute", "ml", "mlm", "mlx", "mm", "mmin", "mmol", "mohm", "mol", "mole", "mrad", "ms", "msr", "myr", "nA", "nC", "nF", "nH", "nHz", "nJ", "nK", "nL", "nN", "nOhm", "nPa", "nS", "nT", "nV", "nW", "nWb", "na", "nanoFarad", "nanoHenry", "nanoHertz", "nanoJoule", "nanoKelvin", "nanoNewton", "nanoOhm", "nanoPascal", "nanoSiemens", "nanoTesla", "nanoVolt", "nanoWatt", "nanoWeber", "nanoamp", "nanoampere", "nanoannum", "nanoarcminute", "nanoarcsecond", "nanocandela", "nanocoulomb", "nanoday", "nanodegree", "nanoelectronvolt", "nanofarad", "nanogram", "nanohenry", "nanohertz", "nanohour", "nanohr", "nanojoule", "nanoliter", "nanolumen", "nanolux", "nanometer", "nanominute", "nanomole", "nanonewton", "nanopascal", "nanoradian", "nanosecond", "nanosiemens", "nanosteradian", "nanotesla", "nanovolt", "nanowatt", "nanoweber", "nanoyear", "narcmin", "narcsec", "ncd", "nd", "ndeg", "neV", "newton", "ng", "nh", "nl", "nlm", "nlx", "nm", "nmin", "nmol", "nohm", "nrad", "ns", "nsr", "nyr", "ohm", "pA", "pC", "pF", "pH", "pHz", "pJ", "pK", "pL", "pN", "pOhm", "pPa", "pS", "pT", "pV", "pW", "pWb", "pa", "parcmin", "parcsec", "pascal", "pcd", "pct", "pd", "pdeg", "peV", "percent", "petaFarad", "petaHenry", "petaHertz", "petaJoule", "petaKelvin", "petaNewton", "petaOhm", "petaPascal", "petaSiemens", "petaTesla", "petaVolt", "petaWatt", "petaWeber", "petaamp", "petaampere", "petaannum", "petaarcminute", "petaarcsecond", "petacandela", "petacoulomb", "petaday", "petadegree", "petaelectronvolt", "petafarad", "petagram", "petahenry", "petahertz", "petahour", "petahr", "petajoule", "petaliter", "petalumen", "petalux", "petameter", "petaminute", "petamole", "petanewton", "petapascal", "petaradian", "petasecond", "petasiemens", "petasteradian", "petatesla", "petavolt", "petawatt", "petaweber", "petayear", "pg", "picoFarad", "picoHenry", "picoHertz", "picoJoule", "picoKelvin", "picoNewton", "picoOhm", "picoPascal", "picoSiemens", "picoTesla", "picoVolt", "picoWatt", "picoWeber", "picoamp", "picoampere", "picoannum", "picoarcminute", "picoarcsecond", "picocandela", "picocoulomb", "picoday", "picodegree", "picoelectronvolt", "picofarad", "picogram", "picohenry", "picohertz", "picohour", "picohr", "picojoule", "picoliter", "picolumen", "picolux", "picometer", "picominute", "picomole", "piconewton", "picopascal", "picoradian", "picosecond", "picosiemens", "picosteradian", "picotesla", "picovolt", "picowatt", "picoweber", "picoyear", "pl", "plm", "plx", "pm", "pmin", "pmol", "pohm", "prad", "ps", "psr", "pyr", "rad", "radian", "s", "sday", "second", "siemens", "sr", "steradian", "t", "teraFarad", "teraHenry", "teraHertz", "teraJoule", "teraKelvin", "teraNewton", "teraOhm", "teraPascal", "teraSiemens", "teraTesla", "teraVolt", "teraWatt", "teraWeber", "teraamp", "teraampere", "teraannum", "teraarcminute", "teraarcsecond", "teracandela", "teracoulomb", "teraday", "teradegree", "teraelectronvolt", "terafarad", "teragram", "terahenry", "terahertz", "terahour", "terahr", "terajoule", "teraliter", "teralumen", "teralux", "terameter", "teraminute", "teramole", "teranewton", "terapascal", "teraradian", "terasecond", "terasiemens", "terasteradian", "teratesla", "teravolt", "terawatt", "teraweber", "terayear", "tesla", "tonne", "uA", "uC", "uF", "uH", "uHz", "uJ", "uK", "uL", "uN", "uOhm", "uPa", "uS", "uT", "uV", "uW", "uWb", "ua", "uarcmin", "uarcsec", "uas", "ucd", "ud", "udeg", "ueV", "ug", "uh", "ul", "ulm", "ulx", "um", "umin", "umol", "uohm", "urad", "us", "usr", "uyr", "volt", "watt", "weber", "week", "wk", "yA", "yC", "yF", "yH", "yHz", "yJ", "yK", "yL", "yN", "yOhm", "yPa", "yS", "yT", "yV", "yW", "yWb", "ya", "yarcmin", "yarcsec", "ycd", "ydeg", "yeV", "year", "yg", "yh", "yl", "ylm", "ylx", "ym", "ymin", "ymol", "yoctoFarad", "yoctoHenry", "yoctoHertz", "yoctoJoule", "yoctoKelvin", "yoctoNewton", "yoctoOhm", "yoctoPascal", "yoctoSiemens", "yoctoTesla", "yoctoVolt", "yoctoWatt", "yoctoWeber", "yoctoamp", "yoctoampere", "yoctoannum", "yoctoarcminute", "yoctoarcsecond", "yoctocandela", "yoctocoulomb", "yoctoday", "yoctodegree", "yoctoelectronvolt", "yoctofarad", "yoctogram", "yoctohenry", "yoctohertz", "yoctohour", "yoctohr", "yoctojoule", "yoctoliter", "yoctolumen", "yoctolux", "yoctometer", "yoctominute", "yoctomole", "yoctonewton", "yoctopascal", "yoctoradian", "yoctosecond", "yoctosiemens", "yoctosteradian", "yoctotesla", "yoctovolt", "yoctowatt", "yoctoweber", "yoctoyear", "yohm", "yottaFarad", "yottaHenry", "yottaHertz", "yottaJoule", "yottaKelvin", "yottaNewton", "yottaOhm", "yottaPascal", "yottaSiemens", "yottaTesla", "yottaVolt", "yottaWatt", "yottaWeber", "yottaamp", "yottaampere", "yottaannum", "yottaarcminute", "yottaarcsecond", "yottacandela", "yottacoulomb", "yottaday", "yottadegree", "yottaelectronvolt", "yottafarad", "yottagram", "yottahenry", "yottahertz", "yottahour", "yottahr", "yottajoule", "yottaliter", "yottalumen", "yottalux", "yottameter", "yottaminute", "yottamole", "yottanewton", "yottapascal", "yottaradian", "yottasecond", "yottasiemens", "yottasteradian", "yottatesla", "yottavolt", "yottawatt", "yottaweber", "yottayear", "yr", "yrad", "ys", "ysr", "yyr", "zA", "zC", "zF", "zH", "zHz", "zJ", "zK", "zL", "zN", "zOhm", "zPa", "zS", "zT", "zV", "zW", "zWb", "za", "zarcmin", "zarcsec", "zcd", "zd", "zdeg", "zeV", "zeptoFarad", "zeptoHenry", "zeptoHertz", "zeptoJoule", "zeptoKelvin", "zeptoNewton", "zeptoOhm", "zeptoPascal", "zeptoSiemens", "zeptoTesla", "zeptoVolt", "zeptoWatt", "zeptoWeber", "zeptoamp", "zeptoampere", "zeptoannum", "zeptoarcminute", "zeptoarcsecond", "zeptocandela", "zeptocoulomb", "zeptoday", "zeptodegree", "zeptoelectronvolt", "zeptofarad", "zeptogram", "zeptohenry", "zeptohertz", "zeptohour", "zeptohr", "zeptojoule", "zeptoliter", "zeptolumen", "zeptolux", "zeptometer", "zeptominute", "zeptomole", "zeptonewton", "zeptopascal", "zeptoradian", "zeptosecond", "zeptosiemens", "zeptosteradian", "zeptotesla", "zeptovolt", "zeptowatt", "zeptoweber", "zeptoyear", "zettaFarad", "zettaHenry", "zettaHertz", "zettaJoule", "zettaKelvin", "zettaNewton", "zettaOhm", "zettaPascal", "zettaSiemens", "zettaTesla", "zettaVolt", "zettaWatt", "zettaWeber", "zettaamp", "zettaampere", "zettaannum", "zettaarcminute", "zettaarcsecond", "zettacandela", "zettacoulomb", "zettaday", "zettadegree", "zettaelectronvolt", "zettafarad", "zettagram", "zettahenry", "zettahertz", "zettahour", "zettahr", "zettajoule", "zettaliter", "zettalumen", "zettalux", "zettameter", "zettaminute", "zettamole", "zettanewton", "zettapascal", "zettaradian", "zettasecond", "zettasiemens", "zettasteradian", "zettatesla", "zettavolt", "zettawatt", "zettaweber", "zettayear", "zg", "zh", "zl", "zlm", "zlx", "zm", "zmin", "zmol", "zohm", "zrad", "zs", "zsr", "zyr", "Ba", "Barye", "Bi", "Biot", "C", "D", "Debye", "EBa", "ED", "EG", "EGal", "EP", "ESt", "Edyn", "Eerg", "Ek", "Fr", "Franklin", "G", "GBa", "GD", "GG", "GGal", "GP", "GSt", "Gal", "Gauss", "Gdyn", "Gerg", "Gk", "K", "Kayser", "MBa", "MD", "MG", "MGal", "MP", "MSt", "Mdyn", "Merg", "Mk", "P", "PBa", "PD", "PG", "PGal", "PP", "PSt", "Pdyn", "Perg", "Pk", "St", "TBa", "TD", "TG", "TGal", "TP", "TSt", "Tdyn", "Terg", "Tk", "YBa", "YD", "YG", "YGal", "YP", "YSt", "Ydyn", "Yerg", "Yk", "ZBa", "ZD", "ZG", "ZGal", "ZP", "ZSt", "Zdyn", "Zerg", "Zk", "aBa", "aD", "aG", "aGal", "aP", "aSt", "abA", "abC", "abampere", "abcoulomb", "adyn", "aerg", "ak", "attoBarye", "attoDebye", "attoGauss", "attoKayser", "attobarye", "attodebye", "attodyne", "attogal", "attogauss", "attokayser", "attopoise", "attostokes", "barye", "bases", "cBa", "cD", "cG", "cGal", "cP", "cSt", "cd", "cdyn", "centiBarye", "centiDebye", "centiGauss", "centiKayser", "centibarye", "centidebye", "centidyne", "centigal", "centigauss", "centikayser", "centimeter", "centipoise", "centistokes", "cerg", "ck", "cm", "dBa", "dD", "dG", "dGal", "dP", "dSt", "daBa", "daD", "daG", "daGal", "daP", "daSt", "dadyn", "daerg", "dak", "ddyn", "debye", "decaBarye", "decaDebye", "decaGauss", "decaKayser", "decabarye", "decadebye", "decadyne", "decagal", "decagauss", "decakayser", "decapoise", "decastokes", "deciBarye", "deciDebye", "deciGauss", "deciKayser", "decibarye", "decidebye", "decidyne", "decigal", "decigauss", "decikayser", "decipoise", "decistokes", "deg_C", "dekaBarye", "dekaDebye", "dekaGauss", "dekaKayser", "dekabarye", "dekadebye", "dekadyne", "dekagal", "dekagauss", "dekakayser", "dekapoise", "dekastokes", "derg", "division", "dk", "dyn", "dyne", "erg", "esu", "exaBarye", "exaDebye", "exaGauss", "exaKayser", "exabarye", "exadebye", "exadyne", "exagal", "exagauss", "exakayser", "exapoise", "exastokes", "fBa", "fD", "fG", "fGal", "fP", "fSt", "fdyn", "femtoBarye", "femtoDebye", "femtoGauss", "femtoKayser", "femtobarye", "femtodebye", "femtodyne", "femtogal", "femtogauss", "femtokayser", "femtopoise", "femtostokes", "ferg", "fk", "g", "gal", "gauss", "gigaBarye", "gigaDebye", "gigaGauss", "gigaKayser", "gigabarye", "gigadebye", "gigadyne", "gigagal", "gigagauss", "gigakayser", "gigapoise", "gigastokes", "hBa", "hD", "hG", "hGal", "hP", "hSt", "hdyn", "hectoBarye", "hectoDebye", "hectoGauss", "hectoKayser", "hectobarye", "hectodebye", "hectodyne", "hectogal", "hectogauss", "hectokayser", "hectopoise", "hectostokes", "herg", "hk", "k", "kBa", "kD", "kG", "kGal", "kP", "kSt", "kayser", "kdyn", "kerg", "kiloBarye", "kiloDebye", "kiloGauss", "kiloKayser", "kilobarye", "kilodebye", "kilodyne", "kilogal", "kilogauss", "kilokayser", "kilopoise", "kilostokes", "kk", "mBa", "mD", "mG", "mGal", "mP", "mSt", "mdyn", "megaBarye", "megaDebye", "megaGauss", "megaKayser", "megabarye", "megadebye", "megadyne", "megagal", "megagauss", "megakayser", "megapoise", "megastokes", "merg", "microBarye", "microDebye", "microGauss", "microKayser", "microbarye", "microdebye", "microdyne", "microgal", "microgauss", "microkayser", "micropoise", "microstokes", "milliBarye", "milliDebye", "milliGauss", "milliKayser", "millibarye", "millidebye", "millidyne", "milligal", "milligauss", "millikayser", "millipoise", "millistokes", "mk", "mol", "nBa", "nD", "nG", "nGal", "nP", "nSt", "nanoBarye", "nanoDebye", "nanoGauss", "nanoKayser", "nanobarye", "nanodebye", "nanodyne", "nanogal", "nanogauss", "nanokayser", "nanopoise", "nanostokes", "ndyn", "nerg", "nk", "pBa", "pD", "pG", "pGal", "pP", "pSt", "pdyn", "perg", "petaBarye", "petaDebye", "petaGauss", "petaKayser", "petabarye", "petadebye", "petadyne", "petagal", "petagauss", "petakayser", "petapoise", "petastokes", "picoBarye", "picoDebye", "picoGauss", "picoKayser", "picobarye", "picodebye", "picodyne", "picogal", "picogauss", "picokayser", "picopoise", "picostokes", "pk", "poise", "rad", "s", "sr", "statA", "statC", "statampere", "statcoulomb", "stokes", "teraBarye", "teraDebye", "teraGauss", "teraKayser", "terabarye", "teradebye", "teradyne", "teragal", "teragauss", "terakayser", "terapoise", "terastokes", "uBa", "uD", "uG", "uGal", "uP", "uSt", "udyn", "uerg", "uk", "yBa", "yD", "yG", "yGal", "yP", "ySt", "ydyn", "yerg", "yk", "yoctoBarye", "yoctoDebye", "yoctoGauss", "yoctoKayser", "yoctobarye", "yoctodebye", "yoctodyne", "yoctogal", "yoctogauss", "yoctokayser", "yoctopoise", "yoctostokes", "yottaBarye", "yottaDebye", "yottaGauss", "yottaKayser", "yottabarye", "yottadebye", "yottadyne", "yottagal", "yottagauss", "yottakayser", "yottapoise", "yottastokes", "zBa", "zD", "zG", "zGal", "zP", "zSt", "zdyn", "zeptoBarye", "zeptoDebye", "zeptoGauss", "zeptoKayser", "zeptobarye", "zeptodebye", "zeptodyne", "zeptogal", "zeptogauss", "zeptokayser", "zeptopoise", "zeptostokes", "zerg", "zettaBarye", "zettaDebye", "zettaGauss", "zettaKayser", "zettabarye", "zettadebye", "zettadyne", "zettagal", "zettagauss", "zettakayser", "zettapoise", "zettastokes", "zk", "AU", "B", "Da", "Dalton", "EAU", "EB", "EJy", "ER", "ERy", "Eadu", "Eau", "Eb", "Ebarn", "Ebeam", "Ebin", "Ebit", "Ebyte", "Echan", "Ecount", "Ect", "EiB", "Eib", "Eibit", "Eibyte", "Elyr", "Epc", "Eph", "Ephoton", "Epix", "Epixel", "Eu", "Evox", "Evoxel", "GAU", "GB", "GJy", "GR", "GRy", "Gadu", "Gau", "Gb", "Gbarn", "Gbeam", "Gbin", "Gbit", "Gbyte", "Gchan", "Gcount", "Gct", "GiB", "Gib", "Gibit", "Gibyte", "Glyr", "Gpc", "Gph", "Gphoton", "Gpix", "Gpixel", "Gu", "Gvox", "Gvoxel", "Jansky", "Jy", "KiB", "Kib", "Kibit", "Kibyte", "L_sun", "Lsun", "MAU", "MB", "MJy", "MR", "MRy", "M_e", "M_earth", "M_jup", "M_jupiter", "M_p", "M_sun", "Madu", "Mau", "Mb", "Mbarn", "Mbeam", "Mbin", "Mbit", "Mbyte", "Mchan", "Mcount", "Mct", "Mearth", "MiB", "Mib", "Mibit", "Mibyte", "Mjup", "Mjupiter", "Mlyr", "Mpc", "Mph", "Mphoton", "Mpix", "Mpixel", "Msun", "Mu", "Mvox", "Mvoxel", "PAU", "PB", "PJy", "PR", "PRy", "Padu", "Pau", "Pb", "Pbarn", "Pbeam", "Pbin", "Pbit", "Pbyte", "Pchan", "Pcount", "Pct", "PiB", "Pib", "Pibit", "Pibyte", "Plyr", "Ppc", "Pph", "Pphoton", "Ppix", "Ppixel", "Pu", "Pvox", "Pvoxel", "R", "R_earth", "R_jup", "R_jupiter", "R_sun", "Rayleigh", "Rearth", "Rjup", "Rjupiter", "Rsun", "Ry", "Sun", "TAU", "TB", "TJy", "TR", "TRy", "Tadu", "Tau", "Tb", "Tbarn", "Tbeam", "Tbin", "Tbit", "Tbyte", "Tchan", "Tcount", "Tct", "TiB", "Tib", "Tibit", "Tibyte", "Tlyr", "Tpc", "Tph", "Tphoton", "Tpix", "Tpixel", "Tu", "Tvox", "Tvoxel", "YAU", "YB", "YJy", "YR", "YRy", "Yadu", "Yau", "Yb", "Ybarn", "Ybeam", "Ybin", "Ybit", "Ybyte", "Ychan", "Ycount", "Yct", "Ylyr", "Ypc", "Yph", "Yphoton", "Ypix", "Ypixel", "Yu", "Yvox", "Yvoxel", "ZAU", "ZB", "ZJy", "ZR", "ZRy", "Zadu", "Zau", "Zb", "Zbarn", "Zbeam", "Zbin", "Zbit", "Zbyte", "Zchan", "Zcount", "Zct", "Zlyr", "Zpc", "Zph", "Zphoton", "Zpix", "Zpixel", "Zu", "Zvox", "Zvoxel", "aAU", "aB", "aJy", "aR", "aRy", "aadu", "aau", "ab", "abarn", "abeam", "abin", "abit", "abyte", "achan", "acount", "act", "adu", "alyr", "apc", "aph", "aphoton", "apix", "apixel", "astronomical_unit", "attoDa", "attoDalton", "attoJansky", "attoRayleigh", "attoastronomical_unit", "attobarn", "attobit", "attobyte", "attocount", "attojansky", "attolightyear", "attoparsec", "attophoton", "attopixel", "attorayleigh", "attorydberg", "attovoxel", "au", "avox", "avoxel", "b", "barn", "beam", "bin", "bit", "byte", "cAU", "cB", "cJy", "cR", "cRy", "cadu", "cau", "cb", "cbarn", "cbeam", "cbin", "cbit", "cbyte", "cchan", "ccount", "cct", "centiDa", "centiDalton", "centiJansky", "centiRayleigh", "centiastronomical_unit", "centibarn", "centibit", "centibyte", "centicount", "centijansky", "centilightyear", "centiparsec", "centiphoton", "centipixel", "centirayleigh", "centirydberg", "centivoxel", "chan", "clyr", "count", "cpc", "cph", "cphoton", "cpix", "cpixel", "ct", "cu", "cvox", "cvoxel", "cy", "cycle", "dAU", "dJy", "dR", "dRy", "daAU", "daB", "daJy", "daR", "daRy", "daadu", "daau", "dab", "dabarn", "dabeam", "dabin", "dabit", "dabyte", "dachan", "dacount", "dact", "dadu", "dalyr", "dapc", "daph", "daphoton", "dapix", "dapixel", "dau", "davox", "davoxel", "db", "dbarn", "dbeam", "dbin", "dbit", "dchan", "dcount", "dct", "decaDa", "decaDalton", "decaJansky", "decaRayleigh", "decaastronomical_unit", "decabarn", "decabit", "decabyte", "decacount", "decajansky", "decalightyear", "decaparsec", "decaphoton", "decapixel", "decarayleigh", "decarydberg", "decavoxel", "deciDa", "deciDalton", "deciJansky", "deciRayleigh", "deciastronomical_unit", "decibarn", "decibit", "decibyte", "decicount", "decijansky", "decilightyear", "deciparsec", "deciphoton", "decipixel", "decirayleigh", "decirydberg", "decivoxel", "dekaDa", "dekaDalton", "dekaJansky", "dekaRayleigh", "dekaastronomical_unit", "dekabarn", "dekabit", "dekabyte", "dekacount", "dekajansky", "dekalightyear", "dekaparsec", "dekaphoton", "dekapixel", "dekarayleigh", "dekarydberg", "dekavoxel", "division", "dlyr", "dpc", "dph", "dphoton", "dpix", "dpixel", "du", "dvox", "dvoxel", "earthMass", "earthRad", "electron", "exaDa", "exaDalton", "exaJansky", "exaRayleigh", "exaastronomical_unit", "exabarn", "exabit", "exabyte", "exacount", "exajansky", "exalightyear", "exaparsec", "exaphoton", "exapixel", "exarayleigh", "exarydberg", "exavoxel", "exbibit", "exbibyte", "fAU", "fB", "fJy", "fR", "fRy", "fadu", "fau", "fb", "fbarn", "fbeam", "fbin", "fbit", "fbyte", "fchan", "fcount", "fct", "femtoDa", "femtoDalton", "femtoJansky", "femtoRayleigh", "femtoastronomical_unit", "femtobarn", "femtobit", "femtobyte", "femtocount", "femtojansky", "femtolightyear", "femtoparsec", "femtophoton", "femtopixel", "femtorayleigh", "femtorydberg", "femtovoxel", "flyr", "fpc", "fph", "fphoton", "fpix", "fpixel", "fu", "fvox", "fvoxel", "gibibit", "gibibyte", "gigaDa", "gigaDalton", "gigaJansky", "gigaRayleigh", "gigaastronomical_unit", "gigabarn", "gigabit", "gigabyte", "gigacount", "gigajansky", "gigalightyear", "gigaparsec", "gigaphoton", "gigapixel", "gigarayleigh", "gigarydberg", "gigavoxel", "hAU", "hB", "hJy", "hR", "hRy", "hadu", "hau", "hb", "hbarn", "hbeam", "hbin", "hbit", "hbyte", "hchan", "hcount", "hct", "hectoDa", "hectoDalton", "hectoJansky", "hectoRayleigh", "hectoastronomical_unit", "hectobarn", "hectobit", "hectobyte", "hectocount", "hectojansky", "hectolightyear", "hectoparsec", "hectophoton", "hectopixel", "hectorayleigh", "hectorydberg", "hectovoxel", "hlyr", "hpc", "hph", "hphoton", "hpix", "hpixel", "hu", "hvox", "hvoxel", "jansky", "jupiterMass", "jupiterRad", "kAU", "kB", "kJy", "kR", "kRy", "kadu", "kau", "kb", "kbarn", "kbeam", "kbin", "kbit", "kbyte", "kchan", "kcount", "kct", "kibibit", "kibibyte", "kiloDa", "kiloDalton", "kiloJansky", "kiloRayleigh", "kiloastronomical_unit", "kilobarn", "kilobit", "kilobyte", "kilocount", "kilojansky", "kilolightyear", "kiloparsec", "kilophoton", "kilopixel", "kilorayleigh", "kilorydberg", "kilovoxel", "klyr", "kpc", "kph", "kphoton", "kpix", "kpixel", "ku", "kvox", "kvoxel", "lightyear", "lyr", "mAU", "mB", "mJy", "mR", "mRy", "madu", "mau", "mb", "mbarn", "mbeam", "mbin", "mbit", "mbyte", "mchan", "mcount", "mct", "mebibit", "mebibyte", "megaDa", "megaDalton", "megaJansky", "megaRayleigh", "megaastronomical_unit", "megabarn", "megabit", "megabyte", "megacount", "megajansky", "megalightyear", "megaparsec", "megaphoton", "megapixel", "megarayleigh", "megarydberg", "megavoxel", "microDa", "microDalton", "microJansky", "microRayleigh", "microastronomical_unit", "microbarn", "microbit", "microbyte", "microcount", "microjansky", "microlightyear", "microparsec", "microphoton", "micropixel", "microrayleigh", "microrydberg", "microvoxel", "milliDa", "milliDalton", "milliJansky", "milliRayleigh", "milliastronomical_unit", "millibarn", "millibit", "millibyte", "millicount", "millijansky", "millilightyear", "milliparsec", "milliphoton", "millipixel", "millirayleigh", "millirydberg", "millivoxel", "mlyr", "mpc", "mph", "mphoton", "mpix", "mpixel", "mu", "mvox", "mvoxel", "nAU", "nB", "nJy", "nR", "nRy", "nadu", "nanoDa", "nanoDalton", "nanoJansky", "nanoRayleigh", "nanoastronomical_unit", "nanobarn", "nanobit", "nanobyte", "nanocount", "nanojansky", "nanolightyear", "nanoparsec", "nanophoton", "nanopixel", "nanorayleigh", "nanorydberg", "nanovoxel", "nau", "nb", "nbarn", "nbeam", "nbin", "nbit", "nbyte", "nchan", "ncount", "nct", "nlyr", "npc", "nph", "nphoton", "npix", "npixel", "nu", "nvox", "nvoxel", "pAU", "pB", "pJy", "pR", "pRy", "padu", "parsec", "pau", "pb", "pbarn", "pbeam", "pbin", "pbit", "pbyte", "pc", "pchan", "pebibit", "pebibyte", "petaDa", "petaDalton", "petaJansky", "petaRayleigh", "petaastronomical_unit", "petabarn", "petabit", "petabyte", "petacount", "petajansky", "petalightyear", "petaparsec", "petaphoton", "petapixel", "petarayleigh", "petarydberg", "petavoxel", "ph", "photon", "picoDa", "picoDalton", "picoJansky", "picoRayleigh", "picoastronomical_unit", "picobarn", "picobit", "picobyte", "picocount", "picojansky", "picolightyear", "picoparsec", "picophoton", "picopixel", "picorayleigh", "picorydberg", "picovoxel", "pix", "pixel", "plyr", "ppc", "pph", "pphoton", "ppix", "ppixel", "pu", "pvox", "pvoxel", "rayleigh", "rydberg", "solLum", "solMass", "solRad", "tebibit", "tebibyte", "teraDa", "teraDalton", "teraJansky", "teraRayleigh", "teraastronomical_unit", "terabarn", "terabit", "terabyte", "teracount", "terajansky", "teralightyear", "teraparsec", "teraphoton", "terapixel", "terarayleigh", "terarydberg", "teravoxel", "u", "uAU", "uB", "uJy", "uR", "uRy", "uadu", "uau", "ub", "ubarn", "ubeam", "ubin", "ubit", "ubyte", "uchan", "ucount", "uct", "ulyr", "upc", "uph", "uphoton", "upix", "upixel", "uu", "uvox", "uvoxel", "vox", "voxel", "yAU", "yB", "yJy", "yR", "yRy", "yadu", "yau", "yb", "ybarn", "ybeam", "ybin", "ybit", "ybyte", "ychan", "ycount", "yct", "ylyr", "yoctoDa", "yoctoDalton", "yoctoJansky", "yoctoRayleigh", "yoctoastronomical_unit", "yoctobarn", "yoctobit", "yoctobyte", "yoctocount", "yoctojansky", "yoctolightyear", "yoctoparsec", "yoctophoton", "yoctopixel", "yoctorayleigh", "yoctorydberg", "yoctovoxel", "yottaDa", "yottaDalton", "yottaJansky", "yottaRayleigh", "yottaastronomical_unit", "yottabarn", "yottabit", "yottabyte", "yottacount", "yottajansky", "yottalightyear", "yottaparsec", "yottaphoton", "yottapixel", "yottarayleigh", "yottarydberg", "yottavoxel", "ypc", "yph", "yphoton", "ypix", "ypixel", "yu", "yvox", "yvoxel", "zAU", "zB", "zJy", "zR", "zRy", "zadu", "zau", "zb", "zbarn", "zbeam", "zbin", "zbit", "zbyte", "zchan", "zcount", "zct", "zeptoDa", "zeptoDalton", "zeptoJansky", "zeptoRayleigh", "zeptoastronomical_unit", "zeptobarn", "zeptobit", "zeptobyte", "zeptocount", "zeptojansky", "zeptolightyear", "zeptoparsec", "zeptophoton", "zeptopixel", "zeptorayleigh", "zeptorydberg", "zeptovoxel", "zettaDa", "zettaDalton", "zettaJansky", "zettaRayleigh", "zettaastronomical_unit", "zettabarn", "zettabit", "zettabyte", "zettacount", "zettajansky", "zettalightyear", "zettaparsec", "zettaphoton", "zettapixel", "zettarayleigh", "zettarydberg", "zettavoxel", "zlyr", "zpc", "zph", "zphoton", "zpix", "zpixel", "zu", "zvox", "zvoxel"), suffix=r'\b'), Keyword.Type), ], 'builtins': [ (words(("resolution", "steps", "emit_spike", "print", "println", "exp", "ln", "log10", "cosh", "sinh", "tanh", "info", "warning", "random", "randomInt", "expm1", "delta", "clip", "max", "min", "integrate_odes", "convolve", "true", "True", "false", "False"), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'\d+j?', Number.Integer)], 'name': [ ('[a-zA-Z_\$]\w*\'*', Name), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings-double': innerstring_rules(String.Double), 'dqs': [ (r'"', String.Double, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings-double') ], 'tdqs': [(r'"""', String.Double, '#pop'), include('strings-double'), (r'\n', String.Double)], }
class JuliaLexer(RegexLexer): """ For `Julia <http://julialang.org/>`_ source code. .. versionadded:: 1.6 """ name = 'Julia' aliases = ['julia', 'jl'] filenames = ['*.jl'] mimetypes = ['text/x-julia', 'application/x-julia'] flags = re.MULTILINE | re.UNICODE builtins = ( 'exit', 'whos', 'edit', 'load', 'is', 'isa', 'isequal', 'typeof', 'tuple', 'ntuple', 'uid', 'hash', 'finalizer', 'convert', 'promote', 'subtype', 'typemin', 'typemax', 'realmin', 'realmax', 'sizeof', 'eps', 'promote_type', 'method_exists', 'applicable', 'invoke', 'dlopen', 'dlsym', 'system', 'error', 'throw', 'assert', 'new', 'Inf', 'Nan', 'pi', 'im', ) keywords = ( 'begin', 'while', 'for', 'in', 'return', 'break', 'continue', 'macro', 'quote', 'let', 'if', 'elseif', 'else', 'try', 'catch', 'end', 'bitstype', 'ccall', 'do', 'using', 'module', 'import', 'export', 'importall', 'baremodule', 'immutable', ) types = ( 'Bool', 'Int', 'Int8', 'Int16', 'Int32', 'Int64', 'Uint', 'Uint8', 'Uint16', 'Uint32', 'Uint64', 'Float32', 'Float64', 'Complex64', 'Complex128', 'Any', 'Nothing', 'None', ) tokens = { 'root': [ (r'\n', Text), (r'[^\S\n]+', Text), (r'#=', Comment.Multiline, "blockcomment"), (r'#.*$', Comment), (r'[\[\]{}:(),;@]', Punctuation), (r'\\\n', Text), (r'\\', Text), # keywords (r'(local|global|const)\b', Keyword.Declaration), (words(keywords, suffix=r'\b'), Keyword), (words(types, suffix=r'\b'), Keyword.Type), # functions (r'(function)((?:\s|\\\s)+)', bygroups(Keyword, Name.Function), 'funcname'), # types (r'(type|typealias|abstract|immutable)((?:\s|\\\s)+)', bygroups(Keyword, Name.Class), 'typename'), # operators (r'==|!=|<=|>=|->|&&|\|\||::|<:|[-~+/*%=<>&^|.?!$]', Operator), (r'\.\*|\.\^|\.\\|\.\/|\\', Operator), # builtins (words(builtins, suffix=r'\b'), Name.Builtin), # backticks (r'`(?s).*?`', String.Backtick), # chars (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|" r"\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char), # try to match trailing transpose (r'(?<=[.\w)\]])\'+', Operator), # strings (r'(?:[IL])"', String, 'string'), (r'[E]?"', String, combined('stringescape', 'string')), # names (r'@[\w.]+', Name.Decorator), (u'(?:[a-zA-Z_\u00A1-\uffff]|%s)(?:[a-zA-Z_0-9\u00A1-\uffff]|%s)*!*' % ((unirange(0x10000, 0x10ffff),)*2), Name), # numbers (r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float), (r'(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?', Number.Float), (r'\d+(_\d+)+[eEf][+-]?[0-9]+', Number.Float), (r'\d+[eEf][+-]?[0-9]+', Number.Float), (r'0b[01]+(_[01]+)+', Number.Bin), (r'0b[01]+', Number.Bin), (r'0o[0-7]+(_[0-7]+)+', Number.Oct), (r'0o[0-7]+', Number.Oct), (r'0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+', Number.Hex), (r'0x[a-fA-F0-9]+', Number.Hex), (r'\d+(_\d+)+', Number.Integer), (r'\d+', Number.Integer) ], 'funcname': [ ('[a-zA-Z_]\w*', Name.Function, '#pop'), ('\([^\s\w{]{1,2}\)', Operator, '#pop'), ('[^\s\w{]{1,2}', Operator, '#pop'), ], 'typename': [ ('[a-zA-Z_]\w*', Name.Class, '#pop'), ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape), ], "blockcomment": [ (r'[^=#]', Comment.Multiline), (r'#=', Comment.Multiline, '#push'), (r'=#', Comment.Multiline, '#pop'), (r'[=#]', Comment.Multiline), ], 'string': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings # Interpolation is defined as "$" followed by the shortest full # expression, which is something we can't parse. # Include the most common cases here: $word, and $(paren'd expr). (r'\$[a-zA-Z_]+', String.Interpol), (r'\$\(', String.Interpol, 'in-intp'), # @printf and @sprintf formats (r'%[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]', String.Interpol), (r'[^$%"\\]+', String), # unhandled special signs (r'[$%"\\]', String), ], 'in-intp': [ (r'[^()]+', String.Interpol), (r'\(', String.Interpol, '#push'), (r'\)', String.Interpol, '#pop'), ] } def analyse_text(text): return shebang_matches(text, r'julia')
class SolidityLexer(RegexLexer): """ For Solidity source code. """ name = 'Solidity' aliases = ['sol', 'solidity'] filenames = ['*.sol'] mimetypes = [] flags = re.DOTALL | re.UNICODE | re.MULTILINE def type_names(prefix, sizerange): """ Helper for type name generation, like: bytes1 .. bytes32 """ namelist = [] for i in sizerange: namelist.append(prefix + str(i)) return tuple(namelist) def type_names_mn(prefix, sizerangem, sizerangen): """ Helper for type name generation, like: fixed0x8 .. fixed0x256 """ lm = [] ln = [] namelist = [] # construct lists out of ranges for i in sizerangem: lm.append(i) for i in sizerangen: ln.append(i) # sizes (in bits) are valid if (%8 == 0) and (m+n <= 256) # first condition is covered by passing proper sizerange{m,n} validpairs = [tuple([m, n]) for m in lm for n in ln if m + n <= 256] for i in validpairs: namelist.append(prefix + str(i[0]) + 'x' + str(i[1])) return tuple(namelist) tokens = { 'assembly': [ include('comments'), include('numbers'), include('strings'), include('whitespace'), (r'\{', Punctuation, '#push'), (r'\}', Punctuation, '#pop'), (r'[(),]', Punctuation), (r':=|=:', Operator), (r'(let)(\s*)(\w*\b)', bygroups(Operator.Word, Text, Name.Variable)), (r'(\w*\b)(\:[^=])', bygroups(Name.Label, Punctuation)), (r'if\b', Keyword.Reserved), # evm instructions (r'(stop|add|mul|sub|div|sdiv|mod|smod|addmod|mulmod|exp|' r'signextend|lt|gt|slt|sgt|eq|iszero|and|or|xor|not|byte|' r'keccak256|sha3|address|balance|origin|caller|' r'callvalue|calldataload|calldatasize|calldatacopy|' r'codesize|codecopy|gasprice|extcodesize|extcodecopy|' r'blockhash|coinbase|timestamp|number|difficulty|gaslimit|' r'pop|mload|mstore|mstore8|sload|sstore|for|switch|' r'jump|jumpi|pc|msize|gas|jumpdest|push1|push2|' r'push32|dup1|dup2|dup16|swap1|swap2|swap16|log0|log1|log4|' r'create|call|callcode|return|delegatecall|suicide|' r'returndatasize|returndatacopy|staticcall|revert|invalid)\b', Name.Function), # everything else is either a local/external var, or label ('[a-zA-Z_]\w*', Name) ], # FIXME: not used! 'natspec': [ (r'@(author|dev|notice|param|return|title)\b', Comment.Special), ], 'comment-parse-single': [ include('natspec'), (r'\n', Comment.Single, '#pop'), (r'[^\n]', Comment.Single), ], 'comment-parse-multi': [ include('natspec'), (r'[^*/]', Comment.Multiline), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ], 'comments': [ (r'//', Comment.Single, 'comment-parse-single'), (r'/[*]', Comment.Multiline, 'comment-parse-multi'), ], 'keywords-other': [ (words(('for', 'in', 'while', 'do', 'break', 'return', 'returns', 'continue', 'if', 'else', 'throw', 'new', 'delete'), suffix=r'\b'), Keyword), (r'assembly\b', Keyword, 'assembly'), (words(('contract', 'interface', 'enum', 'event', 'function', 'constructor', 'library', 'mapping', 'modifier', 'struct', 'var'), suffix=r'\b'), Keyword.Declaration), (r'(import|using)\b', Keyword.Namespace), # misc keywords (r'pragma (solidity|experimental)\b', Keyword.Reserved), (r'(_|as|constant|default|from|is)\b', Keyword.Reserved), (r'emit\b', Keyword.Reserved), # built-in modifier (r'payable\b', Keyword.Reserved), # variable location specifiers (r'(memory|storage)\b', Keyword.Reserved), # method visibility specifiers (r'(external|internal|private|public)\b', Keyword.Reserved), # event parameter specifiers (r'(anonymous|indexed)\b', Keyword.Reserved), # added in `solc v0.4.0`, not covered elsewhere (r'(abstract|pure|static|view)\b', Keyword.Reserved), # built-in constants (r'(true|false)\b', Keyword.Constant), (r'(wei|finney|szabo|ether)\b', Keyword.Constant), (r'(seconds|minutes|hours|days|weeks|years)\b', Keyword.Constant), ], 'keywords-types': [ (words(('address', 'bool', 'byte', 'bytes', 'int', 'fixed', 'string', 'ufixed', 'uint'), suffix=r'\b'), Keyword.Type), (words(type_names('int', range(8, 256 + 1, 8)), suffix=r'\b'), Keyword.Type), (words(type_names('uint', range(8, 256 + 1, 8)), suffix=r'\b'), Keyword.Type), (words(type_names('bytes', range(1, 32 + 1)), suffix=r'\b'), Keyword.Type), (words(type_names_mn('fixed', range(8, 256 + 1, 8), range(0, 80 + 1, 1)), suffix=r'\b'), Keyword.Type), (words(type_names_mn('ufixed', range(8, 256 + 1, 8), range(0, 80 + 1, 1)), suffix=r'\b'), Keyword.Type), ], 'keywords-nested': [ (r'abi\.encode(|Packed|WithSelector|WithSignature)\b', Name.Builtin), (r'block\.(blockhash|coinbase|difficulty|gaslimit|hash|number|timestamp)\b', Name.Builtin), (r'msg\.(data|gas|sender|value)\b', Name.Builtin), (r'tx\.(gasprice|origin)\b', Name.Builtin), ], 'numbers': [ (r'0[xX][0-9a-fA-F]+', Number.Hex), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?', Number.Float), (r'[0-9]+([eE][0-9]+)?', Number.Integer), ], 'string-parse-common': [ # escapes (r'\\(u[0-9a-fA-F]{4}|x..|[^x])', String.Escape), # almost everything else is plain characters (r'[^\\"\'\n]+', String), # line continuation (r'\\\n', String), # stray backslash (r'\\', String) ], 'string-parse-double': [(r'"', String, '#pop'), (r"'", String)], 'string-parse-single': [(r"'", String, '#pop'), (r'"', String)], 'strings': [ # hexadecimal string literals (r"hex'[0-9a-fA-F]+'", String), (r'hex"[0-9a-fA-F]+"', String), # usual strings (r'"', String, combined('string-parse-common', 'string-parse-double')), (r"'", String, combined('string-parse-common', 'string-parse-single')) ], 'whitespace': [(r'\s+', Text)], 'root': [ include('comments'), include('keywords-types'), include('keywords-nested'), include('keywords-other'), include('numbers'), include('strings'), include('whitespace'), (r'\+\+|--|\*\*|\?|:|~|&&|\|\||=>|==?|!=?|' r'(<<|>>>?|[-<>+*%&|^/])=?', Operator), (r'[{(\[;,]', Punctuation), (r'[})\].]', Punctuation), # compiler built-ins (r'(this|super)\b', Name.Builtin), (r'selector\b', Name.Builtin), # like block.hash and msg.gas in `keywords-nested` (r'(blockhash|gasleft)\b', Name.Function), # actually evm instructions, should be Name.Function?.. (r'(balance|now)\b', Name.Builtin), (r'(selfdestruct|suicide)\b', Name.Builtin), # processed into many-instructions (r'(send|transfer|call|callcode|delegatecall)\b', Name.Function), (r'(assert|revert|require)\b', Name.Function), (r'push\b', Name.Function), # built-in functions and/or precompiles (r'(addmod|ecrecover|keccak256|mulmod|ripemd160|sha256|sha3)\b', Name.Function), # everything else is a var/function name ('[a-zA-Z_]\w*', Name) ] # 'root' } # tokens
class Python3LexerExtended(Python3Lexer): """Extended python 3 lexer.""" aliases = ['py3ext'] name = 'py3ext' tokens = Python3Lexer.tokens.copy() tokens['root'] = [ (r'\n', Text), (r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc)), (r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc)), (r'[^\S\n]+', Text), (r'\A#!.+$', Comment.Hashbang), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('magicfuncs'), include('magicvars'), include('backtick'), include('strings'), include('name'), include('numbers'), ] tokens['strings'] = [ ('(?i)(r[fub]?|[fub]r)(""")', bygroups(String.Affix, String.Double), 'tdqs'), ("(?i)(r[fub]?|[fub]r)(''')", bygroups(String.Affix, String.Single), 'tsqs'), ('(?i)(r[fub]?|[fub]r)(")', bygroups(String.Affix, String.Double), 'dqs'), ("(?i)(r[fub]?|[fub]r)(')", bygroups(String.Affix, String.Single), 'sqs'), ('(?i)([ubf]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ("(?i)([ubf]?)(''')", bygroups(String.Affix, String.Single), combined('stringescape', 'tsqs')), ('(?i)([ubf]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), ("(?i)([ubf]?)(')", bygroups(String.Affix, String.Single), combined('stringescape', 'sqs')), ] tokens['name'] = [ (r'@[\w.]+', Name.Decorator), (r'[a-zA-Z_]\w*', Name), ]
class RenpyLexer(RegexLexer): """ For `Renpy <http://www.renpy.org>`_ source code. """ name = 'Renpy' aliases = ['renpy', 'rpy'] filenames = ['*.rpy'] def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsux%]', String.Interpol), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r'%', ttype), # newlines are an error (use "nl" state) ] tokens = { 'root': [ (r'\n', Text), include('screen_lang'), (r'^ *\$', Renpy.Python.Inline), (r'((renpy|im)\.[a-zA-Z_]+)\(([a-zA-Z_ ,=]+)\)', bygroups(Renpy.Function.Builtin, Renpy.Function.Arguments)), include("screen_actions"), (r'\$', String.Symbol), (r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc)), (r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc)), (r'[^\S\n]+', Text), (r'\A#!.+$', Comment.Hashbang), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), include('special_labels'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('magicfuncs'), include('magicvars'), include('backtick'), ('([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), 'tdqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(''')", bygroups(String.Affix, String.Single), 'tsqs'), ('([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), 'dqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(')", bygroups(String.Affix, String.Single), 'sqs'), ('([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ("([uUbB]?)(''')", bygroups(String.Affix, String.Single), combined('stringescape', 'tsqs')), ('([uUbB]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), ("([uUbB]?)(')", bygroups(String.Affix, String.Single), combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(('assert', 'break', 'continue', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'global', 'if', 'lambda', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'yield from', 'as', 'with'), suffix=r'\b'), Keyword), (words(( 'audio', 'scene', 'expression', 'play', 'queue', 'stop', 'python', 'init', 'pause', 'jump', 'call', 'zorder', 'show', 'hide', 'at', 'music', 'sound', 'voice', ), suffix=r'\b'), Renpy.Reserved), (words(('default', 'define', 'layeredimage', 'screen', 'transform', 'label', 'menu', 'style', 'image'), suffix=r'\b'), Renpy.Declaration), ], 'special_labels': [ (words(( 'start', 'quit', 'after_load', 'splashscreen', 'before_main_menu', 'main_menu', 'after_warp', ), prefix=r"label ", suffix=r'\b'), Renpy.Label.Reserved), ], 'screen_lang': [ (words(( 'add', 'bar', 'button', 'fixed', 'frame', 'grid', 'hbox', 'imagebutton', 'input', 'key', 'mousearea', 'null', 'side', 'text', 'textbutton', 'timer', 'vbar', 'vbox', 'viewport', 'vpgrid', 'window', 'imagemap', 'hotspot', 'hotbar', 'drag', 'draggroup', 'has', 'on', 'use', 'transclude', 'transform', 'label', ), prefix=r'\s+', suffix=r'\b'), Renpy.Screen.Displayables), ], 'properties': [ # renpy/tutorial/game/keywords.py # [u'(?:insensitive|keysym|layer|length|min_overlap|modal|mouse_drop|mousewheel| # pagekeys|pixel_width|predict|prefix|properties|range|repeat|rows|scope|scrollbars| # selected|selected_hover|selected_idle|selected_insensitive|sensitive|slow|slow_done| # pacing|style|style_group|style_prefix|style_suffix|substitute|suffix|text_style| # transpose|unhovered|value|variant|width|xadjustment|xinitial|yadjustment|yinitial| # zorder)', '(?:|activate_|hover_|idle_|insensitive_|selected_|selected_activate_| # selected_hover_|selected_idle_|selected_insensitive_)(?:additive|adjust_spacing # |align|alignaround|alpha|alt|anchor|angle|antialias|area|around|background| # bar_invert|bar_resizing|bar_vertical|base_bar|black_color|bold|bottom_bar| # bottom_gutter|bottom_margin|bottom_padding|box_layout|box_reverse|box_wrap| # box_wrap_spacing|caret|child|clipping|color|corner1|corner2|crop|crop_relative| # debug|delay|drop_shadow|drop_shadow_color|events|first_indent|first_spacing| # fit_first|focus_mask|font|foreground|hinting|hyperlink_functions|italic| # justify|kerning|key_events|keyboard_focus|language|layout|left_bar|left_gutter| # left_margin|left_padding|line_leading|line_spacing|margin|maximum|maxsize|min_width| # minimum|minwidth|mouse|nearest|newline_indent|offset|order_reverse|outline_scaling| # outlines|padding|pos|radius|rest_indent|right_bar|right_gutter|right_margin| # right_padding|rotate|rotate_pad|ruby_style|size|size_group|slow_abortable| # slow_cps|slow_cps_multiplier|sound|spacing|strikethrough|subpixel|text_align| # text_y_fudge|thumb|thumb_offset|thumb_shadow|tooltip|top_bar|top_gutter|top_margin| # top_padding|transform_anchor|underline|unscrollable|vertical|xalign|xanchor| # xanchoraround|xaround|xcenter|xfill|xfit|xmargin|xmaximum|xminimum|xoffset|xpadding| # xpan|xpos|xsize|xspacing|xtile|xysize|xzoom|yalign|yanchor|yanchoraround|yaround| # ycenter|yfill|yfit|ymargin|ymaximum|yminimum|yoffset|ypadding|ypan|ypos|ysize| # yspacing|ytile|yzoom|zoom)', '(?:vscrollbar_|scrollbar_)(?:|activate_|hover_| # idle_|insensitive_|selected_|selected_activate_|selected_hover_|selected_idle_| # selected_insensitive_)(?:align|alt|anchor|area|bar_invert|bar_resizing|bar_vertical| # base_bar|bottom_bar|bottom_gutter|clipping|debug|keyboard_focus|left_bar|left_gutter| # maximum|mouse|offset|pos|right_bar|right_gutter|thumb|thumb_offset|thumb_shadow| # tooltip|top_bar|top_gutter|unscrollable|xalign|xanchor|xcenter|xfill|xmaximum| # xoffset|xpos|xsize|xysize|yalign|yanchor|ycenter|yfill|ymaximum|yoffset|ypos| # ysize)', 'side_(?:|activate_|hover_|idle_|insensitive_|selected_|selected_activate_| # selected_hover_|selected_idle_|selected_insensitive_)(?:align|alt|anchor|area|clipping| # debug|maximum|offset|pos|spacing|tooltip|xalign|xanchor|xcenter|xfill|xmaximum| # xoffset|xpos|xsize|xysize|yalign|yanchor|ycenter|yfill|ymaximum|yoffset|ypos| # ysize)', 'text_(?:|activate_|hover_|idle_|insensitive_|selected_|selected_activate_| # selected_hover_|selected_idle_|selected_insensitive_)(?:adjust_spacing|align|alt| # anchor|antialias|area|black_color|bold|clipping|color|debug|drop_shadow| # drop_shadow_color|first_indent|font|hinting|hyperlink_functions|italic|justify| # kerning|language|layout|line_leading|line_spacing|maximum|min_width|minimum|minwidth| # newline_indent|offset|outline_scaling|outlines|pos|rest_indent|ruby_style|size| # slow_abortable|slow_cps|slow_cps_multiplier|strikethrough|text_align|text_y_fudge| # tooltip|underline|vertical|xalign|xanchor|xcenter|xfill|xmaximum|xminimum|xoffset| # xpos|xsize|xysize|yalign|yanchor|ycenter|yfill|ymaximum|yminimum|yoffset|ypos| # ysize)', 'viewport_(?:|activate_|hover_|idle_|insensitive_|selected_| # selected_activate_|selected_hover_|selected_idle_|selected_insensitive_)(?:align # |alt|anchor|area|clipping|debug|maximum|offset|pos|tooltip|xalign|xanchor|xcenter # |xfill|xmaximum|xoffset|xpos|xsize|xysize|yalign|yanchor|ycenter|yfill|ymaximum| # yoffset|ypos|ysize)'] (words(("action", "activate_sound", "activated", "adjustment", "allow", "alpha", "alternate", "alternate_keysym", "arguments", "arrowkeys", "at", "auto", "cache", "caption", "changed", "child_size", "clicked", "cols", "copypaste", "default", "drag_handle", "drag_joined", "drag_name", "drag_offscreen", "drag_raise", "draggable", "dragged", "drop_allowable", "droppable", "dropped", "edgescroll", "exclude", "focus", "focus_mask", "ground", "height", "hover", "hovered", "id", "idle", "image_style"), prefix=r"( {4}){2,}", suffix=r"\b"), Renpy.Properties) ], "screen_actions": [(words( ("Call", "Hide", "Jump", "NullAction", "Return", "Show", "ShowTransient", "ToggleScreen", "AddToSet", "RemoveFromSet", "SetDict", "SetField", "SetLocalVariable", "SetScreenVariable", "SetVariable", "ToggleDict", "ToggleField", "ToggleLocalVariable", "ToggleScreenVariable", "ToggleSetMembership", "ToggleVariable", "MainMenu", "Quit", "ShowMenu", "Start", "FileAction", "FileDelete", "FileLoad", "FilePage", "FilePageNext", "FileSave", "FileTakeScreenshot", "QuickLoad", "QuickSave", "PauseAudio", "Play", "Queue", "SetMixer", "SetMute", "Stop", "ToggleMute", "Confirm", "DisableAllInputValues", "Function", "Help", "HideInterface", "If", "InvertSelected", "MouseMove", "Notify", "OpenURL", "QueueEvent", "RestartStatement", "RollForward", "Rollback", "RollbackToIdentifier", "Screenshot", "Scroll", "SelectedIf", "SensitiveIf", "Skip", "With", "AnimatedValue", "AudioPositionValue", "DictValue", "FieldValue", "MixerValue", "ScreenVariableValue", "StaticValue", "VariableValue", "XScrollValue", "YScrollValue", "DictInputValue", "FieldInputValue", "FilePageNameInputValue", "ScreenVariableInputValue", "VariableInputValue", "Preference", "GamepadCalibrate", "GamepadExists", "FileCurrentPage", "FileCurrentScreenshot", "FileJson", "FileLoadable", "FileNewest", "FilePageName", "FileSaveName", "FileScreenshot", "FileSlotName", "FileTime", "FileUsedSlot", "SideImage", "GetTooltip"), prefix=r' ', suffix=r"\b"), Renpy.Screen.Actions)], 'builtins': [ (words( ('__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls' r')\b', Name.Builtin.Pseudo), (words( ('ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', 'RecursionError', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'StopAsyncIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning', 'WindowsError', 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Exception), ], 'magicfuncs': [ (words( ('__abs__', '__add__', '__and__', '__call__', '__cmp__', '__coerce__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__delslice__', '__div__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floordiv__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__idiv__', '__ifloordiv__', '__ilshift__', '__imod__', '__imul__', '__index__', '__init__', '__instancecheck__', '__int__', '__invert__', '__iop__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__long__', '__lshift__', '__lt__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__oct__', '__op__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rcmp__', '__rdiv__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__rop__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__unicode__', '__xor__'), suffix=r'\b'), Name.Function.Magic), ], 'magicvars': [ (words( ('__bases__', '__class__', '__closure__', '__code__', '__defaults__', '__dict__', '__doc__', '__file__', '__func__', '__globals__', '__metaclass__', '__module__', '__mro__', '__name__', '__self__', '__slots__', '__weakref__'), suffix=r'\b'), Name.Variable.Magic), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[0-7]+j?', Number.Oct), (r'0[bB][01]+', Number.Bin), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+j?', Number.Integer)], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[\w.]+', Name.Decorator), (r'[a-zA-Z_]\w*', Name), ], 'funcname': [ include('magicfuncs'), (r'[a-zA-Z_]\w*', Name.Function, '#pop'), default('#pop'), ], 'classname': [(r'[a-zA-Z_]\w*', Name.Class, '#pop')], 'import': [ (r'(?:[ \t]|\\\n)+', Text), (r'as\b', Keyword.Namespace), (r',', Operator), (r'[a-zA-Z_][\w.]*', Name.Namespace), default('#pop') # all else: go back ], 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'import\b', Keyword.Namespace, '#pop'), # if None occurs here, it's "raise x from None", since None can # never be a module name (r'None\b', Name.Builtin.Pseudo, '#pop'), # sadly, in "raise x from y" y will be highlighted as namespace too (r'[a-zA-Z_.][\w.]*', Name.Namespace), # anything else here also means "raise x from y" and is therefore # not an error default('#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings-single': innerstring_rules(String.Single), 'strings-double': innerstring_rules(String.Double), 'dqs': [ (r'"', String.Double, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings-double') ], 'sqs': [ (r"'", String.Single, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings-single') ], 'tdqs': [(r'"""', String.Double, '#pop'), include('strings-double'), (r'\n', String.Double)], 'tsqs': [(r"'''", String.Single, '#pop'), include('strings-single'), (r'\n', String.Single)], } def analyse_text(text): return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \ 'import ' in text[:1000]
class GDScriptLexer(RegexLexer): """ For `GDScript source code <https://www.godotengine.org>`_. """ name = "GDScript" aliases = ["gdscript", "gd"] filenames = ["*.gd"] mimetypes = ["text/x-gdscript", "application/x-gdscript"] def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting ( r"%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?" "[hlL]?[E-GXc-giorsux%]", String.Interpol, ), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r"%", ttype), # newlines are an error (use "nl" state) ] tokens = { "root": [ (r"\n", Text), ( r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc), ), ( r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc), ), (r"[^\S\n]+", Text), (r"#.*$", Comment.Single), (r"[]{}:(),;[]", Punctuation), (r"\\\n", Text), (r"\\", Text), (r"(in|and|or|not)\b", Operator.Word), ( r"!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]", Operator, ), include("keywords"), (r"(func)((?:\s|\\\s)+)", bygroups(Keyword, Text), "funcname"), (r"(class)((?:\s|\\\s)+)", bygroups(Keyword, Text), "classname"), include("builtins"), include("decorators"), ( '([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), "tdqs", ), ( "([rR]|[uUbB][rR]|[rR][uUbB])(''')", bygroups(String.Affix, String.Single), "tsqs", ), ( '([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), "dqs", ), ( "([rR]|[uUbB][rR]|[rR][uUbB])(')", bygroups(String.Affix, String.Single), "sqs", ), ( '([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined("stringescape", "tdqs"), ), ( "([uUbB]?)(''')", bygroups(String.Affix, String.Single), combined("stringescape", "tsqs"), ), ( '([uUbB]?)(")', bygroups(String.Affix, String.Double), combined("stringescape", "dqs"), ), ( "([uUbB]?)(')", bygroups(String.Affix, String.Single), combined("stringescape", "sqs"), ), include("name"), include("numbers"), ], "keywords": [ ( words( ( "and", "await", "in", "get", "set", "not", "or", "as", "breakpoint", "class", "class_name", "extends", "is", "func", "signal", "const", "enum", "static", "var", "break", "continue", "if", "elif", "else", "for", "pass", "return", "match", "while", "super", ), suffix=r"\b", ), Keyword, ), ], "builtins": [ ( words( ( # doc/classes/@GlobalScope.xml "abs", "absf", "absi", "acos", "asin", "atan", "atan2", "bytes2var", "bytes2var_with_objects", "ceil", "clamp", "clampf", "clampi", "cos", "cosh", "cubic_interpolate", "db2linear", "deg2rad", "ease", "error_string", "exp", "floor", "fmod", "fposmod", "hash", "instance_from_id", "inverse_lerp", "is_equal_approx", "is_inf", "is_instance_id_valid", "is_instance_valid", "is_nan", "is_zero_approx", "lerp", "lerp_angle", "linear2db", "log", "max", "maxf", "maxi", "min", "minf", "mini", "move_toward", "nearest_po2", "pingpong", "posmod", "pow", "print", "print_verbose", "printerr", "printraw", "prints", "printt", "push_error", "push_warning", "rad2deg", "rand_from_seed", "randf", "randf_range", "randfn", "randi", "randi_range", "randomize", "range_lerp", "range_step_decimals", "rid_allocate_id", "rid_from_int64", "round", "seed", "sign", "signf", "signi", "sin", "sinh", "smoothstep", "snapped", "sqrt", "step_decimals", "str", "str2var", "tan", "tanh", "typeof", "var2bytes", "var2bytes_with_objects", "var2str", "weakref", "wrapf", "wrapi", # modules/gdscript/doc_classes/@GDScript.xml "Color8", "assert", "char", "convert", "dict2inst", "get_stack", "inst2dict", "len", "load", "preload", "print_debug", "print_stack", "range", "str", "type_exists", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Builtin, ), (r"((?<!\.)(self|super|false|true)|(PI|TAU|NAN|INF)" r")\b", Name.Builtin.Pseudo), ( words( ( "bool", "int", "float", "String", "StringName", "NodePath", "Vector2", "Vector2i", "Rect2", "Rect2i", "Transform2D", "Vector3", "Vector3i", "AABB", "Plane", "Quaternion", "Basis", "Transform3D", "Color", "RID", "Object", "NodePath", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray", "PackedVector2Array", "PackedVector2iArray", "PackedVector3Array", "PackedVector3iArray", "PackedColorArray", "null", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Builtin.Type, ), ], "decorators": [ ( words( ( "@export", "@export_color_no_alpha", "@export_dir", "@export_enum", "@export_exp_easing", "@export_file", "@export_flags", "@export_flags_2d_navigation", "@export_flags_2d_physics", "@export_flags_2d_render", "@export_flags_3d_navigation", "@export_flags_3d_physics", "@export_flags_3d_render", "@export_global_dir", "@export_global_file", "@export_multiline", "@export_node_path", "@export_placeholder", "@export_range", "@icon", "@onready", "@rpc", "@tool", "@warning_ignore", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Decorator, ), ], "numbers": [ (r"(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?", Number.Float), (r"\d+[eE][+-]?[0-9]+j?", Number.Float), (r"0x[a-fA-F0-9]+", Number.Hex), (r"0b[01]+", Number.Bin), (r"\d+j?", Number.Integer), ], "name": [(r"@?[a-zA-Z_]\w*", Name)], "funcname": [(r"[a-zA-Z_]\w*", Name.Function, "#pop"), default("#pop")], "classname": [(r"[a-zA-Z_]\w*", Name.Class, "#pop")], "stringescape": [( r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r"U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})", String.Escape, )], "strings-single": innerstring_rules(String.Single), "strings-double": innerstring_rules(String.Double), "dqs": [ (r'"', String.Double, "#pop"), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include("strings-double"), ], "sqs": [ (r"'", String.Single, "#pop"), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include("strings-single"), ], "tdqs": [ (r'"""', String.Double, "#pop"), include("strings-double"), (r"\n", String.Double), ], "tsqs": [ (r"'''", String.Single, "#pop"), include("strings-single"), (r"\n", String.Single), ], }
class HushLexer(RegexLexer): """ For `Hush <https://www.github.com/gahag/hush>` scripts. """ name = 'Hush' aliases = ['hush'] filenames = ['*.hsh'] mimetypes = ['text/x-hush', 'application/x-hush'] _comment = r'(?:#.*$)' _space = r'(?:\s+)' _s = r'(?:%s|%s)' % (_comment, _space) _name = r'(?:[^\W\d]\w*)' tokens = { 'root': [ # Hush allows a file to start with a shebang. (r'#!.*', Comment.Preproc), default('base'), ], 'ws': [ (_comment, Comment.Single), (_space, Text), ], 'base': [ include('ws'), (r'(?i)0x[\da-f]*(\.[\da-f]*)?(p[+-]?\d+)?', Number.Hex), (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float), (r'(?i)\d+e[+-]?\d+', Number.Float), (r'\d+', Number.Integer), # multiline strings # (r'(?s)\[(=*)\[.*?\]\1\]', String), # (r'::', Punctuation, 'label'), # (r'\.{3}', Punctuation), (r'[\?\$!=<>{}|+\-*/%]+', Operator), (r'[\[\]().,:;]|@\[', Punctuation), (r'(and|or|not)\b', Operator.Word), (r'(break|self|do|else|end|for|if|in|return|then|while)\b', Keyword.Reserved), (r'(let)\b', Keyword.Declaration), (r'(true|false|nil)\b', Keyword.Constant), (r'(function)\b', Keyword.Reserved, 'funcname'), (r'[A-Za-z_]\w*(\.[A-Za-z_]\w*)?', Name), ("'", String.Char, combined('stringescape', 'sqs')), # TODO ('"', String.Double, combined('stringescape', 'dqs')) ], 'funcname': [ include('ws'), (_name, Name.Function, '#pop'), # inline function (r'\(', Punctuation, '#pop'), ], 'stringescape': [ (r'\\([abfnrtv\\"\']|[\r\n]{1,2}|z\s*|x[0-9a-fA-F]{2}|\d{1,3}|' r'u\{[0-9a-fA-F]+\})', String.Escape), ], 'sqs': [ (r"'", String.Single, '#pop'), (r"[^\\']+", String.Single), ], 'dqs': [ (r'"', String.Double, '#pop'), (r'[^\\"]+', String.Double), ] } def get_tokens_unprocessed(self, text): for index, token, value in RegexLexer.get_tokens_unprocessed( self, text): if token is Name: if '.' in value: a, b = value.split('.') yield index, Name, a yield index + len(a), Punctuation, '.' yield index + len(a) + 1, Name, b continue yield index, token, value
class PythonLexer(RegexLexer): """ For `Python <http://www.python.org>`_ source code. """ name = 'Python' aliases = ['python', 'py', 'sage'] filenames = [ '*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage' ] mimetypes = ['text/x-python', 'application/x-python'] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)([rRuU]{,2}"""(?:.|\n)*?""")', bygroups(Text, String.Doc)), (r"^(\s*)([rRuU]{,2}'''(?:.|\n)*?''')", bygroups(Text, String.Doc)), (r'[^\S\n]+', Text), (r'\A#!.+$', Comment.Hashbang), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('backtick'), ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), ('[uU]?"""', String, combined('stringescape', 'tdqs')), ("[uU]?'''", String, combined('stringescape', 'tsqs')), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(('assert', 'break', 'continue', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'global', 'if', 'lambda', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'yield from', 'as', 'with'), suffix=r'\b'), Keyword), ], 'builtins': [ (words( ('__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True' r')\b', Name.Builtin.Pseudo), (words( ('ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning', 'WindowsError', 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Exception), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[0-7]+j?', Number.Oct), (r'0[bB][01]+', Number.Bin), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+j?', Number.Integer)], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[\w.]+', Name.Decorator), ('[a-zA-Z_]\w*', Name), ], 'funcname': [('[a-zA-Z_]\w*', Name.Function, '#pop')], 'classname': [('[a-zA-Z_]\w*', Name.Class, '#pop')], 'import': [ (r'(?:[ \t]|\\\n)+', Text), (r'as\b', Keyword.Namespace), (r',', Operator), (r'[a-zA-Z_][\w.]*', Name.Namespace), default('#pop') # all else: go back ], 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'import\b', Keyword.Namespace, '#pop'), # if None occurs here, it's "raise x from None", since None can # never be a module name (r'None\b', Name.Builtin.Pseudo, '#pop'), # sadly, in "raise x from y" y will be highlighted as namespace too (r'[a-zA-Z_.][\w.]*', Name.Namespace), # anything else here also means "raise x from y" and is therefore # not an error default('#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings': [ # the old style '%s' % (...) string formatting (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', String), (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [(r'\n', String)], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings') ], 'tdqs': [(r'"""', String, '#pop'), include('strings'), include('nl')], 'tsqs': [(r"'''", String, '#pop'), include('strings'), include('nl')], } def analyse_text(text): return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \ 'import ' in text[:1000]
class AhkTestLexer(RegexLexer): name = 'AutoHotkey' aliases = ['ahk_cl, ahk_custom_lexer, ahk_patched'] filenames = ['*.ahk'] mimetypes = ['text/x-ahk'] tokens = { 'root': [ (r'^(\s*)(/\*)', bygroups(Text, Comment.Multiline), 'incomment'), (r'^(\s*)(\()', bygroups(Text, Generic), 'incontinuation'), (r'\s+;.*?$', Comment.Single), (r'^;.*?$', Comment.Single), # (r'[]{}(),;[]', Punctuation), (r'[]{},;[]', Punctuation), (r'(in|is|and|or|not)\b', Operator.Word), # (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable), (r'\%[a-zA-Z_#@$][\w#@$]*\%', Name.Variable.Instance ), # class: 'vi" #349bdd' (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), #MOD: (r'[()]', String.Symbol), include('commands'), #mod, added: include('directives'), include('ListOfKeys'), include('labels'), # include('builtInFunctions'), include('builtInVariables'), #MOD# include('keywords'), include('class_and_group_keywords'), include('userFunctions'), include('memberVariables'), (r'"', String, combined('stringescape', 'dqs')), include('numbers'), (r'[a-zA-Z_#@$][\w#@$]*', Name), (r'\\|\'', Text), (r'\`([,%`abfnrtv\-+;])', String.Escape), include('garbage'), ], 'incomment': [(r'^\s*\*/', Comment.Multiline, '#pop'), (r'[^*/]', Comment.Multiline), (r'[*/]', Comment.Multiline)], #--------------------- #Generic class: 'g' 'incontinuation': [ (r'^\s*\)', Generic, '#pop'), (r'[^)]', Generic), (r'[)]', Generic), ], #--------------------- #Name.Builtin class: 'nb' #349bdd 'directives': [ ( r'(?i)^(\s*)(global|local|static|' #Puppies|Itwasatest:) r'#AllowSameLineComments|#ClipboardTimeout|#CommentFlag|' r'#ErrorStdOut|#EscapeChar|#HotkeyInterval|#HotkeyModifierTimeout|' r'#Hotstring|#If|#IfWinActive|#IfWinExist|#IfWinNotActive|' r'#IfWinNotExist|#IncludeAgain|#Include|#InstallKeybdHook|' r'#InstallMouseHook|#KeyHistory|#LTrim|#MaxHotkeysPerInterval|' r'#MaxMem|#MaxThreads|#MaxThreadsBuffer|#MaxThreadsPerHotkey|' r'#NoEnv|#NoTrayIcon|#Persistent|#SingleInstance|#UseHook|' r'#WinActivateForce)\b', bygroups(Text, Name.Builtin)), ], #--------------------- #Keyword.Reserved class: 'kr' #2cb6ea 'commands': [ (r'(?i)(AutoTrim|BlockInput|Click|ClipWait|' r'Control|ControlClick|ControlFocus|ControlGetFocus|' r'ControlGetPos|ControlGetText|ControlGet|ControlMove|ControlSend|' r'ControlSendRaw|ControlSetText|CoordMode|Critical|' r'DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|' r'DriveSpaceFree|Edit|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|' r'EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|' r'FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|' r'FileDelete|FileGetAttrib|FileGetShortcut|FileGetSize|' r'FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|' r'FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|' r'FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|' r'FileSetTime|FormatTime|GetKeyState|GroupActivate|' r'GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|' r'GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|' r'InputBox|Input|KeyHistory|KeyWait|ListHotkeys|ListLines|' r'ListVars|Menu|MouseClickDrag|MouseClick|MouseGetPos|' r'MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|' r'PixelSearch|PostMessage|Process|Progress|Random|RegDelete|' r'RegRead|RegWrite|Reload|Repeat|RunAs|RunWait|Run|' r'SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|Send|' r'SetBatchLines|SetCapslockState|SetControlDelay|' r'SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|' r'SetMouseDelay|SetNumlockState|SetScrollLockState|' r'SetStoreCapslockMode|SetTimer|SetTitleMatchMode|' r'SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|' r'SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|' r'SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|' r'SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|' r'StringGetPos|StringLeft|StringLen|StringLower|StringMid|' r'StringReplace|StringRight|StringSplit|StringTrimLeft|' r'StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|' r'Transform|TrayTip|URLDownloadToFile|WinActivate|' r'WinActivateBottom|WinClose|WinGetActiveStats|WinGetActiveTitle|' r'WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinGet|WinHide|' r'WinKill|WinMaximize|WinMenuSelectItem|WinMinimizeAllUndo|' r'WinMinimizeAll|WinMinimize|WinMove|WinRestore|WinSetTitle|' r'WinSet|WinShow|WinWaitActive|WinWaitClose|WinWaitNotActive|' r'WinWait|' r'Abs|ACos|Asc|ASin|ATan|Ceil|Chr|Cos|DllCall|Exp|FileExist|' r'Floor|GetKeyState|IL_Add|IL_Create|IL_Destroy|InStr|IsFunc|' r'IsLabel|Ln|Log|LV_Add|LV_Delete|LV_DeleteCol|LV_GetCount|' r'LV_GetNext|LV_GetText|LV_Insert|LV_InsertCol|LV_Modify|' r'LV_ModifyCol|LV_SetImageList|Mod|NumGet|NumPut|OnMessage|' r'RegExMatch|RegExReplace|RegisterCallback|Round|SB_SetIcon|' r'SB_SetParts|SB_SetText|Sin|Sqrt|StrLen|SubStr|Tan|TV_Add|' r'TV_Delete|TV_GetChild|TV_GetCount|TV_GetNext|TV_Get|' r'TV_GetParent|TV_GetPrev|TV_GetSelection|TV_GetText|TV_Modify|' r'VarSetCapacity|WinActive|WinExist|Object|ComObjActive|' r'ComObjArray|ComObjEnwrap|ComObjUnwrap|ComObjParameter|' r'ComObjType|ComObjConnect|ComObjCreate|ComObjGet|ComObjError|' r'ComObjValue|Insert|MinIndex|MaxIndex|Remove|SetCapacity|' r'GetCapacity|GetAddress|_NewEnum|FileOpen|Read|Write|ReadLine|' r'WriteLine|ReadNumType|WriteNumType|RawRead|RawWrite|Seek|Tell|' r'Close|Next|IsObject|StrPut|StrGet|' r'Trim|LTrim|RTrim)\b', Keyword.Reserved), ], #--------------------- #Name.Variable class: 'nv' 'builtInVariables': [ (r'(?i)(A_AhkPath|A_AhkVersion|A_AppData|A_AppDataCommon|' r'A_AutoTrim|A_BatchLines|A_CaretX|A_CaretY|A_ComputerName|' r'A_ControlDelay|A_Cursor|A_DDDD|A_DDD|A_DD|A_DefaultMouseSpeed|' r'A_Desktop|A_DesktopCommon|A_DetectHiddenText|' r'A_DetectHiddenWindows|A_EndChar|A_EventInfo|A_ExitReason|' r'A_FormatFloat|A_FormatInteger|A_Gui|A_GuiEvent|A_GuiControl|' r'A_GuiControlEvent|A_GuiHeight|A_GuiWidth|A_GuiX|A_GuiY|A_Hour|' r'A_IconFile|A_IconHidden|A_IconNumber|A_IconTip|A_Index|' r'A_IPAddress1|A_IPAddress2|A_IPAddress3|A_IPAddress4|A_ISAdmin|' r'A_IsCompiled|A_IsCritical|A_IsPaused|A_IsSuspended|A_KeyDelay|' r'A_Language|A_LastError|A_LineFile|A_LineNumber|A_LoopField|' r'A_LoopFileAttrib|A_LoopFileDir|A_LoopFileExt|A_LoopFileFullPath|' r'A_LoopFileLongPath|A_LoopFileName|A_LoopFileShortName|' r'A_LoopFileShortPath|A_LoopFileSize|A_LoopFileSizeKB|' r'A_LoopFileSizeMB|A_LoopFileTimeAccessed|A_LoopFileTimeCreated|' r'A_LoopFileTimeModified|A_LoopReadLine|A_LoopRegKey|' r'A_LoopRegName|A_LoopRegSubkey|A_LoopRegTimeModified|' r'A_LoopRegType|A_MDAY|A_Min|A_MM|A_MMM|A_MMMM|A_Mon|A_MouseDelay|' r'A_MSec|A_MyDocuments|A_Now|A_NowUTC|A_NumBatchLines|A_OSType|' r'A_OSVersion|A_PriorHotkey|A_ProgramFiles|A_Programs|' r'A_ProgramsCommon|A_ScreenHeight|A_ScreenWidth|A_ScriptDir|' r'A_ScriptFullPath|A_ScriptName|A_Sec|A_Space|A_StartMenu|' r'A_StartMenuCommon|A_Startup|A_StartupCommon|A_StringCaseSense|' r'A_Tab|A_Temp|A_ThisFunc|A_ThisHotkey|A_ThisLabel|A_ThisMenu|' r'A_ThisMenuItem|A_ThisMenuItemPos|A_TickCount|A_TimeIdle|' r'A_TimeIdlePhysical|A_TimeSincePriorHotkey|A_TimeSinceThisHotkey|' r'A_TitleMatchMode|A_TitleMatchModeSpeed|A_UserName|A_WDay|' r'A_WinDelay|A_WinDir|A_WorkingDir|A_YDay|A_YEAR|A_YWeek|A_YYYY|' r'Clipboard|ClipboardAll|ComSpec|ErrorLevel|ProgramFiles|True|' r'False|A_IsUnicode|A_FileEncoding|A_OSVersion|A_PtrSize)\b', Name.Variable), ], #--------------------- #Name.Constant # 'constants': [ # (r'(?i)(True|False)\b', Name.Constant), # ], #--------------------- #Name.Label class: 'nl' #ff9bbf - light pink 'labels': [ # hotkeys and labels # technically, hotkey names are limited to named keys and buttons # (r'(^\s*)([^:\s("]+?:{1,2})', bygroups(Text, Name.Label)), # (r'(^\s*)(::[^:\s]+?::)', bygroups(Text, Name.Label)), # (r'(^\s*)([^:\s("]+?:{1})', bygroups(Text, Name.Label)), (r'(^\s*)([^:\s("]+?:[^:])', bygroups(Text, Name.Label)), ], #--------------------- #Number.Integer class: 'm' #Number.Integer.Long #Number.Float #Number.Hex #Number.Oct 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'\d+[eE][+-]?[0-9]+', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer)], #--------------------- #String.Escape class: 'se' 'stringescape': [ (r'\"\"|\`([,%`abfnrtv])', String.Escape), ], #--------------------- #String class: 's' #fff7ab - light yellow 'strings': [ # MOD # Original was eating any `n which existed # After the begging of a String's opening " ch # Added the ` to the "not" group # Now escapes are painted!!!!!!! (r'[^"\n`]+', String), ], #--------------------- #String class: 's' 'dqs': [(r'"', String, '#pop'), include('strings')], #--------------------- #Text 'garbage': [ (r'[^\S\n]', Text), # (r'.', Text), # no cheating ], #=========================================== #Mod# below this line: # # added (or moved) # #=========================================== #--------------------- #Keyword class: 'k' #efeb66 - yellow #Keyword #fff385 - yellow #Keyword #ffeb36 - yellow * 'keywords': [ (r'(?i)(class|Return|Break|Catch|Continue|Else|Finally|For|Gosub|Goto|' r'If|IfEqual|IfExist|IfGreaterOrEqual|IfGreater|' r'IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|' r'IfInString|IfNotInString|' r'IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist' r'Loop|Try|While)\b', Keyword), ], #--------------------- #Name.Function class: 'nf' 'userFunctions': [ # matches `thing`() and `things`(and,`stuff`(),areneat) (r'(\b)[\w]+(?=\()', Name.Function) ], #--------------------- #Name.Variable.Class class: 'vc' #34cfab - teal green #Name.Variable.Class class: 'vc' #4fd5b0 - teal green 'memberVariables': [ # matches objecct.`_member` or `_memberVariable` # does not match %dereference_string%_restOfVarName # (r'(\.|\b)_[\w]+', Name.Variable.Class) (r'(\.|\b)(?<!\%)_[\w]+', Name.Variable.Class) ], #--------------------- #Name.Namespace class: 'nn' #ae81ff - purple 'class_and_group_keywords': [ (r'(?i)(__New|__Get|__Set|__Delete|' r'this|super|base|extends|' r'ahk_class|ahk_exe|ahk_group|ahk_id|ahk_pid|' r'guiclose|guicontextmenu|guidropfiles|' r'guiescape|guisize|' r'InsertAt|RemoveAt|Push|Pop|Delete|' r'MinIndex|MaxIndex|Length|Count|SetCapacity|' r'GetCapacity|GetAddress|_NewEnum|' r'HasKey|Clone|Insert|Remove)\b', Name.Namespace), ], #--------------------- #Keyword.Pseudo class: 'kp' #2cb6ea # (kp: because it's close to "keypad") 'ListOfKeys': [(r'(?i)(lbutton|mbutton|rbutton|' r'xbutton1|xbutton2|wheelup|wheeldown|wheelleft|wheelright|' r'alt|altdown|altup|appskey|backspace|blind|' r'browser_back|browser_favorites|browser_forward|browser_home|' r'browser_refresh|browser_search|browser_stop|' r'bs|capslock|click|control|ctrl|ctrlbreak|ctrldown|ctrlup|' r'del|delete|down|end|enter|esc|escape|' r'lalt|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|' r'rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|' r'scrolllock|shift|shiftdown|shiftup|space|tab|up|' r'home|ins|insert|' r'f1|f2|f3|f4|f5|f6|f7|f8|f9|f10|f11|f12|' r'f13|f14|f15|f16|f17|f18|f19|f20|f21|f22|f23|f24|' r'joy1|joy2|joy3|joy4|joy5|joy6|joy7|joy8|joy9|' r'joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|' r'joy19|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|' r'joy28|joy29|joy30|joy31|joy32|' r'joyaxes|joybuttons|joyinfo|joyname|joypov' r'joyr|joyu|joyv|joyx|joyy|joyz|' r'launch_app1|launch_app2|launch_mail|launch_media|' r'media_next|media_play_pause|media_prev|media_stop|' r'numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|' r'numpad6|numpad7|numpad8|numpad9|' r'numpadadd|numpadclear|numpaddel|numpaddiv|' r'numpaddot|numpaddown|numpadend|numpadenter|' r'numpadhome|numpadins|numpadleft|numpadmult|' r'numpadpgdn|numpadpgup|numpadright|numpadsub|' r'numpadup|pause|pgdn|pgup|printscreen|ralt|raw|' r'volume_down|volume_mute|volume_up)\b', Keyword.Pseudo)], #------------------------------------------------- #mod, moved this into commands / Name.Builtin #------------------------------------------------- #neutered, going to recast to encapsulate thing.functioncall() and func() #------------------------------------------------- # 'builtInFunctions': [ # (r'(?i)()\b', # Name.Function), # ], #------------------------------------------------- }
class ZhpyLexer(RegexLexer): """ for zhpy <zhpy.googlecode.com> source code """ name = "Zhpy" aliases = ['zhpy'] filenames = ['*.twpy', '*.cnpy', '*.py'] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)), #docstring (r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)), #docstring (r'[^\S\n]+', Text), (r'#.*$', Comment), #comment (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)(\s+)', bygroups(Keyword, Text), 'funcname'), (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), (r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'), (r'(import)(\s+)', bygroups(Keyword, Text), 'import'), include('builtins'), include('backtick'), ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), ('[uU]?"""', String, combined('stringescape', 'tdqs')), ("[uU]?'''", String, combined('stringescape', 'tsqs')), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (r'(assert|break|continue|del|elif|else|except|exec|' r'finally|for|global|if|lambda|pass|print|raise|' r'return|try|while|yield|as|with|' r'印出|輸入)\b', Keyword), ], 'builtins': [ (r'(?<!\.)(__import__|abs|apply|basestring|bool|buffer|callable|' r'chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|' r'divmod|enumerate|eval|execfile|exit|file|filter|float|getattr|' r'globals|hasattr|hash|hex|id|input|int|intern|isinstance|' r'issubclass|iter|len|list|locals|long|map|max|min|object|oct|' r'open|ord|pow|property|range|raw_input|reduce|reload|repr|' r'round|setattr|slice|staticmethod|str|sum|super|tuple|type|' r'unichr|unicode|vars|xrange|zip)\b', Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True' r')\b', Name.Builtin.Pseudo), (r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|' r'BaseException|DeprecationWarning|EOFError|EnvironmentError|' r'Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|' r'ImportError|ImportWarning|IndentationError|IndexError|KeyError|' r'KeyboardInterrupt|LookupError|MemoryError|NameError|' r'NotImplemented|NotImplementedError|OSError|OverflowError|' r'OverflowWarning|PendingDeprecationWarning|ReferenceError|' r'RuntimeError|RuntimeWarning|StandardError|StopIteration|' r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|' r'TypeError|UnboundLocalError|UnicodeDecodeError|' r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|' r'UnicodeWarning|UserWarning|ValueError|Warning|ZeroDivisionError' r')\b', Name.Exception), ], 'numbers': [ (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer) ], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[a-zA-Z0-9_]+', Name.Decorator), ('[a-zA-Z_][a-zA-Z0-9_u"\u0080-\ufe01]*', Name), ], 'funcname': [ ('[a-zA-Z_][a-zA-Z0-9_\u0080-\ufe01]*', Name.Function, '#pop') ], 'classname': [ ('[a-zA-Z_][a-zA-Z0-9_\u0080-\ufe01]*', Name.Class, '#pop') ], 'import': [ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), (r'[a-zA-Z_][a-zA-Z0-9_.\u0080-\ufe01]*', Name.Namespace), (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), (r'', Text, '#pop') # all else: go back ], 'fromimport': [ (r'(\s+)(import)\b', bygroups(Text, Keyword), '#pop'), (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace), ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9\u0080-\ufe01]{8}|x[a-fA-F0-9\u0080-\ufe01]{2}|[0-7]{1,3})', String.Escape) ], 'strings': [ (r'%(\([a-zA-Z0-9\u0080-\ufe01]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [ (r'\n', String) ], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings include('strings') ], 'tdqs': [ (r'"""', String, '#pop'), include('strings'), include('nl') ], 'tsqs': [ (r"'''", String, '#pop'), include('strings'), include('nl') ], } def analyse_text(text): return shebang_matches(text, r'pythonw?(2\.\d)?')
class AutoItLexer(RegexLexer): """ For `AutoIt <http://www.autoitscript.com/site/autoit/>`_ files. AutoIt is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting .. versionadded:: 1.6 """ name = 'AutoIt' aliases = ['autoit'] filenames = ['*.au3'] mimetypes = ['text/x-autoit'] # Keywords, functions, macros from au3.keywords.properties # which can be found in AutoIt installed directory, e.g. # c:\Program Files (x86)\AutoIt3\SciTE\au3.keywords.properties keywords = """\ #include-once #include #endregion #forcedef #forceref #region and byref case continueloop dim do else elseif endfunc endif endselect exit exitloop for func global if local next not or return select step then to until wend while exit""".split() functions = """\ abs acos adlibregister adlibunregister asc ascw asin assign atan autoitsetoption autoitwingettitle autoitwinsettitle beep binary binarylen binarymid binarytostring bitand bitnot bitor bitrotate bitshift bitxor blockinput break call cdtray ceiling chr chrw clipget clipput consoleread consolewrite consolewriteerror controlclick controlcommand controldisable controlenable controlfocus controlgetfocus controlgethandle controlgetpos controlgettext controlhide controllistview controlmove controlsend controlsettext controlshow controltreeview cos dec dircopy dircreate dirgetsize dirmove dirremove dllcall dllcalladdress dllcallbackfree dllcallbackgetptr dllcallbackregister dllclose dllopen dllstructcreate dllstructgetdata dllstructgetptr dllstructgetsize dllstructsetdata drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype drivemapadd drivemapdel drivemapget drivesetlabel drivespacefree drivespacetotal drivestatus envget envset envupdate eval execute exp filechangedir fileclose filecopy filecreatentfslink filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile fileflush filegetattrib filegetencoding filegetlongname filegetpos filegetshortcut filegetshortname filegetsize filegettime filegetversion fileinstall filemove fileopen fileopendialog fileread filereadline filerecycle filerecycleempty filesavedialog fileselectfolder filesetattrib filesetpos filesettime filewrite filewriteline floor ftpsetproxy guicreate guictrlcreateavi guictrlcreatebutton guictrlcreatecheckbox guictrlcreatecombo guictrlcreatecontextmenu guictrlcreatedate guictrlcreatedummy guictrlcreateedit guictrlcreategraphic guictrlcreategroup guictrlcreateicon guictrlcreateinput guictrlcreatelabel guictrlcreatelist guictrlcreatelistview guictrlcreatelistviewitem guictrlcreatemenu guictrlcreatemenuitem guictrlcreatemonthcal guictrlcreateobj guictrlcreatepic guictrlcreateprogress guictrlcreateradio guictrlcreateslider guictrlcreatetab guictrlcreatetabitem guictrlcreatetreeview guictrlcreatetreeviewitem guictrlcreateupdown guictrldelete guictrlgethandle guictrlgetstate guictrlread guictrlrecvmsg guictrlregisterlistviewsort guictrlsendmsg guictrlsendtodummy guictrlsetbkcolor guictrlsetcolor guictrlsetcursor guictrlsetdata guictrlsetdefbkcolor guictrlsetdefcolor guictrlsetfont guictrlsetgraphic guictrlsetimage guictrlsetlimit guictrlsetonevent guictrlsetpos guictrlsetresizing guictrlsetstate guictrlsetstyle guictrlsettip guidelete guigetcursorinfo guigetmsg guigetstyle guiregistermsg guisetaccelerators guisetbkcolor guisetcoord guisetcursor guisetfont guisethelp guiseticon guisetonevent guisetstate guisetstyle guistartgroup guiswitch hex hotkeyset httpsetproxy httpsetuseragent hwnd inetclose inetget inetgetinfo inetgetsize inetread inidelete iniread inireadsection inireadsectionnames inirenamesection iniwrite iniwritesection inputbox int isadmin isarray isbinary isbool isdeclared isdllstruct isfloat ishwnd isint iskeyword isnumber isobj isptr isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox number objcreate objcreateinterface objevent objevent objget objname onautoitexitregister onautoitexitunregister opt ping pixelchecksum pixelgetcolor pixelsearch pluginclose pluginopen processclose processexists processgetstats processlist processsetpriority processwait processwaitclose progressoff progresson progressset ptr random regdelete regenumkey regenumval regread regwrite round run runas runaswait runwait send sendkeepactive seterror setextended shellexecute shellexecutewait shutdown sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton sqrt srandom statusbargettext stderrread stdinwrite stdioclose stdoutread string stringaddcr stringcompare stringformat stringfromasciiarray stringinstr stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint stringislower stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid stringregexp stringregexpreplace stringreplace stringright stringsplit stringstripcr stringstripws stringtoasciiarray stringtobinary stringtrimleft stringtrimright stringupper tan tcpaccept tcpclosesocket tcpconnect tcplisten tcpnametoip tcprecv tcpsend tcpshutdown tcpstartup timerdiff timerinit tooltip traycreateitem traycreatemenu traygetmsg trayitemdelete trayitemgethandle trayitemgetstate trayitemgettext trayitemsetonevent trayitemsetstate trayitemsettext traysetclick trayseticon traysetonevent traysetpauseicon traysetstate traysettooltip traytip ubound udpbind udpclosesocket udpopen udprecv udpsend udpshutdown udpstartup vargettype winactivate winactive winclose winexists winflash wingetcaretpos wingetclasslist wingetclientsize wingethandle wingetpos wingetprocess wingetstate wingettext wingettitle winkill winlist winmenuselectitem winminimizeall winminimizeallundo winmove winsetontop winsetstate winsettitle winsettrans winwait winwaitactive winwaitclose winwaitnotactive""".split() macros = """\ @appdatacommondir @appdatadir @autoitexe @autoitpid @autoitversion @autoitx64 @com_eventobj @commonfilesdir @compiled @computername @comspec @cpuarch @cr @crlf @desktopcommondir @desktopdepth @desktopdir @desktopheight @desktoprefresh @desktopwidth @documentscommondir @error @exitcode @exitmethod @extended @favoritescommondir @favoritesdir @gui_ctrlhandle @gui_ctrlid @gui_dragfile @gui_dragid @gui_dropid @gui_winhandle @homedrive @homepath @homeshare @hotkeypressed @hour @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @kblayout @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @msec @muilang @mydocumentsdir @numparams @osarch @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir @programscommondir @programsdir @scriptdir @scriptfullpath @scriptlinenumber @scriptname @sec @startmenucommondir @startmenudir @startupcommondir @startupdir @sw_disable @sw_enable @sw_hide @sw_lock @sw_maximize @sw_minimize @sw_restore @sw_show @sw_showdefault @sw_showmaximized @sw_showminimized @sw_showminnoactive @sw_showna @sw_shownoactivate @sw_shownormal @sw_unlock @systemdir @tab @tempdir @tray_id @trayiconflashing @trayiconvisible @username @userprofiledir @wday @windowsdir @workingdir @yday @year""".split() tokens = { 'root': [ (r';.*\n', Comment.Single), (r'(#comments-start|#cs)(.|\n)*?(#comments-end|#ce)', Comment.Multiline), (r'[\[\]{}(),;]', Punctuation), (r'(and|or|not)\b', Operator.Word), (r'[$|@][a-zA-Z_]\w*', Name.Variable), (r'!=|==|:=|\.=|<<|>>|[-~+/*%=<>&^|?:!.]', Operator), include('commands'), include('labels'), include('builtInFunctions'), include('builtInMarcros'), (r'"', String, combined('stringescape', 'dqs')), include('numbers'), (r'[a-zA-Z_#@$][\w#@$]*', Name), (r'\\|\'', Text), (r'\`([,%`abfnrtv\-+;])', String.Escape), (r'_\n', Text), # Line continuation include('garbage'), ], 'commands': [ (r'(?i)(\s*)(%s)\b' % '|'.join(keywords), bygroups(Text, Name.Builtin)), ], 'builtInFunctions': [ (r'(?i)(%s)\b' % '|'.join(functions), Name.Function), ], 'builtInMarcros': [ (r'(?i)(%s)\b' % '|'.join(macros), Name.Variable.Global), ], 'labels': [ # sendkeys (r'(^\s*)(\{\S+?\})', bygroups(Text, Name.Label)), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'\d+[eE][+-]?[0-9]+', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer)], 'stringescape': [ (r'\"\"|\`([,%`abfnrtv])', String.Escape), ], 'strings': [ (r'[^"\n]+', String), ], 'dqs': [(r'"', String, '#pop'), include('strings')], 'garbage': [ (r'[^\S\n]', Text), ], }
class LuaLexer(RegexLexer): """ For `Lua <http://www.lua.org>`_ source code. Additional options accepted: `func_name_highlighting` If given and ``True``, highlight builtin function names (default: ``True``). `disabled_modules` If given, must be a list of module names whose function names should not be highlighted. By default all modules are highlighted. To get a list of allowed modules have a look into the `_luabuiltins` module: .. sourcecode:: pycon >>> from pygments.lexers._luabuiltins import MODULES >>> MODULES.keys() ['string', 'coroutine', 'modules', 'io', 'basic', ...] """ name = 'lua_tarantool' aliases = ['lua_tarantool'] filenames = ['*.lua', '*.wlua'] mimetypes = ['text/x-lua', 'application/x-lua'] tokens = { 'root': [ # lua allows a file to start with a shebang (r'#!(.*?)$', Comment.Preproc), (r'', Text, 'base'), ], 'base': [ (r'(?s)--\[(=*)\[.*?\]\1\]', Comment.Multiline), ('--.*$', Comment.Single), (r'(?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?', Number.Float), (r'(?i)\d+e[+-]?\d+', Number.Float), ('(?i)0x[0-9a-f]*', Number.Hex), (r'\d+', Number.Integer), (r'\n', Text), (r'[^\S\n]', Text), # multiline strings (r'(?s)\[(=*)\[.*?\]\1\]', String), (r'(==|~=|<=|>=|\.\.\.|\.\.|[=+\-*/%^<>#])', Operator), (r'[\[\]\{\}\(\)\.,:;!]', Punctuation), (r'(and|or|not)\b', Operator.Word), ('(break|do|else|elseif|end|for|if|in|repeat|return|then|until|' r'while)\b', Keyword), (r'(local)\b', Keyword.Declaration), (r'(true|false|nil)\b', Keyword.Constant), (r'(function)\b', Keyword, 'funcname'), (r'[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?', Name), ("'", String.Single, combined('stringescape', 'sqs')), ('"', String.Double, combined('stringescape', 'dqs')) ], 'funcname': [ (r'\s+', Text), ('(?:([A-Za-z_][A-Za-z0-9_]*)(\.))?([A-Za-z_][A-Za-z0-9_]*)', bygroups(Name.Class, Punctuation, Name.Function), '#pop'), # inline function ('\(', Punctuation, '#pop'), ], # if I understand correctly, every character is valid in a lua string, # so this state is only for later corrections 'string': [ ('.', String) ], 'stringescape': [ (r'''\\([abfnrtv\\"']|\d{1,3})''', String.Escape) ], 'sqs': [ ("'", String, '#pop'), include('string') ], 'dqs': [ ('"', String, '#pop'), include('string') ] } def __init__(self, **options): self.func_name_highlighting = get_bool_opt( options, 'func_name_highlighting', True) self.disabled_modules = get_list_opt(options, 'disabled_modules', []) self._functions = set() if self.func_name_highlighting: from pygments.lexers._lua_builtins import MODULES for mod, func in MODULES.iteritems(): if mod not in self.disabled_modules: self._functions.update(func) RegexLexer.__init__(self, **options) def get_tokens_unprocessed(self, text): for index, token, value in \ RegexLexer.get_tokens_unprocessed(self, text): if token is Name: if value in self._functions: yield index, Name.Builtin, value continue elif '.' in value: a, b = value.split('.') yield index, Name, a yield index + len(a), Punctuation, u'.' yield index + len(a) + 1, Name, b continue yield index, token, value
class CythonLexer(RegexLexer): """ For `Cython <http://cython.org>`_ source code. """ name = 'Cython' aliases = ['cython', 'pyx'] filenames = ['*.pyx', '*.pxd', '*.pxi'] mimetypes = ['text/x-cython', 'application/x-cython'] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)("""(?:.|\n)*?""")', bygroups(Text, String.Doc)), (r"^(\s*)('''(?:.|\n)*?''')", bygroups(Text, String.Doc)), (r'[^\S\n]+', Text), (r'#.*$', Comment), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'(<)([a-zA-Z0-9.?]+)(>)', bygroups(Punctuation, Keyword.Type, Punctuation)), (r'!=|==|<<|>>|[-~+/*%=<>&^|.?]', Operator), (r'(from)(\d+)(<=)(\s+)(<)(\d+)(:)', bygroups(Keyword, Number.Integer, Operator, Name, Operator, Name, Punctuation)), include('keywords'), (r'(def|property)(\s+)', bygroups(Keyword, Text), 'funcname'), (r'(cp?def)(\s+)', bygroups(Keyword, Text), 'cdef'), (r'(class|struct)(\s+)', bygroups(Keyword, Text), 'classname'), (r'(from)(\s+)', bygroups(Keyword, Text), 'fromimport'), (r'(c?import)(\s+)', bygroups(Keyword, Text), 'import'), include('builtins'), include('backtick'), ('(?:[rR]|[uU][rR]|[rR][uU])"""', String, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", String, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', String, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", String, 'sqs'), ('[uU]?"""', String, combined('stringescape', 'tdqs')), ("[uU]?'''", String, combined('stringescape', 'tsqs')), ('[uU]?"', String, combined('stringescape', 'dqs')), ("[uU]?'", String, combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (r'(assert|break|by|continue|ctypedef|del|elif|else|except\??|exec|' r'finally|for|gil|global|if|include|lambda|nogil|pass|print|raise|' r'return|try|while|yield|as|with)\b', Keyword), (r'(DEF|IF|ELIF|ELSE)\b', Comment.Preproc), ], 'builtins': [ (r'(?<!\.)(__import__|abs|all|any|apply|basestring|bin|bool|buffer|' r'bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|' r'complex|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|' r'file|filter|float|frozenset|getattr|globals|hasattr|hash|hex|id|' r'input|int|intern|isinstance|issubclass|iter|len|list|locals|' r'long|map|max|min|next|object|oct|open|ord|pow|property|range|' r'raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|' r'sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|' r'vars|xrange|zip)\b', Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|NULL' r')\b', Name.Builtin.Pseudo), (r'(?<!\.)(ArithmeticError|AssertionError|AttributeError|' r'BaseException|DeprecationWarning|EOFError|EnvironmentError|' r'Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|' r'ImportError|ImportWarning|IndentationError|IndexError|KeyError|' r'KeyboardInterrupt|LookupError|MemoryError|NameError|' r'NotImplemented|NotImplementedError|OSError|OverflowError|' r'OverflowWarning|PendingDeprecationWarning|ReferenceError|' r'RuntimeError|RuntimeWarning|StandardError|StopIteration|' r'SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|' r'TypeError|UnboundLocalError|UnicodeDecodeError|' r'UnicodeEncodeError|UnicodeError|UnicodeTranslateError|' r'UnicodeWarning|UserWarning|ValueError|Warning|ZeroDivisionError' r')\b', Name.Exception), ], 'numbers': [ (r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float), (r'0\d+', Number.Oct), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+', Number.Integer) ], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[a-zA-Z0-9_]+', Name.Decorator), ('[a-zA-Z_][a-zA-Z0-9_]*', Name), ], 'funcname': [ ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop') ], 'cdef': [ (r'(public|readonly|extern|api|inline)\b', Keyword.Reserved), (r'(struct|enum|union|class)\b', Keyword), (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(?=[(:#=]|$)', bygroups(Name.Function, Text), '#pop'), (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(,)', bygroups(Name.Function, Text, Punctuation)), (r'from\b', Keyword, '#pop'), (r'as\b', Keyword), (r':', Punctuation, '#pop'), (r'(?=["\'])', Text, '#pop'), (r'[a-zA-Z_][a-zA-Z0-9_]*', Keyword.Type), (r'.', Text), ], 'classname': [ ('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop') ], 'import': [ (r'(\s+)(as)(\s+)', bygroups(Text, Keyword, Text)), (r'[a-zA-Z_][a-zA-Z0-9_.]*', Name.Namespace), (r'(\s*)(,)(\s*)', bygroups(Text, Operator, Text)), (r'', Text, '#pop') # all else: go back ], 'fromimport': [ (r'(\s+)(c?import)\b', bygroups(Text, Keyword), '#pop'), (r'[a-zA-Z_.][a-zA-Z0-9_.]*', Name.Namespace), # ``cdef foo from "header"``, or ``for foo from 0 < i < 10`` (r'', Text, '#pop'), ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) ], 'strings': [ (r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [ (r'\n', String) ], 'dqs': [ (r'"', String, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here again for raw strings include('strings') ], 'sqs': [ (r"'", String, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here again for raw strings include('strings') ], 'tdqs': [ (r'"""', String, '#pop'), include('strings'), include('nl') ], 'tsqs': [ (r"'''", String, '#pop'), include('strings'), include('nl') ], } ##TODO: fix this, as shebang lines don't make sense for cython. def analyse_text(text): return shebang_matches(text, r'pythonw?(2\.\d)?')
class GDScriptLexer(RegexLexer): """ For `Godot source code <https://www.godotengine.org>`_ source code. """ name = 'GDScript' aliases = ['gdscript', 'gd'] filenames = ['*.gd'] mimetypes = ['text/x-gdscript', 'application/x-gdscript'] def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsux%]', String.Interpol), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r'%', ttype), # newlines are an error (use "nl" state) ] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc)), (r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc)), (r'[^\S\n]+', Text), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]', Operator), include('keywords'), (r'(func)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), include('builtins'), ('([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), 'tdqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(''')", bygroups(String.Affix, String.Single), 'tsqs'), ('([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), 'dqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(')", bygroups(String.Affix, String.Single), 'sqs'), ('([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ("([uUbB]?)(''')", bygroups(String.Affix, String.Single), combined('stringescape', 'tsqs')), ('([uUbB]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), ("([uUbB]?)(')", bygroups(String.Affix, String.Single), combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(( 'and', 'in', 'not', 'or', 'as', 'breakpoint', 'class', 'class_name', 'extends', 'is', 'func', 'setget', 'signal', 'tool', 'const', 'enum', 'export', 'onready', 'static', 'var', 'break', 'continue', 'if', 'elif', 'else', 'for', 'pass', 'return', 'match', 'while', 'remote', 'master', 'puppet', 'remotesync', 'mastersync', 'puppetsync'), suffix=r'\b'), Keyword), ], 'builtins': [ (words(( 'Color8', 'ColorN', 'abs', 'acos', 'asin', 'assert', 'atan', 'atan2', 'bytes2var', 'ceil', 'char', 'clamp', 'convert', 'cos', 'cosh', 'db2linear', 'decimals', 'dectime', 'deg2rad', 'dict2inst', 'ease', 'exp', 'floor', 'fmod', 'fposmod', 'funcref', 'hash', 'inst2dict', 'instance_from_id', 'is_inf', 'is_nan', 'lerp', 'linear2db', 'load', 'log', 'max', 'min', 'nearest_po2', 'pow', 'preload', 'print', 'print_stack', 'printerr', 'printraw', 'prints', 'printt', 'rad2deg', 'rand_range', 'rand_seed', 'randf', 'randi', 'randomize', 'range', 'round', 'seed', 'sign', 'sin', 'sinh', 'sqrt', 'stepify', 'str', 'str2var', 'tan', 'tan', 'tanh', 'type_exist', 'typeof', 'var2bytes', 'var2str', 'weakref', 'yield'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'((?<!\.)(self|false|true)|(PI|TAU|NAN|INF)' r')\b', Name.Builtin.Pseudo), (words(( 'bool', 'int', 'float', 'String', 'NodePath' 'Vector2', 'Rect2', 'Transform2D', 'Vector3', 'Rect3', 'Plane', 'Quat', 'Basis', 'Transform', 'Color', "RID", 'Object', 'NodePath', 'Dictionary', 'Array', 'PoolByteArray', 'PoolIntArray', 'PoolRealArray', 'PoolStringArray', 'PoolVector2Array', 'PoolVector3Array', 'PoolColorArray', 'null', ), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin.Type), ], 'numbers': [ (r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+j?', Number.Integer) ], 'name': [ ('[a-zA-Z_]\w*', Name), ], 'funcname': [ ('[a-zA-Z_]\w*', Name.Function, '#pop'), default('#pop'), ], 'classname': [ ('[a-zA-Z_]\w*', Name.Class, '#pop') ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) ], 'strings-single': innerstring_rules(String.Single), 'strings-double': innerstring_rules(String.Double), 'dqs': [ (r'"', String.Double, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings-double') ], 'sqs': [ (r"'", String.Single, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings-single') ], 'tdqs': [ (r'"""', String.Double, '#pop'), include('strings-double'), (r'\n', String.Double) ], 'tsqs': [ (r"'''", String.Single, '#pop'), include('strings-single'), (r'\n', String.Single) ], }
class Python2Lexer(RegexLexer): """ For `Python 2.x <http://www.python.org>`_ source code. .. versionchanged:: 2.5 This class has been renamed from ``PythonLexer``. ``PythonLexer`` now refers to the Python 3 variant. File name patterns like ``*.py`` have been moved to Python 3 as well. """ name = 'Python 2.x' aliases = ['python2', 'py2'] filenames = [] # now taken over by PythonLexer (3.x) mimetypes = ['text/x-python2', 'application/x-python2'] def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsux%]', String.Interpol), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r'%', ttype), # newlines are an error (use "nl" state) ] tokens = { 'root': [ (r'\n', Text), (r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Text, String.Affix, String.Doc)), (r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Text, String.Affix, String.Doc)), (r'[^\S\n]+', Text), (r'\A#!.+$', Comment.Hashbang), (r'#.*$', Comment.Single), (r'[]{}:(),;[]', Punctuation), (r'\\\n', Text), (r'\\', Text), (r'(in|is|and|or|not)\b', Operator.Word), (r'!=|==|<<|>>|[-~+/*%=<>&^|.]', Operator), include('keywords'), (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'), (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'), (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'fromimport'), (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text), 'import'), include('builtins'), include('magicfuncs'), include('magicvars'), include('backtick'), ('([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), 'tdqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(''')", bygroups(String.Affix, String.Single), 'tsqs'), ('([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), 'dqs'), ("([rR]|[uUbB][rR]|[rR][uUbB])(')", bygroups(String.Affix, String.Single), 'sqs'), ('([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined('stringescape', 'tdqs')), ("([uUbB]?)(''')", bygroups(String.Affix, String.Single), combined('stringescape', 'tsqs')), ('([uUbB]?)(")', bygroups(String.Affix, String.Double), combined('stringescape', 'dqs')), ("([uUbB]?)(')", bygroups(String.Affix, String.Single), combined('stringescape', 'sqs')), include('name'), include('numbers'), ], 'keywords': [ (words(('assert', 'break', 'continue', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'global', 'if', 'lambda', 'pass', 'print', 'raise', 'return', 'try', 'while', 'yield', 'yield from', 'as', 'with'), suffix=r'\b'), Keyword), ], 'builtins': [ (words( ('__import__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', 'long', 'map', 'max', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Builtin), (r'(?<!\.)(self|None|Ellipsis|NotImplemented|False|True|cls' r')\b', Name.Builtin.Pseudo), (words( ('ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning', 'PendingDeprecationWarning', 'RecursionError', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'VMSError', 'Warning', 'WindowsError', 'ZeroDivisionError'), prefix=r'(?<!\.)', suffix=r'\b'), Name.Exception), ], 'magicfuncs': [ (words( ('__abs__', '__add__', '__and__', '__call__', '__cmp__', '__coerce__', '__complex__', '__contains__', '__del__', '__delattr__', '__delete__', '__delitem__', '__delslice__', '__div__', '__divmod__', '__enter__', '__eq__', '__exit__', '__float__', '__floordiv__', '__ge__', '__get__', '__getattr__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__hex__', '__iadd__', '__iand__', '__idiv__', '__ifloordiv__', '__ilshift__', '__imod__', '__imul__', '__index__', '__init__', '__instancecheck__', '__int__', '__invert__', '__iop__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__long__', '__lshift__', '__lt__', '__missing__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__nonzero__', '__oct__', '__op__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rcmp__', '__rdiv__', '__rdivmod__', '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__rop__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__set__', '__setattr__', '__setitem__', '__setslice__', '__str__', '__sub__', '__subclasscheck__', '__truediv__', '__unicode__', '__xor__'), suffix=r'\b'), Name.Function.Magic), ], 'magicvars': [ (words( ('__bases__', '__class__', '__closure__', '__code__', '__defaults__', '__dict__', '__doc__', '__file__', '__func__', '__globals__', '__metaclass__', '__module__', '__mro__', '__name__', '__self__', '__slots__', '__weakref__'), suffix=r'\b'), Name.Variable.Magic), ], 'numbers': [(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?', Number.Float), (r'\d+[eE][+-]?[0-9]+j?', Number.Float), (r'0[0-7]+j?', Number.Oct), (r'0[bB][01]+', Number.Bin), (r'0[xX][a-fA-F0-9]+', Number.Hex), (r'\d+L', Number.Integer.Long), (r'\d+j?', Number.Integer)], 'backtick': [ ('`.*?`', String.Backtick), ], 'name': [ (r'@[\w.]+', Name.Decorator), (r'[a-zA-Z_]\w*', Name), ], 'funcname': [ include('magicfuncs'), (r'[a-zA-Z_]\w*', Name.Function, '#pop'), default('#pop'), ], 'classname': [(r'[a-zA-Z_]\w*', Name.Class, '#pop')], 'import': [ (r'(?:[ \t]|\\\n)+', Text), (r'as\b', Keyword.Namespace), (r',', Operator), (r'[a-zA-Z_][\w.]*', Name.Namespace), default('#pop') # all else: go back ], 'fromimport': [ (r'(?:[ \t]|\\\n)+', Text), (r'import\b', Keyword.Namespace, '#pop'), # if None occurs here, it's "raise x from None", since None can # never be a module name (r'None\b', Name.Builtin.Pseudo, '#pop'), # sadly, in "raise x from y" y will be highlighted as namespace too (r'[a-zA-Z_.][\w.]*', Name.Namespace), # anything else here also means "raise x from y" and is therefore # not an error default('#pop'), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'strings-single': innerstring_rules(String.Single), 'strings-double': innerstring_rules(String.Double), 'dqs': [ (r'"', String.Double, '#pop'), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include('strings-double') ], 'sqs': [ (r"'", String.Single, '#pop'), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include('strings-single') ], 'tdqs': [(r'"""', String.Double, '#pop'), include('strings-double'), (r'\n', String.Double)], 'tsqs': [(r"'''", String.Single, '#pop'), include('strings-single'), (r'\n', String.Single)], } def analyse_text(text): return shebang_matches(text, r'pythonw?2(\.\d)?') or \ 'import ' in text[:1000]
class HttpPromptLexer(RegexLexer): name = 'HttpPrompt' aliases = ['http-prompt'] filenames = ['*.http-prompt'] tokens = { 'root': [ (r'\s+', Text), (r'(cd)(\s*)', bygroups(Keyword, Text), 'cd'), (r'(rm)(\s*)', bygroups(Keyword, Text), 'rm_option'), (r'(httpie|curl)(\s*)', bygroups(Keyword, Text), 'action'), (words(HTTP_METHODS, prefix='(?i)', suffix='(?!\S)(\s*)'), bygroups(Keyword, Text), combined('redir_out', 'urlpath')), (r'(exit)(\s*)', bygroups(Keyword, Text), 'end'), (r'(help)(\s)*', bygroups(Keyword, Text), 'end'), (r'(env)(\s*)', bygroups(Keyword, Text), combined('redir_out', 'pipe')), (r'(source)(\s*)', bygroups(Keyword, Text), 'file_path'), (r'(exec)(\s*)', bygroups(Keyword, Text), 'file_path'), (r'', Text, 'concat_mut') ], 'cd': string_rules('end'), 'rm_option': [ (r'(\-(?:h|o|b|q))(\s*)', bygroups(Name, Text), 'rm_name'), (r'(\*)(\s*)', bygroups(Name, Text), 'end') ], 'rm_name': string_rules('end'), 'shell_command': [ (r'(`)([^`]*)(`)', bygroups(Text, using(BashLexer), Text)), ], 'pipe': [ (r'(\s*)(\|)(.*)', bygroups(Text, Operator, using(BashLexer))), ], 'concat_mut': [ (r'$', Text, 'end'), (r'\s+', Text), # Flag options, such as (--form) and (--json) (words(FLAG_OPTIONS, suffix=r'\b'), Name, 'concat_mut'), # Options with values, such as (--style=default) and (--pretty all) (words(VALUE_OPTIONS, suffix=r'\b'), Name, combined('shell_command', 'option_op')), include('shell_command'), # Unquoted or value-quoted request mutation, # such as (name="John Doe") and (name=John\ Doe) (r'((?:[^\s\'"\\=:]|(?:\\.))*)(:=|:|==|=)', bygroups(Name, Operator), combined('shell_command', 'unquoted_mut')), # Full single-quoted request mutation, such as ('name=John Doe') (r"(')((?:[^\r\n'\\=:]|(?:\\.))+)(:=|:|==|=)", bygroups(Text, Name, Operator), combined('shell_command', 'squoted_mut')), # Full double-quoted request mutation, such as ("name=John Doe") (r'(")((?:[^\r\n"\\=:]|(?:\\.))+)(:=|:|==|=)', bygroups(Text, Name, Operator), combined('shell_command', 'dquoted_mut')) ], 'option_op': [ (r'(\s+|=)', Operator, 'option_value'), ], 'option_value': string_rules('#pop:2'), 'file_path': string_rules('end'), 'redir_out': [ (r'(?i)(>>?)(\s*)', bygroups(Operator, Text), 'file_path') ], 'unquoted_mut': string_rules('#pop'), 'squoted_mut': [ (r"((?:[^\r\n'\\]|(?:\\.))+)(')", bygroups(String, Text), '#pop'), (r"([^\r\n'\\]|(\\.))+", String, '#pop') ], 'dquoted_mut': [ (r'((?:[^\r\n"\\]|(?:\\.))+)(")', bygroups(String, Text), '#pop'), (r'([^\r\n"\\]|(\\.))+', String, '#pop') ], 'action': [ (words(HTTP_METHODS, prefix='(?i)', suffix='(\s*)'), bygroups(Keyword, Text), combined('redir_out', 'pipe', 'urlpath')), (r'', Text, combined('redir_out', 'pipe', 'urlpath')) ], 'urlpath': [ (r'https?://([^\s"\'\\]|(\\.))+', String, combined('concat_mut', 'redir_out', 'pipe')), (r'(")(https?://(?:[^\r\n"\\]|(?:\\.))+)(")', bygroups(Text, String, Text), combined('concat_mut', 'redir_out', 'pipe')), (r'(")(https?://(?:[^\r\n"\\]|(?:\\.))+)', bygroups(Text, String)), (r"(')(https?://(?:[^\r\n'\\]|(?:\\.))+)(')", bygroups(Text, String, Text), combined('concat_mut', 'redir_out', 'pipe')), (r"(')(https?://(?:[^\r\n'\\]|(?:\\.))+)", bygroups(Text, String)), (r'(")((?:[^\r\n"\\=:]|(?:\\.))+)(")', bygroups(Text, String, Text), combined('concat_mut', 'redir_out', 'pipe')), (r'(")((?:[^\r\n"\\=:]|(?:\\.))+)', bygroups(Text, String)), (r"(')((?:[^\r\n'\\=:]|(?:\\.))+)(')", bygroups(Text, String, Text), combined('concat_mut', 'redir_out', 'pipe')), (r"(')((?:[^\r\n'\\=:]|(?:\\.))+)", bygroups(Text, String)), (r'([^\-](?:[^\s"\'\\=:]|(?:\\.))+)(\s+|$)', bygroups(String, Text), combined('concat_mut', 'redir_out', 'pipe')), (r'', Text, combined('concat_mut', 'redir_out', 'pipe')) ], 'end': [ (r'\n', Text, 'root') ] }
class DgLexer(RegexLexer): """ Lexer for `dg <http://pyos.github.com/dg>`_, a functional and object-oriented programming language running on the CPython 3 VM. .. versionadded:: 1.6 """ name = 'dg' aliases = ['dg'] filenames = ['*.dg'] mimetypes = ['text/x-dg'] tokens = { 'root': [ (r'\s+', Text), (r'#.*?$', Comment.Single), (r'(?i)0b[01]+', Number.Bin), (r'(?i)0o[0-7]+', Number.Oct), (r'(?i)0x[0-9a-f]+', Number.Hex), (r'(?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?', Number.Float), (r'(?i)[+-]?[0-9]+e[+-]?\d+j?', Number.Float), (r'(?i)[+-]?[0-9]+j?', Number.Integer), (r"(?i)(br|r?b?)'''", String, combined('stringescape', 'tsqs', 'string')), (r'(?i)(br|r?b?)"""', String, combined('stringescape', 'tdqs', 'string')), (r"(?i)(br|r?b?)'", String, combined('stringescape', 'sqs', 'string')), (r'(?i)(br|r?b?)"', String, combined('stringescape', 'dqs', 'string')), (r"`\w+'*`", Operator), (r'\b(and|in|is|or|where)\b', Operator.Word), (r'[!$%&*+\-./:<-@\\^|~;,]+', Operator), (words(('bool', 'bytearray', 'bytes', 'classmethod', 'complex', 'dict', 'dict\'', 'float', 'frozenset', 'int', 'list', 'list\'', 'memoryview', 'object', 'property', 'range', 'set', 'set\'', 'slice', 'staticmethod', 'str', 'super', 'tuple', 'tuple\'', 'type'), prefix=r'(?<!\.)', suffix=r'(?![\'\w])'), Name.Builtin), (words(('__import__', 'abs', 'all', 'any', 'bin', 'bind', 'chr', 'cmp', 'compile', 'complex', 'delattr', 'dir', 'divmod', 'drop', 'dropwhile', 'enumerate', 'eval', 'exhaust', 'filter', 'flip', 'foldl1?', 'format', 'fst', 'getattr', 'globals', 'hasattr', 'hash', 'head', 'hex', 'id', 'init', 'input', 'isinstance', 'issubclass', 'iter', 'iterate', 'last', 'len', 'locals', 'map', 'max', 'min', 'next', 'oct', 'open', 'ord', 'pow', 'print', 'repr', 'reversed', 'round', 'setattr', 'scanl1?', 'snd', 'sorted', 'sum', 'tail', 'take', 'takewhile', 'vars', 'zip'), prefix=r'(?<!\.)', suffix=r'(?![\'\w])'), Name.Builtin), (r"(?<!\.)(self|Ellipsis|NotImplemented|None|True|False)(?!['\w])", Name.Builtin.Pseudo), (r"(?<!\.)[A-Z]\w*(Error|Exception|Warning)'*(?!['\w])", Name.Exception), (r"(?<!\.)(Exception|GeneratorExit|KeyboardInterrupt|StopIteration|" r"SystemExit)(?!['\w])", Name.Exception), (r"(?<![\w.])(except|finally|for|if|import|not|otherwise|raise|" r"subclass|while|with|yield)(?!['\w])", Keyword.Reserved), (r"[A-Z_]+'*(?!['\w])", Name), (r"[A-Z]\w+'*(?!['\w])", Keyword.Type), (r"\w+'*", Name), (r'[()]', Punctuation), (r'.', Error), ], 'stringescape': [(r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)], 'string': [ (r'%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[E-GXc-giorsux%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String), (r'\n', String) ], 'dqs': [(r'"', String, '#pop')], 'sqs': [(r"'", String, '#pop')], 'tdqs': [(r'"""', String, '#pop')], 'tsqs': [(r"'''", String, '#pop')], }
class FelixLexer(RegexLexer): """ For `Felix <http://felix-lang.org>`_ source code. .. versionadded:: 1.2 """ name = 'Felix' aliases = ['felix', 'flx'] filenames = ['*.flx', '*.flxh'] mimetypes = ['text/x-felix'] keywords = ( '_', '_deref', 'all', 'as', 'assert', 'attempt', 'call', 'callback', 'case', 'caseno', 'cclass', 'code', 'compound', 'ctypes', 'do', 'done', 'downto', 'elif', 'else', 'endattempt', 'endcase', 'endif', 'endmatch', 'enum', 'except', 'exceptions', 'expect', 'finally', 'for', 'forall', 'forget', 'fork', 'functor', 'goto', 'ident', 'if', 'incomplete', 'inherit', 'instance', 'interface', 'jump', 'lambda', 'loop', 'match', 'module', 'namespace', 'new', 'noexpand', 'nonterm', 'obj', 'of', 'open', 'parse', 'raise', 'regexp', 'reglex', 'regmatch', 'rename', 'return', 'the', 'then', 'to', 'type', 'typecase', 'typedef', 'typematch', 'typeof', 'upto', 'when', 'whilst', 'with', 'yield', ) keyword_directives = ( '_gc_pointer', '_gc_type', 'body', 'comment', 'const', 'export', 'header', 'inline', 'lval', 'macro', 'noinline', 'noreturn', 'package', 'private', 'pod', 'property', 'public', 'publish', 'requires', 'todo', 'virtual', 'use', ) keyword_declarations = ( 'def', 'let', 'ref', ) keyword_types = ( 'unit', 'void', 'any', 'bool', 'byte', 'offset', 'address', 'caddress', 'cvaddress', 'vaddress', 'tiny', 'short', 'int', 'long', 'vlong', 'utiny', 'ushort', 'vshort', 'uint', 'ulong', 'uvlong', 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'uint64', 'float', 'double', 'ldouble', 'complex', 'dcomplex', 'lcomplex', 'imaginary', 'dimaginary', 'limaginary', 'char', 'wchar', 'uchar', 'charp', 'charcp', 'ucharp', 'ucharcp', 'string', 'wstring', 'ustring', 'cont', 'array', 'varray', 'list', 'lvalue', 'opt', 'slice', ) keyword_constants = ( 'false', 'true', ) name_builtins = ( '_svc', 'while', ) name_pseudo = ( 'root', 'self', 'this', ) decimal_suffixes = '((u?([tTsSiIlLvVzpj]|ll|LL))|([iIuU])(8|16|32|64))?' tokens = { 'root': [ include('whitespace'), # Keywords (words(('axiom', 'ctor', 'fun', 'gen', 'proc', 'reduce','regdef','var','val', 'union'), suffix=r'\b'), Keyword, 'funcname'), (words(('class', 'cclass', 'cstruct', 'obj', 'struct', 'object'), suffix=r'\b'), Keyword, 'funcname'), (r'(instance|module|typeclass|interface)\b', Keyword, 'funcname'), (words(keywords, suffix=r'\b'), Keyword), (words(keyword_directives, suffix=r'\b'), Name.Decorator), (words(keyword_declarations, suffix=r'\b'), Keyword.Declaration), (words(keyword_types, suffix=r'\b'), Keyword.Type), (words(keyword_constants, suffix=r'\b'), Keyword.Constant), # Operators include('operators'), # Float Literal # -- Hex Float (r'0[xX]([0-9a-fA-F_]*\.[0-9a-fA-F_]+|[0-9a-fA-F_]+)' r'[pP][+\-]?[0-9_]+[lLfFdD]?', Number.Float), # -- DecimalFloat (r'[0-9_]+(\.[0-9_]+[eE][+\-]?[0-9_]+|' r'\.[0-9_]*|[eE][+\-]?[0-9_]+)[lLfFdD]?', Number.Float), (r'\.(0|[1-9][0-9_]*)([eE][+\-]?[0-9_]+)?[lLfFdD]?', Number.Float), # IntegerLiteral # -- Binary (r'0[Bb][01_]+%s' % decimal_suffixes, Number.Bin), # -- Octal (r'0[oO][0-7_]+%s' % decimal_suffixes, Number.Oct), # -- Hexadecimal (r'0[xX][0-9a-fA-F_]+%s' % decimal_suffixes, Number.Hex), # -- Decimal (r'0[dD][0-9_]+%s' % decimal_suffixes, Number.Integer), (r'[0-9][0-9_]*%s' % decimal_suffixes, Number.Integer), # Strings ('([rR][cC]?|[cC][rR])"""', String, 'tdqs'), ("([rR][cC]?|[cC][rR])'''", String, 'tsqs'), ('([rR][cC]?|[cC][rR])"', String, 'dqs'), ("([rR][cC]?|[cC][rR])'", String, 'sqs'), ('[cCfFqQwWuU]?"""', String, combined('stringescape', 'tdqs')), ("[cCfFqQwWuU]?'''", String, combined('stringescape', 'tsqs')), ('[cCfFqQwWuU]?"', String, combined('stringescape', 'dqs')), ("[cCfFqQwWuU]?'", String, combined('stringescape', 'sqs')), # Punctuation (r'[\[\]{}:(),;?]', Punctuation), # Labels (r'[a-zA-Z_]\w*:>', Name.Label), # Identifiers (r"[a-zA-Z_][a-zA-Z0-9_'-]*|\\[A-Za-z]+", Name), ], 'whitespace': [ (r'\n', Text), (r'\s+', Text), include('comment'), ], 'operators': [ (r'!=|==|<<|>>|\|\||&&|[#!~+/*%=<>&^|.$-]', Operator), ], 'comment': [ (r'//(.*?)\n', Comment.Single), (r'/[*]', Comment.Multiline, 'comment2'), ], 'comment2': [ (r'[^/*]', Comment.Multiline), (r'/[*]', Comment.Multiline, '#push'), (r'[*]/', Comment.Multiline, '#pop'), (r'[/*]', Comment.Multiline), ], 'funcname': [ include('whitespace'), (r'[^[( ]+', Name.Function, '#pop'), # anonymous functions (r'(?=\()', Text, '#pop'), ], 'stringescape': [ (r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape) ], 'strings': [ (r'%(\([a-zA-Z0-9]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?' '[hlL]?[diouxXeEfFgGcrs%]', String.Interpol), (r'[^\\\'"%\n]+', String), # quotes, percents and backslashes must be parsed one at a time (r'[\'"\\]', String), # unhandled string formatting sign (r'%', String) # newlines are an error (use "nl" state) ], 'nl': [ (r'\n', String) ], 'dqs': [ (r'"', String, '#pop'), # included here again for raw strings (r'\\\\|\\"|\\\n', String.Escape), include('strings') ], 'sqs': [ (r"'", String, '#pop'), # included here again for raw strings (r"\\\\|\\'|\\\n", String.Escape), include('strings') ], 'tdqs': [ (r'"""', String, '#pop'), include('strings'), include('nl') ], 'tsqs': [ (r"'''", String, '#pop'), include('strings'), include('nl') ], }
class ThriftLexer(RegexLexer): """ For `Thrift <https://thrift.apache.org/>`__ interface definitions. .. versionadded:: 2.1 """ name = 'Thrift' aliases = ['thrift'] filenames = ['*.thrift'] mimetypes = ['application/x-thrift'] tokens = { 'root': [ include('whitespace'), include('comments'), (r'"', String.Double, combined('stringescape', 'dqs')), (r'\'', String.Single, combined('stringescape', 'sqs')), (r'(namespace)(\s+)', bygroups(Keyword.Namespace, Text.Whitespace), 'namespace'), (r'(enum|union|struct|service|exception)(\s+)', bygroups(Keyword.Declaration, Text.Whitespace), 'class'), ( r'((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)' # return arguments r'((?:[^\W\d]|\$)[\w$]*)' # method name r'(\s*)(\()', # signature start bygroups(using(this), Name.Function, Text, Operator)), include('keywords'), include('numbers'), (r'[&=]', Operator), (r'[:;,{}()<>\[\]]', Punctuation), (r'[a-zA-Z_](\.\w|\w)*', Name), ], 'whitespace': [ (r'\n', Text.Whitespace), (r'\s+', Text.Whitespace), ], 'comments': [ (r'#.*$', Comment), (r'//.*?\n', Comment), (r'/\*[\w\W]*?\*/', Comment.Multiline), ], 'stringescape': [ (r'\\([\\nrt"\'])', String.Escape), ], 'dqs': [ (r'"', String.Double, '#pop'), (r'[^\\"\n]+', String.Double), ], 'sqs': [ (r"'", String.Single, '#pop'), (r'[^\\\'\n]+', String.Single), ], 'namespace': [ (r'[a-z*](\.\w|\w)*', Name.Namespace, '#pop'), default('#pop'), ], 'class': [ (r'[a-zA-Z_]\w*', Name.Class, '#pop'), default('#pop'), ], 'keywords': [ (r'(async|oneway|extends|throws|required|optional)\b', Keyword), (r'(true|false)\b', Keyword.Constant), (r'(const|typedef)\b', Keyword.Declaration), (words(('cpp_namespace', 'cpp_include', 'cpp_type', 'java_package', 'cocoa_prefix', 'csharp_namespace', 'delphi_namespace', 'php_namespace', 'py_module', 'perl_package', 'ruby_namespace', 'smalltalk_category', 'smalltalk_prefix', 'xsd_all', 'xsd_optional', 'xsd_nillable', 'xsd_namespace', 'xsd_attrs', 'include'), suffix=r'\b'), Keyword.Namespace), (words( ('void', 'bool', 'byte', 'i16', 'i32', 'i64', 'double', 'string', 'binary', 'map', 'list', 'set', 'slist', 'senum'), suffix=r'\b'), Keyword.Type), (words( ('BEGIN', 'END', '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__', 'abstract', 'alias', 'and', 'args', 'as', 'assert', 'begin', 'break', 'case', 'catch', 'class', 'clone', 'continue', 'declare', 'def', 'default', 'del', 'delete', 'do', 'dynamic', 'elif', 'else', 'elseif', 'elsif', 'end', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'ensure', 'except', 'exec', 'finally', 'float', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'import', 'in', 'inline', 'instanceof', 'interface', 'is', 'lambda', 'module', 'native', 'new', 'next', 'nil', 'not', 'or', 'pass', 'public', 'print', 'private', 'protected', 'raise', 'redo', 'rescue', 'retry', 'register', 'return', 'self', 'sizeof', 'static', 'super', 'switch', 'synchronized', 'then', 'this', 'throw', 'transient', 'try', 'undef', 'unless', 'unsigned', 'until', 'use', 'var', 'virtual', 'volatile', 'when', 'while', 'with', 'xor', 'yield'), prefix=r'\b', suffix=r'\b'), Keyword.Reserved), ], 'numbers': [ (r'[+-]?(\d+\.\d+([eE][+-]?\d+)?|\.?\d+[eE][+-]?\d+)', Number.Float), (r'[+-]?0x[0-9A-Fa-f]+', Number.Hex), (r'[+-]?[0-9]+', Number.Integer), ], }
class JSLTLexer(RegexLexer): """ For JSLT source. .. versionadded:: 2.10 """ name = 'JSLT' url = 'https://github.com/schibsted/jslt' filenames = ['*.jslt'] aliases = ['jslt'] mimetypes = ['text/x-jslt'] tokens = { 'root': [ (r'[\t\n\f\r ]+', Whitespace), (r'//.*(\n|\Z)', Comment.Single), (r'-?(0|[1-9][0-9]*)', Number.Integer), (r'-?(0|[1-9][0-9]*)(.[0-9]+a)?([Ee][+-]?[0-9]+)', Number.Float), (r'"([^"\\]|\\.)*"', String.Double), (r'[(),:\[\]{}]', Punctuation), (r'(!=|[<=>]=?)', Operator), (r'[*+/|-]', Operator), (r'\.', Operator), (words(('import', ), suffix=_WORD_END), Keyword.Namespace, combined('import-path', 'whitespace')), (words(('as', ), suffix=_WORD_END), Keyword.Namespace, combined('import-alias', 'whitespace')), (words(('let', ), suffix=_WORD_END), Keyword.Declaration, combined('constant', 'whitespace')), (words(('def', ), suffix=_WORD_END), Keyword.Declaration, combined('function', 'whitespace')), (words(('false', 'null', 'true'), suffix=_WORD_END), Keyword.Constant), (words(('else', 'for', 'if'), suffix=_WORD_END), Keyword), (words(('and', 'or'), suffix=_WORD_END), Operator.Word), (words(('all', 'any', 'array', 'boolean', 'capture', 'ceiling', 'contains', 'ends-with', 'error', 'flatten', 'floor', 'format-time', 'from-json', 'get-key', 'hash-int', 'index-of', 'is-array', 'is-boolean', 'is-decimal', 'is-integer', 'is-number', 'is-object', 'is-string', 'join', 'lowercase', 'max', 'min', 'mod', 'not', 'now', 'number', 'parse-time', 'parse-url', 'random', 'replace', 'round', 'sha256-hex', 'size', 'split', 'starts-with', 'string', 'sum', 'test', 'to-json', 'trim', 'uppercase', 'zip', 'zip-with-index', 'fallback'), suffix=_WORD_END), Name.Builtin), (r'[A-Z_a-z][0-9A-Z_a-z-]*:[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function), (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name), (r'\$[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable), ], 'constant': [ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable, 'root'), ], 'function': [ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function, combined('function-parameter-list', 'whitespace')), ], 'function-parameter-list': [ (r'\(', Punctuation, combined('function-parameters', 'whitespace')), ], 'function-parameters': [ (r',', Punctuation), (r'\)', Punctuation, 'root'), (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable), ], 'import-path': [ (r'"([^"]|\\.)*"', String.Symbol, 'root'), ], 'import-alias': [ (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Namespace, 'root'), ], 'string': [ (r'"', String.Double, '#pop'), (r'\\.', String.Escape), ], 'whitespace': [ (r'[\t\n\f\r ]+', Whitespace), (r'//.*(\n|\Z)', Comment.Single), ] }
class GDScriptLexer(RegexLexer): """ For `GDScript source code <https://www.godotengine.org>`_. """ name = "GDScript" aliases = ["gdscript", "gd"] filenames = ["*.gd"] mimetypes = ["text/x-gdscript", "application/x-gdscript"] def innerstring_rules(ttype): return [ # the old style '%s' % (...) string formatting ( r"%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?" "[hlL]?[E-GXc-giorsux%]", String.Interpol, ), # backslashes, quotes and formatting signs must be parsed one at a time (r'[^\\\'"%\n]+', ttype), (r'[\'"\\]', ttype), # unhandled string formatting sign (r"%", ttype), # newlines are an error (use "nl" state) ] tokens = { "root": [ (r"\n", Whitespace), ( r'^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")', bygroups(Whitespace, String.Affix, String.Doc), ), ( r"^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')", bygroups(Whitespace, String.Affix, String.Doc), ), (r"[^\S\n]+", Whitespace), (r"#.*$", Comment.Single), (r"[]{}:(),;[]", Punctuation), (r"(\\)(\n)", bygroups(Text, Whitespace)), (r"\\", Text), (r"(in|and|or|not)\b", Operator.Word), ( r"!=|==|<<|>>|&&|\+=|-=|\*=|/=|%=|&=|\|=|\|\||[-~+/*%=<>&^.!|$]", Operator, ), include("keywords"), (r"(func)(\s+)", bygroups(Keyword, Whitespace), "funcname"), (r"(class)(\s+)", bygroups(Keyword, Whitespace), "classname"), include("builtins"), ( '([rR]|[uUbB][rR]|[rR][uUbB])(""")', bygroups(String.Affix, String.Double), "tdqs", ), ( "([rR]|[uUbB][rR]|[rR][uUbB])(''')", bygroups(String.Affix, String.Single), "tsqs", ), ( '([rR]|[uUbB][rR]|[rR][uUbB])(")', bygroups(String.Affix, String.Double), "dqs", ), ( "([rR]|[uUbB][rR]|[rR][uUbB])(')", bygroups(String.Affix, String.Single), "sqs", ), ( '([uUbB]?)(""")', bygroups(String.Affix, String.Double), combined("stringescape", "tdqs"), ), ( "([uUbB]?)(''')", bygroups(String.Affix, String.Single), combined("stringescape", "tsqs"), ), ( '([uUbB]?)(")', bygroups(String.Affix, String.Double), combined("stringescape", "dqs"), ), ( "([uUbB]?)(')", bygroups(String.Affix, String.Single), combined("stringescape", "sqs"), ), include("name"), include("numbers"), ], "keywords": [ ( words( ( "and", "in", "not", "or", "as", "breakpoint", "class", "class_name", "extends", "is", "func", "setget", "signal", "tool", "const", "enum", "export", "onready", "static", "var", "break", "continue", "if", "elif", "else", "for", "pass", "return", "match", "while", "remote", "master", "puppet", "remotesync", "mastersync", "puppetsync", ), suffix=r"\b", ), Keyword, ), ], "builtins": [ ( words( ( "Color8", "ColorN", "abs", "acos", "asin", "assert", "atan", "atan2", "bytes2var", "ceil", "char", "clamp", "convert", "cos", "cosh", "db2linear", "decimals", "dectime", "deg2rad", "dict2inst", "ease", "exp", "floor", "fmod", "fposmod", "funcref", "hash", "inst2dict", "instance_from_id", "is_inf", "is_nan", "lerp", "linear2db", "load", "log", "max", "min", "nearest_po2", "pow", "preload", "print", "print_stack", "printerr", "printraw", "prints", "printt", "rad2deg", "rand_range", "rand_seed", "randf", "randi", "randomize", "range", "round", "seed", "sign", "sin", "sinh", "sqrt", "stepify", "str", "str2var", "tan", "tan", "tanh", "type_exist", "typeof", "var2bytes", "var2str", "weakref", "yield", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Builtin, ), (r"((?<!\.)(self|false|true)|(PI|TAU|NAN|INF)" r")\b", Name.Builtin.Pseudo), ( words( ( "bool", "int", "float", "String", "NodePath", "Vector2", "Rect2", "Transform2D", "Vector3", "Rect3", "Plane", "Quat", "Basis", "Transform", "Color", "RID", "Object", "NodePath", "Dictionary", "Array", "PackedByteArray", "PackedInt32Array", "PackedInt64Array", "PackedFloat32Array", "PackedFloat64Array", "PackedStringArray", "PackedVector2Array", "PackedVector3Array", "PackedColorArray", "null", "void", ), prefix=r"(?<!\.)", suffix=r"\b", ), Name.Builtin.Type, ), ], "numbers": [ (r"(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?", Number.Float), (r"\d+[eE][+-]?[0-9]+j?", Number.Float), (r"0[xX][a-fA-F0-9]+", Number.Hex), (r"\d+j?", Number.Integer), ], "name": [(r"[a-zA-Z_]\w*", Name)], "funcname": [(r"[a-zA-Z_]\w*", Name.Function, "#pop"), default("#pop")], "classname": [(r"[a-zA-Z_]\w*", Name.Class, "#pop")], "stringescape": [ ( r'\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|' r"U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})", String.Escape, ) ], "strings-single": innerstring_rules(String.Single), "strings-double": innerstring_rules(String.Double), "dqs": [ (r'"', String.Double, "#pop"), (r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings include("strings-double"), ], "sqs": [ (r"'", String.Single, "#pop"), (r"\\\\|\\'|\\\n", String.Escape), # included here for raw strings include("strings-single"), ], "tdqs": [ (r'"""', String.Double, "#pop"), include("strings-double"), (r"\n", Whitespace), ], "tsqs": [ (r"'''", String.Single, "#pop"), include("strings-single"), (r"\n", Whitespace), ], } def analyse_text(text): score = 0.0 if re.search( r"func (_ready|_init|_input|_process|_unhandled_input)", text ): score += 0.8 if re.search( r"(extends |class_name |onready |preload|load|setget|func [^_])", text ): score += 0.4 if re.search(r"(var|const|enum|export|signal|tool)", text): score += 0.2 return min(score, 1.0)
class ObsidianLexer(RegexLexer): """ For Obsidian source code. """ name = 'Obsidian' aliases = ['obs', 'Obsidian'] filenames = ['*.obs'] mimetypes = [] flags = re.DOTALL | re.UNICODE | re.MULTILINE tokens = { 'comment-parse-single': [ (r'\n', Comment.Single, '#pop'), (r'[^\n]', Comment.Single), ], 'comment-parse-multi': [ (r'[^*/]', Comment.Multiline), (r'\*/', Comment.Multiline, '#pop'), (r'[*/]', Comment.Multiline), ], 'comments': [ (r'//', Comment.Single, 'comment-parse-single'), (r'/[*]', Comment.Multiline, 'comment-parse-multi'), ], 'keywords-other': [ (words(('Owned', 'Unowned', 'Shared', 'asset', 'interface', 'owned', 'unowned', 'shared', 'available in', 'in'), suffix=r'\b'), Keyword), (words(('contract', 'transaction', 'state'), suffix=r'\b'), Keyword.Declaration), # built-in constants (r'(true|false)\b', Keyword.Constant), ], 'keywords-types': [ (words(('void', 'int', 'string'), suffix=r'\b'), Keyword.Type), ], 'numbers': [ (r'0[xX][0-9a-fA-F]+', Number.Hex), (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?', Number.Float), (r'[0-9]+([eE][0-9]+)?', Number.Integer), ], 'string-parse-common': [ # escapes (r'\\(u[0-9a-fA-F]{4}|x..|[^x])', String.Escape), # almost everything else is plain characters (r'[^\\"\'\n]+', String), # line continuation (r'\\\n', String), # stray backslash (r'\\', String) ], 'string-parse-double': [(r'"', String, '#pop'), (r"'", String)], 'string-parse-single': [(r"'", String, '#pop'), (r'"', String)], 'strings': [ # usual strings (r'"', String, combined('string-parse-common', 'string-parse-double')), (r"'", String, combined('string-parse-common', 'string-parse-single')) ], 'whitespace': [(r'\s+', Text)], 'root': [ include('comments'), include('keywords-types'), include('keywords-other'), include('numbers'), include('strings'), include('whitespace'), (r'>>|@|\*\*|\?|:|~|&&|\|\||=>|==?|!=?|->', Operator), (r'(<<|[\-<>+*%&/\|])', Operator), (r'[{(\[;,]', Punctuation), (r'[})\].]', Punctuation), # compiler built-ins (r'(this|super)\b', Name.Builtin), (r'selector\b', Name.Builtin), # everything else is a var/function name ('[a-zA-Z_]\w*', Name) ] # 'root' } # tokens