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}*
307self [,()\[\].;\:\+\-\*\/\%\^<>\=]
308op_chars [\~\!\@\#\^\&\|\`\?\+\-\*\/\%<>\=]
327decinteger {decdigit}(_?{decdigit})*
328hexinteger 0[xX](_?{hexdigit})+
329octinteger 0[oO](_?{octdigit})+
330bininteger 0[bB](_?{bindigit})+
336numeric (({decinteger}\.{decinteger}?)|(\.{decinteger}))
337numericfail {decinteger}\.\.
339real ({decinteger}|{numeric})[Ee][-+]?{decinteger}
340realfail ({decinteger}|{numeric})[Ee][-+]
362integer_junk {decinteger}{identifier}
363numeric_junk {numeric}{identifier}
364real_junk {real}{identifier}
365param_junk \${decdigit}+{identifier}
368variable_char [A-Za-z\200-\377_0-9]
390 PQExpBuffer output_buf =
cur_state->output_buf;
399 BEGIN(cur_state->start_state);
410 if (output_buf->len > 0)
492<xb,xh,xq,xe,xus>{quote} {
505<xqs>{quotecontinue} {
514<xqs>{quotecontinuefail} |
526<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)
752:\"{variable_char}+\" {
757:\{\?{variable_char}+\} {
void psqlscan_test_variable(PsqlScanState state, const char *txt, int len)
778:\{\?{variable_char}* {
828 (
yytext[nchars - 1] ==
'+' ||
829 yytext[nchars - 1] ==
'-'))
833 for (
ic = nchars - 2;
ic >= 0;
ic--)
836 if (
c ==
'~' ||
c ==
'!' ||
c ==
'@' ||
837 c ==
'#' ||
c ==
'^' ||
c ==
'&' ||
838 c ==
'|' ||
c ==
'`' ||
c ==
'?' ||
850 }
while (nchars > 1 &&
851 (
yytext[nchars - 1] ==
'+' ||
852 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)
1007 state->callbacks = callbacks;
1072 state->std_strings = std_strings;
1077 state->scanline = line;
1084 state->cur_line_no = 0;
1144 if (
state->cur_line_no == 0)
1145 state->cur_line_no = 1;
1153 switch (
state->start_state)
1157 if (
state->paren_depth > 0)
1162 else if (
state->begin_depth > 0)
1255 if (
state->scanbufhandle)
1278 state->paren_depth = 0;
1280 if (
state->dolqstart)
1283 state->identifier_count = 0;
1284 state->begin_depth = 0;
1336 int *lineno,
int *offset)
1345 if (
state->cur_line_no == 0)
1358 state->cur_line_no++;
1364 *lineno =
state->cur_line_no;
1365 *offset =
state->cur_line_ptr -
state->scanbuf;
1375 const char *varname)
1391 if (
state->safe_encoding)
1486 if (
state->safe_encoding)
1521 if (
state->safe_encoding)
1526 const char *reference =
state->refline;
1529 reference += (
txt -
state->curline);
1531 for (
i = 0;
i <
len;
i++)
1535 if (
ch == (
char) 0xFF)
1553 if (
state->safe_encoding)
1558 const char *reference =
state->refline;
1561 reference += (
txt -
state->curline);
1563 for (
i = 0;
i <
len;
i++)
1567 if (
ch == (
char) 0xFF)
1593 if (
state->callbacks->get_variable)
1594 value =
state->callbacks->get_variable(varname, quote,
1595 state->cb_passthrough);
1620 if (
state->callbacks->get_variable)
1622 state->cb_passthrough);
#define Assert(condition)
#define fprintf(file, fmt, msg)
int PQmblen(const char *s, int encoding)
void * pg_malloc(size_t size)
void * pg_malloc0(size_t size)
#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