Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
inferno.py96 linesDownload Raw Back to lexers
1"""2    pygments.lexers.inferno3    ~~~~~~~~~~~~~~~~~~~~~~~4 5    Lexers for Inferno os and all the related stuff.6 7    :copyright: Copyright 2006-present by the Pygments team, see AUTHORS.8    :license: BSD, see LICENSE for details.9"""10 11import re12 13from pygments.lexer import RegexLexer, include, bygroups, default14from pygments.token import Punctuation, Comment, Operator, Keyword, \15    Name, String, Number, Whitespace16 17__all__ = ['LimboLexer']18 19 20class LimboLexer(RegexLexer):21    """22    Lexer for Limbo programming language23 24    TODO:25        - maybe implement better var declaration highlighting26        - some simple syntax error highlighting27    """28    name = 'Limbo'29    url = 'http://www.vitanuova.com/inferno/limbo.html'30    aliases = ['limbo']31    filenames = ['*.b']32    mimetypes = ['text/limbo']33    version_added = '2.0'34 35    tokens = {36        'whitespace': [37            (r'^(\s*)([a-zA-Z_]\w*:)(\s*\n)',38             bygroups(Whitespace, Name.Label, Whitespace)),39            (r'\n', Whitespace),40            (r'\s+', Whitespace),41            (r'#(\n|(.|\n)*?[^\\]\n)', Comment.Single),42        ],43        'string': [44            (r'"', String, '#pop'),45            (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|'46             r'u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})', String.Escape),47            (r'[^\\"\n]+', String), # all other characters48            (r'\\', String), # stray backslash49        ],50        'statements': [51            (r'"', String, 'string'),52            (r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),53            (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+', Number.Float),54            (r'(\d+\.\d*|\.\d+|\d+[fF])', Number.Float),55            (r'16r[0-9a-fA-F]+', Number.Hex),56            (r'8r[0-7]+', Number.Oct),57            (r'((([1-3]\d)|([2-9]))r)?(\d+)', Number.Integer),58            (r'[()\[\],.]', Punctuation),59            (r'[~!%^&*+=|?:<>/-]|(->)|(<-)|(=>)|(::)', Operator),60            (r'(alt|break|case|continue|cyclic|do|else|exit'61             r'for|hd|if|implement|import|include|len|load|or'62             r'pick|return|spawn|tagof|tl|to|while)\b', Keyword),63            (r'(byte|int|big|real|string|array|chan|list|adt'64             r'|fn|ref|of|module|self|type)\b', Keyword.Type),65            (r'(con|iota|nil)\b', Keyword.Constant),66            (r'[a-zA-Z_]\w*', Name),67        ],68        'statement' : [69            include('whitespace'),70            include('statements'),71            ('[{}]', Punctuation),72            (';', Punctuation, '#pop'),73        ],74        'root': [75            include('whitespace'),76            default('statement'),77        ],78    }79 80    def analyse_text(text):81        # Any limbo module implements something82        if re.search(r'^implement \w+;', text, re.MULTILINE):83            return 0.784 85# TODO:86#   - Make lexers for:87#       - asm sources88#       - man pages89#       - mkfiles90#       - module definitions91#       - namespace definitions92#       - shell scripts93#       - maybe keyfiles and fonts94#   they all seem to be quite similar to their equivalents95#   from unix world, so there should not be a lot of problems96 
codekingpro/portable-devtools · Team Ai