static const char * expr_source
static bool last_was_newline
static int expr_start_offset
static const char * expr_command
55%option never-interactive
61%option prefix="expr_yy"
64alpha [a-zA-Z\200-\377_]
66alnum [A-Za-z\200-\377_0-9]
69nonspace [^ \t\r\f\v\n]
73continuation \\\r?{newline}
85false [Ff][Aa][Ll][Ss][Ee]
88isnull [Ii][Ss][Nn][Uu][Ll][Ll]
89notnull [Nn][Oo][Tt][Nn][Uu][Ll][Ll]
98 PsqlScanState cur_state =
yyextra;
107 BEGIN(cur_state->start_state);
110 last_was_newline =
false;
void psqlscan_emit(PsqlScanState state, const char *txt, int len)
125{nonspace}+{continuation} {
128 if (yytext[wordlen] ==
'\r')
130 Assert(yytext[wordlen] ==
'\\');
Assert(PointerIsAligned(start, uint64))
155"<>" {
return NE_OP; }
156"!=" {
return NE_OP; }
157"<=" {
return LE_OP; }
158">=" {
return GE_OP; }
159"<<" {
return LS_OP; }
160">>" {
return RS_OP; }
172{and} {
return AND_OP; }
173{or} {
return OR_OP; }
174{not} {
return NOT_OP; }
175{is} {
return IS_OP; }
176{isnull} {
return ISNULL_OP; }
177{notnull} {
return NOTNULL_OP; }
179{case} {
return CASE_KW; }
180{when} {
return WHEN_KW; }
181{then} {
return THEN_KW; }
182{else} {
return ELSE_KW; }
183{end} {
return END_KW; }
char * pg_strdup(const char *in)
190{null} {
return NULL_CONST; }
193 return BOOLEAN_CONST;
196 yylval->bval =
false;
197 return BOOLEAN_CONST;
199"9223372036854775808" {
206 return MAXINT_PLUS_ONE_CONST;
212 return INTEGER_CONST;
void expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more)
bool strtoint64(const char *str, bool errorOK, int64 *result)
214{digit}+(\.{digit}*)?([eE][-+]?{digit}+)? {
bool strtodouble(const char *str, bool errorOK, double *dv)
220\.{digit}+([eE][-+]?{digit}+)? {
255 if (cur_state->buffer_stack == NULL)
void psqlscan_select_top_buffer(PsqlScanState state)
void psqlscan_pop_buffer_stack(PsqlScanState state)
275 int error_detection_offset;
280 error_detection_offset--;
289 while (
yylex(&lval, yyscanner))
327 state->output_buf = word_buf;
331 if (
state->buffer_stack != NULL)
332 yy_switch_to_buffer(
state->buffer_stack->buf,
state->scanner);
334 yy_switch_to_buffer(
state->scanbufhandle,
state->scanner);
337 state->start_state = INITIAL;
349 *offset = end_offset - word_buf->
len;
360 return (
bool) lexresult;
371 const char *
source,
int lineno,
int start_offset,
384 state->output_buf = NULL;
387 if (
state->buffer_stack != NULL)
388 yy_switch_to_buffer(
state->buffer_stack->buf,
state->scanner);
390 yy_switch_to_buffer(
state->scanbufhandle,
state->scanner);
393 state->start_state = EXPR;
395 return state->scanner;
430 const char *scanptr =
state->scanbuf + start_offset;
431 size_t slen = strlen(scanptr);
436 (scanptr[slen - 1] ==
'\n' || scanptr[slen - 1] ==
'\r'))
441 memcpy(result, scanptr, slen);
bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset)
char * expr_scanner_get_substring(PsqlScanState state, int start_offset, bool chomp)
void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message)
int yylex(YYSTYPE *yylval_param, yyscan_t yyscanner)
void expr_scanner_finish(yyscan_t yyscanner)
yyscan_t expr_scanner_init(PsqlScanState state, const char *source, int lineno, int start_offset, const char *command)
void * pg_malloc(size_t size)
static rewind_source * source
void syntax_error(const char *source, int lineno, const char *line, const char *command, const char *msg, const char *more, int column)
void resetPQExpBuffer(PQExpBuffer str)
void psql_scan_get_location(PsqlScanState state, int *lineno, int *offset)
void psql_scan_reselect_sql_lexer(PsqlScanState state)