diff options
author | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:24:06 +0300 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:41:34 +0300 |
commit | e0e3e1717e3d33762ce61950504f9637a6e669ed (patch) | |
tree | bca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/Pygments/py3/pygments/lexers/jmespath.py | |
parent | 38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff) | |
download | ydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz |
add ydb deps
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/jmespath.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/jmespath.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/jmespath.py b/contrib/python/Pygments/py3/pygments/lexers/jmespath.py new file mode 100644 index 00000000000..74aa57274b9 --- /dev/null +++ b/contrib/python/Pygments/py3/pygments/lexers/jmespath.py @@ -0,0 +1,68 @@ +""" + pygments.lexers.jmespath + ~~~~~~~~~~~~~~~~~~~~~~~~ + + Lexers for the JMESPath language + + :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from pygments.lexer import RegexLexer, bygroups, include +from pygments.token import String, Punctuation, Whitespace, Name, Operator, \ + Number, Literal, Keyword + +__all__ = ['JMESPathLexer'] + + +class JMESPathLexer(RegexLexer): + """ + For JMESPath queries. + """ + name = 'JMESPath' + url = 'https://jmespath.org' + filenames = ['*.jp'] + aliases = ['jmespath', 'jp'] + + tokens = { + 'string': [ + (r"'(\\(.|\n)|[^'\\])*'", String), + ], + 'punctuation': [ + (r'(\[\?|[\.\*\[\],:\(\)\{\}\|])', Punctuation), + ], + 'ws': [ + (r" |\t|\n|\r", Whitespace) + ], + "dq-identifier": [ + (r'[^\\"]+', Name.Variable), + (r'\\"', Name.Variable), + (r'.', Punctuation, '#pop'), + ], + 'identifier': [ + (r'(&)?(")', bygroups(Name.Variable, Punctuation), 'dq-identifier'), + (r'(")?(&?[A-Za-z][A-Za-z0-9_-]*)(")?', bygroups(Punctuation, Name.Variable, Punctuation)), + ], + 'root': [ + include('ws'), + include('string'), + (r'(==|!=|<=|>=|<|>|&&|\|\||!)', Operator), + include('punctuation'), + (r'@', Name.Variable.Global), + (r'(&?[A-Za-z][A-Za-z0-9_]*)(\()', bygroups(Name.Function, Punctuation)), + (r'(&)(\()', bygroups(Name.Variable, Punctuation)), + include('identifier'), + (r'-?\d+', Number), + (r'`', Literal, 'literal'), + ], + 'literal': [ + include('ws'), + include('string'), + include('punctuation'), + (r'(false|true|null)\b', Keyword.Constant), + include('identifier'), + (r'-?\d+\.?\d*([eE][-+]\d+)?', Number), + (r'\\`', Literal), + (r'`', Literal, '#pop'), + ] + } |