File: //opt/saltstack/salt/lib/python3.10/site-packages/pygments/lexers/__pycache__/sql.cpython-310.pyc
o
;j�� � @ sN d Z ddlZddlZddlmZmZmZmZmZ ddl m
Z
ddl mZ ddl mZ ddl m
Z
ddl mZ dd l mZmZ dd
lmZmZmZmZmZmZmZmZmZmZmZ g d�Ze�d�Ze�d
�Z e�dej!�Z"e�dej!�Z#e�d�Z$e�d�Z%e�dej!�Z&e�dej!�Z'e�d�Z(e
j)e
j* e
j+ Z,dd� Z-G dd� d�Z.G dd� de.e�Z/G dd� de.e�Z0G dd� de.e�Z1e�d�Z2e�d �Z3e�d!�Z4e�d"�Z3e�d#�Z5e�d$�Z6G d%d&� d&�Z7G d'd(� d(e�Z8G d)d*� d*e�Z9G d+d,� d,e�Z:G d-d.� d.e�Z;G d/d0� d0e�Z<G d1d2� d2e�Z=G d3d4� d4e�Z>G d5d6� d6e�Z?dS )7a�
pygments.lexers.sql
~~~~~~~~~~~~~~~~~~~
Lexers for various SQL dialects and related interactive sessions.
Postgres specific lexers:
`PostgresLexer`
A SQL lexer for the PostgreSQL dialect. Differences w.r.t. the SQL
lexer are:
- keywords and data types list parsed from the PG docs (run the
`_postgres_builtins` module to update them);
- Content of $-strings parsed using a specific lexer, e.g. the content
of a PL/Python function is parsed using the Python lexer;
- parse PG specific constructs: E-strings, $-strings, U&-strings,
different operators and punctuation.
`PlPgsqlLexer`
A lexer for the PL/pgSQL language. Adds a few specific construct on
top of the PG SQL lexer (such as <<label>>).
`PostgresConsoleLexer`
A lexer to highlight an interactive psql session:
- identifies the prompt and does its best to detect the end of command
in multiline statement where not all the lines are prefixed by a
prompt, telling them apart from the output;
- highlights errors in the output and notification levels;
- handles psql backslash commands.
`PostgresExplainLexer`
A lexer to highlight Postgres execution plan.
The ``tests/examplefiles`` contains a few test files with data to be
parsed by these lexers.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�Lexer�
RegexLexer�
do_insertions�bygroups�words)�_googlesql_builtins)�_mysql_builtins)�_postgres_builtins)�
_sql_builtins)�_tsql_builtins)�get_lexer_by_name�
ClassNotFound)�Punctuation�
Whitespace�Text�Comment�Operator�Keyword�Name�String�Number�Generic�Literal)
�GoogleSqlLexer�
PostgresLexer�PlPgsqlLexer�PostgresConsoleLexer�PostgresExplainLexer�SqlLexer�TransactSqlLexer�
MySqlLexer�SqliteConsoleLexer�RqlLexerz.*?
z^(?:sqlite| ...)>(?= )z\s+LANGUAGE\s+'?(\w+)'?z\bDO\bz\[[a-zA-Z_]\w*\]z`[a-zA-Z_]\w*`z\bgo\bz
\bdeclare\s+@z@[a-zA-Z_]\w*\bc c s� � d}t �| j|�� |�� d � �}|dur | �|�d��}n>tt �| jtd|� � d �|� � � ��}|rB| �|d �d��}ntt
�| jtd|� � d �|� � � ��}|r^| �d�}|� d�t|�d�fV |� d�tj|�d�fV |� d �t|�d �fV |r�|�
|�d
��E dH n|� d
�t|�d
�fV |� d�t|�d�fV |� d�tj|�d�fV |� d
�t|�d
�fV dS )z�Parse the content of a $-string using a lexer
The lexer is chosen looking for a nearby LANGUAGE or assumed as
plpgsql if inside a DO statement and no LANGUAGE has been found.
N�d � r ���� �plpgsql� � � � � � )�language_re�match�text�end�
_get_lexer�group�list�finditer�max�start�do_rer Z Delimiter�get_tokens_unprocessed)�lexerr/ �lx�m� r= �G/opt/saltstack/salt/lib/python3.10/site-packages/pygments/lexers/sql.py�language_callbackR s0 � ��
r? c s( e Zd ZdZ� fdd�Zdd� Z� ZS )�PostgresBasea� Base class for Postgres-related lexers.
This is implemented as a mixin to avoid the Lexer metaclass kicking in.
this way the different lexer don't have a common Lexer ancestor. If they
had, _tokens could be created on this ancestor and not updated for the
other classes, resulting e.g. in PL/pgSQL parsed as SQL. This shortcoming
seem to suggest that regexp lexers are not really subclassable.
c '