Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
nit.py64 linesDownload Raw Back to lexers
1"""2    pygments.lexers.nit3    ~~~~~~~~~~~~~~~~~~~4 5    Lexer for the Nit language.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, words12from pygments.token import Text, Comment, Operator, Keyword, Name, String, \13    Number, Punctuation14 15__all__ = ['NitLexer']16 17 18class NitLexer(RegexLexer):19    """20    For nit source.21    """22 23    name = 'Nit'24    url = 'http://nitlanguage.org'25    aliases = ['nit']26    filenames = ['*.nit']27    version_added = '2.0'28    tokens = {29        'root': [30            (r'#.*?$', Comment.Single),31            (words((32                'package', 'module', 'import', 'class', 'abstract', 'interface',33                'universal', 'enum', 'end', 'fun', 'type', 'init', 'redef',34                'isa', 'do', 'readable', 'writable', 'var', 'intern', 'extern',35                'public', 'protected', 'private', 'intrude', 'if', 'then',36                'else', 'while', 'loop', 'for', 'in', 'and', 'or', 'not',37                'implies', 'return', 'continue', 'break', 'abort', 'assert',38                'new', 'is', 'once', 'super', 'self', 'true', 'false', 'nullable',39                'null', 'as', 'isset', 'label', '__debug__'), suffix=r'(?=[\r\n\t( ])'),40             Keyword),41            (r'[A-Z]\w*', Name.Class),42            (r'"""(([^\'\\]|\\.)|\\r|\\n)*((\{\{?)?(""?\{\{?)*""""*)', String),  # Simple long string43            (r'\'\'\'(((\\.|[^\'\\])|\\r|\\n)|\'((\\.|[^\'\\])|\\r|\\n)|'44             r'\'\'((\\.|[^\'\\])|\\r|\\n))*\'\'\'', String),  # Simple long string alt45            (r'"""(([^\'\\]|\\.)|\\r|\\n)*((""?)?(\{\{?""?)*\{\{\{\{*)', String),  # Start long string46            (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(""?)?(\{\{?""?)*\{\{\{\{*', String),  # Mid long string47            (r'\}\}\}(((\\.|[^\'\\])|\\r|\\n))*(\{\{?)?(""?\{\{?)*""""*', String),  # End long string48            (r'"(\\.|([^"}{\\]))*"', String),  # Simple String49            (r'"(\\.|([^"}{\\]))*\{', String),  # Start string50            (r'\}(\\.|([^"}{\\]))*\{', String),  # Mid String51            (r'\}(\\.|([^"}{\\]))*"', String),  # End String52            (r'(\'[^\'\\]\')|(\'\\.\')', String.Char),53            (r'[0-9]+', Number.Integer),54            (r'[0-9]*.[0-9]+', Number.Float),55            (r'0(x|X)[0-9A-Fa-f]+', Number.Hex),56            (r'[a-z]\w*', Name),57            (r'_\w+', Name.Variable.Instance),58            (r'==|!=|<==>|>=|>>|>|<=|<<|<|\+|-|=|/|\*|%|\+=|-=|!|@', Operator),59            (r'\(|\)|\[|\]|,|\.\.\.|\.\.|\.|::|:', Punctuation),60            (r'`\{[^`]*`\}', Text),  # Extern blocks won't be Lexed by Nit61            (r'[\r\n\t ]+', Text),62        ],63    }64 
codekingpro/portable-devtools · Team Ai