Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
pony.py94 linesDownload Raw Back to lexers
1"""2    pygments.lexers.pony3    ~~~~~~~~~~~~~~~~~~~~4 5    Lexers for Pony and related languages.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11from pygments.lexer import RegexLexer, bygroups, words12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \13    Number, Punctuation14 15__all__ = ['PonyLexer']16 17 18class PonyLexer(RegexLexer):19    """20    For Pony source code.21    """22 23    name = 'Pony'24    aliases = ['pony']25    filenames = ['*.pony']26    url = 'https://www.ponylang.io'27    version_added = '2.4'28 29    _caps = r'(iso|trn|ref|val|box|tag)'30 31    tokens = {32        'root': [33            (r'\n', Text),34            (r'[^\S\n]+', Text),35            (r'//.*\n', Comment.Single),36            (r'/\*', Comment.Multiline, 'nested_comment'),37            (r'"""(?:.|\n)*?"""', String.Doc),38            (r'"', String, 'string'),39            (r'\'.*\'', String.Char),40            (r'=>|[]{}:().~;,|&!^?[]', Punctuation),41            (words((42                'addressof', 'and', 'as', 'consume', 'digestof', 'is', 'isnt',43                'not', 'or'),44                suffix=r'\b'),45             Operator.Word),46            (r'!=|==|<<|>>|[-+/*%=<>]', Operator),47            (words((48                'box', 'break', 'compile_error', 'compile_intrinsic',49                'continue', 'do', 'else', 'elseif', 'embed', 'end', 'error',50                'for', 'if', 'ifdef', 'in', 'iso', 'lambda', 'let', 'match',51                'object', 'recover', 'ref', 'repeat', 'return', 'tag', 'then',52                'this', 'trn', 'try', 'until', 'use', 'var', 'val', 'where',53                'while', 'with', '#any', '#read', '#send', '#share'),54                suffix=r'\b'),55             Keyword),56            (r'(actor|class|struct|primitive|interface|trait|type)((?:\s)+)',57             bygroups(Keyword, Text), 'typename'),58            (r'(new|fun|be)((?:\s)+)', bygroups(Keyword, Text), 'methodname'),59            (words((60                'I8', 'U8', 'I16', 'U16', 'I32', 'U32', 'I64', 'U64', 'I128',61                'U128', 'ILong', 'ULong', 'ISize', 'USize', 'F32', 'F64',62                'Bool', 'Pointer', 'None', 'Any', 'Array', 'String',63                'Iterator'),64                suffix=r'\b'),65             Name.Builtin.Type),66            (r'_?[A-Z]\w*', Name.Type),67            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),68            (r'0x[0-9a-fA-F]+', Number.Hex),69            (r'\d+', Number.Integer),70            (r'(true|false)\b', Name.Builtin),71            (r'_\d*', Name),72            (r'_?[a-z][\w\']*', Name)73        ],74        'typename': [75            (_caps + r'?((?:\s)*)(_?[A-Z]\w*)',76             bygroups(Keyword, Text, Name.Class), '#pop')77        ],78        'methodname': [79            (_caps + r'?((?:\s)*)(_?[a-z]\w*)',80             bygroups(Keyword, Text, Name.Function), '#pop')81        ],82        'nested_comment': [83            (r'[^*/]+', Comment.Multiline),84            (r'/\*', Comment.Multiline, '#push'),85            (r'\*/', Comment.Multiline, '#pop'),86            (r'[*/]', Comment.Multiline)87        ],88        'string': [89            (r'"', String, '#pop'),90            (r'\\"', String),91            (r'[^\\"]+', String)92        ]93    }94 
codekingpro/portable-devtools · Team Ai