Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
wren.py99 linesDownload Raw Back to lexers
1"""2    pygments.lexers.wren3    ~~~~~~~~~~~~~~~~~~~~4 5    Lexer for Wren.6 7    :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11import re12 13from pygments.lexer import include, RegexLexer, words14from pygments.token import Whitespace, Punctuation, Keyword, Name, Comment, \15    Operator, Number, String16 17__all__ = ['WrenLexer']18 19class WrenLexer(RegexLexer):20    """21    For Wren source code, version 0.4.0.22    """23    name = 'Wren'24    url = 'https://wren.io'25    aliases = ['wren']26    filenames = ['*.wren']27    version_added = '2.14'28 29    flags = re.MULTILINE | re.DOTALL30 31    tokens = {32        'root': [33            # Whitespace.34            (r'\s+', Whitespace),35            (r'[,\\\[\]{}]', Punctuation),36 37            # Really 'root', not '#push': in 'interpolation',38            # parentheses inside the interpolation expression are39            # Punctuation, not String.Interpol.40            (r'\(', Punctuation, 'root'),41            (r'\)', Punctuation, '#pop'),42 43            # Keywords.44            (words((45                'as', 'break', 'class', 'construct', 'continue', 'else',46                'for', 'foreign', 'if', 'import', 'return', 'static', 'super',47                'this', 'var', 'while'), prefix = r'(?<!\.)',48                suffix = r'\b'), Keyword),49 50            (words((51                'true', 'false', 'null'), prefix = r'(?<!\.)',52                suffix = r'\b'), Keyword.Constant),53 54            (words((55                'in', 'is'), prefix = r'(?<!\.)',56                suffix = r'\b'), Operator.Word),57 58            # Comments.59            (r'/\*', Comment.Multiline, 'comment'), # Multiline, can nest.60            (r'//.*?$', Comment.Single),            # Single line.61            (r'#.*?(\(.*?\))?$', Comment.Special),  # Attribute or shebang.62 63            # Names and operators.64            (r'[!%&*+\-./:<=>?\\^|~]+', Operator),65            (r'[a-z][a-zA-Z_0-9]*', Name),66            (r'[A-Z][a-zA-Z_0-9]*', Name.Class),67            (r'__[a-zA-Z_0-9]*', Name.Variable.Class),68            (r'_[a-zA-Z_0-9]*', Name.Variable.Instance),69 70            # Numbers.71            (r'0x[0-9a-fA-F]+', Number.Hex),72            (r'\d+(\.\d+)?([eE][-+]?\d+)?', Number.Float),73 74            # Strings.75            (r'""".*?"""', String),   # Raw string76            (r'"', String, 'string'), # Other string77        ],78        'comment': [79            (r'/\*', Comment.Multiline, '#push'),80            (r'\*/', Comment.Multiline, '#pop'),81            (r'([^*/]|\*(?!/)|/(?!\*))+', Comment.Multiline),82        ],83        'string': [84            (r'"', String, '#pop'),85            (r'\\[\\%"0abefnrtv]', String.Escape), # Escape.86            (r'\\x[a-fA-F0-9]{2}', String.Escape), # Byte escape.87            (r'\\u[a-fA-F0-9]{4}', String.Escape), # Unicode escape.88            (r'\\U[a-fA-F0-9]{8}', String.Escape), # Long Unicode escape.89 90            (r'%\(', String.Interpol, 'interpolation'),91            (r'[^\\"%]+', String), # All remaining characters.92        ],93        'interpolation': [94            # redefine closing paren to be String.Interpol95            (r'\)', String.Interpol, '#pop'),96            include('root'),97        ],98    }99 
codekingpro/portable-devtools · Team Ai