59#define LEXRES_BACKSLASH 2
62#define ECHO psqlscan_emit(cur_state, yytext, yyleng)
69%option never-interactive
75%option prefix="psql_yy"
81%option extra-type="PsqlScanState"
150non_newline_space [ \t\f\v]
154comment ("--"{non_newline}*)
156whitespace ({space}+|{comment})
165special_whitespace ({space}+|{comment}{newline})
166non_newline_whitespace ({non_newline_space}|{comment})
167whitespace_with_newline ({non_newline_whitespace}*{newline}{special_whitespace}*)
171quotecontinue {whitespace_with_newline}{quote}
180quotecontinuefail {whitespace}*"-"?
205xeoctesc [\\][0-7]{1,3}
206xehexesc [\\]x[0-9A-Fa-f]{1,2}
207xeunicode [\\](u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})
208xeunicodefail [\\](u[0-9A-Fa-f]{0,3}|U[0-9A-Fa-f]{0,7})
214xqdouble {quote}{quote}
226dolq_start [A-Za-z\200-\377_]
227dolq_cont [A-Za-z\200-\377_0-9]
228dolqdelim \$({dolq_start}{dolq_cont}*)?\$
229dolqfailed \${dolq_start}{dolq_cont}*
238xddouble {dquote}{dquote}
242xuistart [uU]&{dquote}
269xcstart \/\*{op_chars}*
273ident_start [A-Za-z\200-\377_]
274ident_cont [A-Za-z\200-\377_0-9\$]
276identifier {ident_start}{ident_cont}*
309self [,()\[\].;\:\|\+\-\*\/\%\^<>\=]
310op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%<>\=]
329decinteger {decdigit}(_?{decdigit})*
330hexinteger 0[xX](_?{hexdigit})+
331octinteger 0[oO](_?{octdigit})+
332bininteger 0[bB](_?{bindigit})+
338numeric (({decinteger}\.{decinteger}?)|(\.{decinteger}))
339numericfail {decinteger}\.\.
341real ({decinteger}|{numeric})[Ee][-+]?{decinteger}
342realfail ({decinteger}|{numeric})[Ee][-+]
364integer_junk {decinteger}{identifier}
365numeric_junk {numeric}{identifier}
366real_junk {real}{identifier}
367param_junk \${decdigit}+{identifier}
370variable_char [A-Za-z\200-\377_0-9]
392 PQExpBuffer output_buf =
cur_state->output_buf;
401 BEGIN(cur_state->start_state);
412 if (output_buf->len > 0)
494<xb,xh,xq,xe,xus>{quote} {
507<xqs>{quotecontinue} {
516<xqs>{quotecontinuefail} |
528<xq,xe,xus>{xqdouble} {
char * pg_strdup(const char *in)
void psqlscan_emit(PsqlScanState state, const char *txt, int len)
#define pg_log_warning(...)
char * psqlscan_extract_substring(PsqlScanState state, const char *txt, int len)
void psqlscan_push_new_buffer(PsqlScanState state, const char *newstr, const char *varname)
bool psqlscan_var_is_current_source(PsqlScanState state, const char *varname)
void psqlscan_escape_variable(PsqlScanState state, const char *txt, int len, PsqlScanQuoteType quote)
758:\"{variable_char}+\" {
763:\{\?{variable_char}+\} {
void psqlscan_test_variable(PsqlScanState state, const char *txt, int len)
784:\{\?{variable_char}* {
834 (
yytext[nchars - 1] ==
'+' ||
835 yytext[nchars - 1] ==
'-'))
839 for (
ic = nchars - 2;
ic >= 0;
ic--)
842 if (
c ==
'~' ||
c ==
'!' ||
c ==
'@' ||
843 c ==
'#' ||
c ==
'^' ||
c ==
'&' ||
844 c ==
'|' ||
c ==
'`' ||
c ==
'?' ||
856 }
while (nchars > 1 &&
857 (
yytext[nchars - 1] ==
'+' ||
858 yytext[nchars - 1] ==
'-'));
int pg_strcasecmp(const char *s1, const char *s2)
unsigned char pg_tolower(unsigned char ch)
void psqlscan_select_top_buffer(PsqlScanState state)
void psqlscan_pop_buffer_stack(PsqlScanState state)
1019 state->callbacks = callbacks;
1084 state->std_strings = std_strings;
1089 state->scanline = line;
1096 state->cur_line_no = 0;
1156 if (
state->cur_line_no == 0)
1157 state->cur_line_no = 1;
1165 switch (
state->start_state)
1169 if (
state->paren_depth > 0)
1174 else if (
state->begin_depth > 0)
1267 if (
state->scanbufhandle)
1290 state->paren_depth = 0;
1292 if (
state->dolqstart)
1295 state->identifier_count = 0;
1296 state->begin_depth = 0;
1348 int *lineno,
int *offset)
1357 if (
state->cur_line_no == 0)
1370 state->cur_line_no++;
1376 *lineno =
state->cur_line_no;
1377 *offset =
state->cur_line_ptr -
state->scanbuf;
1387 const char *varname)
1403 if (
state->safe_encoding)
1498 if (
state->safe_encoding)
1533 if (
state->safe_encoding)
1538 const char *reference =
state->refline;
1541 reference += (
txt -
state->curline);
1543 for (
i = 0;
i <
len;
i++)
1547 if (
ch == (
char) 0xFF)
1565 if (
state->safe_encoding)
1570 const char *reference =
state->refline;
1573 reference += (
txt -
state->curline);
1575 for (
i = 0;
i <
len;
i++)
1579 if (
ch == (
char) 0xFF)
1605 if (
state->callbacks->get_variable)
1606 value =
state->callbacks->get_variable(varname, quote,
1607 state->cb_passthrough);
1632 if (
state->callbacks->get_variable)
1634 state->cb_passthrough);
#define Assert(condition)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define fprintf(file, fmt, msg)
int PQmblen(const char *s, int encoding)
#define pg_malloc_array(type, count)
#define pg_malloc0_object(type)
#define pg_malloc_object(type)
#define pg_valid_server_encoding_id
void appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
enum _promptStatus promptStatus_t
YY_BUFFER_STATE psqlscan_prepare_buffer(PsqlScanState state, const char *txt, int len, char **txtcopy)
void psql_scan_get_location(PsqlScanState state, int *lineno, int *offset)
void psql_scan_reset(PsqlScanState state)
void psql_scan_destroy(PsqlScanState state)
PsqlScanResult psql_scan(PsqlScanState state, PQExpBuffer query_buf, promptStatus_t *prompt)
PsqlScanState psql_scan_create(const PsqlScanCallbacks *callbacks)
void psql_scan_set_passthrough(PsqlScanState state, void *passthrough)
void psql_scan_setup(PsqlScanState state, const char *line, int line_len, int encoding, bool std_strings)
void psql_scan_reselect_sql_lexer(PsqlScanState state)
bool psql_scan_in_quote(PsqlScanState state)
void psql_scan_finish(PsqlScanState state)
struct yy_buffer_state * YY_BUFFER_STATE