3
V'ícg
ã @ s$ d Z ddlZddlmZmZmZmZmZ ddlm Z m
Z
mZmZm
Z
mZmZmZmZmZmZ ddlmZmZ ddlmZmZmZmZ ddlmZmZmZm Z m!Z! ddlm"Z" d d
ddd
dddgZ#ej$dZ%ej$dZ&ej$dej'Z(ej$dej'Z)ej$dZ*ej$dZ+ej$dej'Z,ej$dej'Z-ej$dZ.dd Z/G dd dZ0G dd d e0eZ1G dd
d
e0eZ2G d d! d!e0eZ3ej$d"Z4ej$d#Z5ej$d$Z6ej$d%Z5ej$d&Z7ej$d'Z8G d(d) d)Z9G d*d deZ:G d+d deZ;G d,d
d
eZ<G d-d deZ=G d.d deZ>G d/d deZ?dS )0a
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.
The ``tests/examplefiles`` contains a few test files with data to be
parsed by these lexers.
:copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
é N)ÚLexerÚ
RegexLexerÚ
do_insertionsÚbygroupsÚwords)ÚPunctuationÚ
WhitespaceÚTextÚCommentÚOperatorÚKeywordÚNameÚStringÚNumberÚGenericÚLiteral)Úget_lexer_by_nameÚ
ClassNotFound)ÚKEYWORDSÚ DATATYPESÚPSEUDO_TYPESÚPLPGSQL_KEYWORDS)ÚMYSQL_CONSTANTSÚMYSQL_DATATYPESÚMYSQL_FUNCTIONSÚMYSQL_KEYWORDSÚMYSQL_OPTIMIZER_HINTS)Ú_tsql_builtinsÚ
PostgresLexerÚPlPgsqlLexerÚPostgresConsoleLexerÚ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| j|j |j d
}|dk r>| j|jd}n|tt j| jtd|j d |j
}|r| j|d
jd}n8tt
j| jtd|j d |j
}|rº| jd}|j dt|jdfV |j dtj|jdfV |j dt|jdfV |r"|j
|jd E dH n|j d t|jd fV |j d
t|jd
fV |j dtj|jdfV |j dt|jdfV 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)Úlexerr2 ÚlxÚm© r@ ú7/tmp/pip-build-gk9425m9/Pygments/pygments/lexers/sql.pyÚlanguage_callbackN s* $$
rB c s( e Zd ZdZ fddZdd 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 '