Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
jslt.py95 linesDownload Raw Back to lexers
1"""2    pygments.lexers.jslt3    ~~~~~~~~~~~~~~~~~~~~4 5    Lexers for the JSLT language6 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, combined, words12from pygments.token import Comment, Keyword, Name, Number, Operator, \13    Punctuation, String, Whitespace14 15 16__all__ = ['JSLTLexer']17 18 19_WORD_END = r'(?=[^0-9A-Z_a-z-])'20 21 22class JSLTLexer(RegexLexer):23    """24    For JSLT source.25    """26    name = 'JSLT'27    url = 'https://github.com/schibsted/jslt'28    filenames = ['*.jslt']29    aliases = ['jslt']30    mimetypes = ['text/x-jslt']31    version_added = '2.10'32 33    tokens = {34        'root': [35            (r'[\t\n\f\r ]+', Whitespace),36            (r'//.*(\n|\Z)', Comment.Single),37            (r'-?(0|[1-9][0-9]*)', Number.Integer),38            (r'-?(0|[1-9][0-9]*)(.[0-9]+a)?([Ee][+-]?[0-9]+)', Number.Float),39            (r'"([^"\\]|\\.)*"', String.Double),40            (r'[(),:\[\]{}]', Punctuation),41            (r'(!=|[<=>]=?)', Operator),42            (r'[*+/|-]', Operator),43            (r'\.', Operator),44            (words(('import',), suffix=_WORD_END), Keyword.Namespace, combined('import-path', 'whitespace')),45            (words(('as',), suffix=_WORD_END), Keyword.Namespace, combined('import-alias', 'whitespace')),46            (words(('let',), suffix=_WORD_END), Keyword.Declaration, combined('constant', 'whitespace')),47            (words(('def',), suffix=_WORD_END), Keyword.Declaration, combined('function', 'whitespace')),48            (words(('false', 'null', 'true'), suffix=_WORD_END), Keyword.Constant),49            (words(('else', 'for', 'if'), suffix=_WORD_END), Keyword),50            (words(('and', 'or'), suffix=_WORD_END), Operator.Word),51            (words((52                'all', 'any', 'array', 'boolean', 'capture', 'ceiling',53                'contains', 'ends-with', 'error', 'flatten', 'floor',54                'format-time', 'from-json', 'get-key', 'hash-int', 'index-of',55                'is-array', 'is-boolean', 'is-decimal', 'is-integer',56                'is-number', 'is-object', 'is-string', 'join', 'lowercase',57                'max', 'min', 'mod', 'not', 'now', 'number', 'parse-time',58                'parse-url', 'random', 'replace', 'round', 'sha256-hex', 'size',59                'split', 'starts-with', 'string', 'sum', 'test', 'to-json',60                'trim', 'uppercase', 'zip', 'zip-with-index', 'fallback'), suffix=_WORD_END),61             Name.Builtin),62            (r'[A-Z_a-z][0-9A-Z_a-z-]*:[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function),63            (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name),64            (r'\$[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),65        ],66        'constant': [67            (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable, 'root'),68        ],69        'function': [70            (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Function, combined('function-parameter-list', 'whitespace')),71        ],72        'function-parameter-list': [73            (r'\(', Punctuation, combined('function-parameters', 'whitespace')),74        ],75        'function-parameters': [76            (r',', Punctuation),77            (r'\)', Punctuation, 'root'),78            (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Variable),79        ],80        'import-path': [81            (r'"([^"]|\\.)*"', String.Symbol, 'root'),82        ],83        'import-alias': [84            (r'[A-Z_a-z][0-9A-Z_a-z-]*', Name.Namespace, 'root'),85        ],86        'string': [87            (r'"', String.Double, '#pop'),88            (r'\\.', String.Escape),89        ],90        'whitespace': [91            (r'[\t\n\f\r ]+', Whitespace),92            (r'//.*(\n|\Z)', Comment.Single),93        ]94    }95 
codekingpro/portable-devtools · Team Ai