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)
1013 state->callbacks = callbacks;
1078 state->std_strings = std_strings;
1083 state->scanline = line;
1090 state->cur_line_no = 0;
1150 if (
state->cur_line_no == 0)
1151 state->cur_line_no = 1;
1159 switch (
state->start_state)
1163 if (
state->paren_depth > 0)
1168 else if (
state->begin_depth > 0)
1261 if (
state->scanbufhandle)
1284 state->paren_depth = 0;
1286 if (
state->dolqstart)
1289 state->identifier_count = 0;
1290 state->begin_depth = 0;
1342 int *lineno,
int *offset)
1351 if (
state->cur_line_no == 0)
1364 state->cur_line_no++;
1370 *lineno =
state->cur_line_no;
1371 *offset =
state->cur_line_ptr -
state->scanbuf;
1381 const char *varname)
1397 if (
state->safe_encoding)
1492 if (
state->safe_encoding)
1527 if (
state->safe_encoding)
1532 const char *reference =
state->refline;
1535 reference += (
txt -
state->curline);
1537 for (
i = 0;
i <
len;
i++)
1541 if (
ch == (
char) 0xFF)
1559 if (
state->safe_encoding)
1564 const char *reference =
state->refline;
1567 reference += (
txt -
state->curline);
1569 for (
i = 0;
i <
len;
i++)
1573 if (
ch == (
char) 0xFF)
1599 if (
state->callbacks->get_variable)
1600 value =
state->callbacks->get_variable(varname, quote,
1601 state->cb_passthrough);
1626 if (
state->callbacks->get_variable)
1628 state->cb_passthrough);
#define Assert(condition)
#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