diff --git a/README.md b/README.md index 379b536..437bcdb 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,40 @@ Libraries: Binaries: -* `psql` +* `clusterdb` +* `createdb` +* `createuser` +* `dropdb` +* `dropuser` * `initdb` +* `pg_amcheck` +* `pg_archivecleanup` +* `pg_basebackup` +* `pg_checksums` +* `pg_combinebackup` (17+) +* `pg_config` +* `pg_controldata` +* `pg_createsubscriber` (17+) * `pg_ctl` +* `pg_dump` +* `pg_dumpall` +* `pg_isready` +* `pg_receivewal` +* `pg_recvlogical` +* `pg_resetwal` +* `pg_restore` +* `pg_rewind` +* `pg_test_fsync` +* `pg_test_timing` +* `pg_upgrade` +* `pg_verifybackup` +* `pg_waldump` +* `pg_walsummary` (17+) +* `pgbench` * `postgres` +* `psql` +* `reindexdb` +* `vacuumdb` For using each of these binaries as tools or via `bazel run`, use the `_bin` suffixed version of each of those targets. They pull all dependent files in as runfiles, ensure that postgres has its expected path layout, and executes the binary in the right bazel configuration. diff --git a/postgres_bazel/default_repo.bzl b/postgres_bazel/default_repo.bzl index eab5974..d74403b 100644 --- a/postgres_bazel/default_repo.bzl +++ b/postgres_bazel/default_repo.bzl @@ -2,12 +2,19 @@ def _postgres_default_repo_impl(repository_ctx): template = repository_ctx.read(repository_ctx.attr._build_file) - repository_ctx.file("BUILD.bazel", template.replace("{repo}", repository_ctx.attr.target_repo)) + repository_ctx.file("BUILD.bazel", template.replace( + "{repo}", + repository_ctx.attr.target_repo, + ).replace( + "{major}", + repository_ctx.attr.major, + )) postgres_default_repo = repository_rule( implementation = _postgres_default_repo_impl, doc = "Aliases every public target of a versioned postgres repository.", attrs = { + "major": attr.string(mandatory = True, doc = "Major version of the versioned repository's template."), "target_repo": attr.string(mandatory = True, doc = "Apparent name of the versioned repository."), "_build_file": attr.label(default = "//templates:default/BUILD.bazel.template"), }, diff --git a/postgres_bazel/extension.bzl b/postgres_bazel/extension.bzl index a15dd7d..85425d6 100644 --- a/postgres_bazel/extension.bzl +++ b/postgres_bazel/extension.bzl @@ -74,7 +74,7 @@ def _postgres_impl(module_ctx): version = tag.version, ) created.append(name) - repo_for_version.setdefault(tag.version, name) + repo_for_version.setdefault(tag.version, (name, major)) for module in module_ctx.modules: for tag in module.tags.default_version: @@ -85,9 +85,11 @@ def _postgres_impl(module_ctx): tag.version, ", ".join(sorted(repo_for_version)), )) + target_repo, major = repo_for_version[tag.version] postgres_default_repo( name = tag.repo_name, - target_repo = repo_for_version[tag.version], + major = major, + target_repo = target_repo, ) created.append(tag.repo_name) diff --git a/postgres_bazel/templates/17.0/files.manifest b/postgres_bazel/templates/17.0/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.0/files.manifest +++ b/postgres_bazel/templates/17.0/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.0/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.1/files.manifest b/postgres_bazel/templates/17.1/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.1/files.manifest +++ b/postgres_bazel/templates/17.1/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.1/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.10/files.manifest b/postgres_bazel/templates/17.10/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.10/files.manifest +++ b/postgres_bazel/templates/17.10/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.10/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.2/files.manifest b/postgres_bazel/templates/17.2/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.2/files.manifest +++ b/postgres_bazel/templates/17.2/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.2/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.3/files.manifest b/postgres_bazel/templates/17.3/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.3/files.manifest +++ b/postgres_bazel/templates/17.3/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.3/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.4/files.manifest b/postgres_bazel/templates/17.4/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.4/files.manifest +++ b/postgres_bazel/templates/17.4/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.4/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.5/files.manifest b/postgres_bazel/templates/17.5/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.5/files.manifest +++ b/postgres_bazel/templates/17.5/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.5/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.6/files.manifest b/postgres_bazel/templates/17.6/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.6/files.manifest +++ b/postgres_bazel/templates/17.6/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.6/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.7/files.manifest b/postgres_bazel/templates/17.7/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.7/files.manifest +++ b/postgres_bazel/templates/17.7/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.7/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.8/files.manifest b/postgres_bazel/templates/17.8/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.8/files.manifest +++ b/postgres_bazel/templates/17.8/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.8/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/17.9/files.manifest b/postgres_bazel/templates/17.9/files.manifest index 7b2b252..557ccf6 100644 --- a/postgres_bazel/templates/17.9/files.manifest +++ b/postgres_bazel/templates/17.9/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..847be59 --- /dev/null +++ b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2362 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +PgBenchExpr *expr_parse_result; + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 205 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 218 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 83, 83, 88, 89, 90, 93, 94, 96, 99, + 102, 104, 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 124, 125, 129, 130, 135, 139, 145, 146, 147, 148, + 150, 151, 152, 156, 157, 160, 161, 163 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (yyscan_t yyscanner) +#else +int +yyparse (yyscanner) + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 83 "src/bin/pgbench/exprparse.y" + { + expr_parse_result = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 90 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 94 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 96 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 100 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 102 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 122 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 124 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 125 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 129 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 131 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 136 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 140 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 148 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 152 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 157 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 161 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 163 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1782 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yyscanner, yymsg); + } + else + { + yyerror (yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 166 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..56d274e --- /dev/null +++ b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 49 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..07b0c2d --- /dev/null +++ b/postgres_bazel/templates/17.9/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2844 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* + * Work around a bug in flex 2.5.35: it emits a couple of functions that + * it forgets to emit declarations for. Since we use -Wmissing-prototypes, + * this would cause warnings. Providing our own declarations should be + * harmless even when the bug gets fixed. + */ +extern int expr_yyget_column(yyscan_t yyscanner); +extern void expr_yyset_column(int column_no, yyscan_t yyscanner); + +/* LCOV_EXCL_START */ + +#line 798 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 807 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 103 "src/bin/pgbench/exprscan.l" + + + +#line 107 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1103 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 125 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 135 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 145 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 147 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 149 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 168 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 172 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 185 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 187 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 189 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 190 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 193 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 195 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 201 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 205 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 218 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 224 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 230 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 241 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 243 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 245 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 251 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 264 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 276 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1502 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 276 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int error_detection_offset = expr_scanner_offset(state) - 1; + YYSTYPE lval; + char *full_line; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + expr_scanner_offset(state), + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +void +expr_yyerror(yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* + * Save start offset of word, if any. We could do this more efficiently, + * but for now this seems fine. + */ + if (lexresult) + *offset = expr_scanner_offset(state) - word_buf->len; + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get offset from start of string to end of current lexer token. + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. + */ +int +expr_scanner_offset(PsqlScanState state) +{ + return strlen(state->scanbuf); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to just before end_offset. If chomp is true, drop any trailing + * newline(s). + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, int end_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + int slen = end_offset - start_offset; + + Assert(slen >= 0); + Assert(end_offset <= strlen(state->scanbuf)); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + +/* + * Get the line number associated with the given string offset + * (which must not be past the end of where we've lexed to). + */ +int +expr_scanner_get_lineno(PsqlScanState state, int offset) +{ + int lineno = 1; + const char *p = state->scanbuf; + + while (*p && offset > 0) + { + if (*p == '\n') + lineno++; + p++, offset--; + } + return lineno; +} + diff --git a/postgres_bazel/templates/18.0/files.manifest b/postgres_bazel/templates/18.0/files.manifest index 5aab7a6..c031583 100644 --- a/postgres_bazel/templates/18.0/files.manifest +++ b/postgres_bazel/templates/18.0/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..c275476 --- /dev/null +++ b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2370 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 203 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 82, 82, 87, 88, 89, 92, 93, 95, 98, + 101, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 123, 124, 128, 129, 134, 138, 144, 145, 146, 147, + 149, 150, 151, 155, 156, 159, 160, 162 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, expr_parse_result_p, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, expr_parse_result_p, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , expr_parse_result_p, yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, expr_parse_result_p, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, expr_parse_result_p, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +int +yyparse (expr_parse_result_p, yyscanner) + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 82 "src/bin/pgbench/exprparse.y" + { + *expr_parse_result_p = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 87 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 92 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 95 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 99 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 101 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 103 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 123 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 124 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 128 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 130 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 135 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 139 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 144 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 149 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 155 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 159 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 162 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1787 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (expr_parse_result_p, yyscanner, yymsg); + } + else + { + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, expr_parse_result_p, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, expr_parse_result_p, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 165 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = + +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..3d19aa5 --- /dev/null +++ b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..8503fd6 --- /dev/null +++ b/postgres_bazel/templates/18.0/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2816 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* LCOV_EXCL_START */ + +#line 789 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 798 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 94 "src/bin/pgbench/exprscan.l" + + + +#line 98 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1094 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 116 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 126 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 136 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 138 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 140 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 150 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 151 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 152 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 153 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 154 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 155 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 156 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 157 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 158 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 177 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 181 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 196 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 215 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 221 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 227 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 232 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 234 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 242 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 255 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 267 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1493 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 267 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int lineno; + int error_detection_offset; + YYSTYPE lval; + char *full_line; + + psql_scan_get_location(state, &lineno, &error_detection_offset); + error_detection_offset--; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +/* + * (The first argument is enforced by Bison to match the first argument of + * yyparse(), but it is not used here.) + */ +void +expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* Save start offset of word, if any. */ + if (lexresult) + { + int lineno; + int end_offset; + + psql_scan_get_location(state, &lineno, &end_offset); + *offset = end_offset - word_buf->len; + } + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to end of current lexer token. If chomp is true, drop any trailing + * newline(s). + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. Also, this will + * give the wrong answer (the whole remainder of the input) if called + * before any yylex() call has been done. + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + size_t slen = strlen(scanptr); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + diff --git a/postgres_bazel/templates/18.1/files.manifest b/postgres_bazel/templates/18.1/files.manifest index 5aab7a6..c031583 100644 --- a/postgres_bazel/templates/18.1/files.manifest +++ b/postgres_bazel/templates/18.1/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..c275476 --- /dev/null +++ b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2370 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 203 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 82, 82, 87, 88, 89, 92, 93, 95, 98, + 101, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 123, 124, 128, 129, 134, 138, 144, 145, 146, 147, + 149, 150, 151, 155, 156, 159, 160, 162 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, expr_parse_result_p, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, expr_parse_result_p, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , expr_parse_result_p, yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, expr_parse_result_p, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, expr_parse_result_p, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +int +yyparse (expr_parse_result_p, yyscanner) + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 82 "src/bin/pgbench/exprparse.y" + { + *expr_parse_result_p = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 87 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 92 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 95 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 99 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 101 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 103 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 123 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 124 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 128 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 130 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 135 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 139 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 144 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 149 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 155 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 159 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 162 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1787 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (expr_parse_result_p, yyscanner, yymsg); + } + else + { + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, expr_parse_result_p, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, expr_parse_result_p, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 165 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = + +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..3d19aa5 --- /dev/null +++ b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..8503fd6 --- /dev/null +++ b/postgres_bazel/templates/18.1/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2816 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* LCOV_EXCL_START */ + +#line 789 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 798 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 94 "src/bin/pgbench/exprscan.l" + + + +#line 98 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1094 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 116 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 126 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 136 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 138 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 140 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 150 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 151 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 152 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 153 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 154 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 155 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 156 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 157 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 158 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 177 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 181 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 196 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 215 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 221 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 227 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 232 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 234 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 242 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 255 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 267 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1493 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 267 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int lineno; + int error_detection_offset; + YYSTYPE lval; + char *full_line; + + psql_scan_get_location(state, &lineno, &error_detection_offset); + error_detection_offset--; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +/* + * (The first argument is enforced by Bison to match the first argument of + * yyparse(), but it is not used here.) + */ +void +expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* Save start offset of word, if any. */ + if (lexresult) + { + int lineno; + int end_offset; + + psql_scan_get_location(state, &lineno, &end_offset); + *offset = end_offset - word_buf->len; + } + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to end of current lexer token. If chomp is true, drop any trailing + * newline(s). + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. Also, this will + * give the wrong answer (the whole remainder of the input) if called + * before any yylex() call has been done. + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + size_t slen = strlen(scanptr); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + diff --git a/postgres_bazel/templates/18.2/files.manifest b/postgres_bazel/templates/18.2/files.manifest index 5aab7a6..c031583 100644 --- a/postgres_bazel/templates/18.2/files.manifest +++ b/postgres_bazel/templates/18.2/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..c275476 --- /dev/null +++ b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2370 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 203 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 82, 82, 87, 88, 89, 92, 93, 95, 98, + 101, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 123, 124, 128, 129, 134, 138, 144, 145, 146, 147, + 149, 150, 151, 155, 156, 159, 160, 162 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, expr_parse_result_p, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, expr_parse_result_p, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , expr_parse_result_p, yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, expr_parse_result_p, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, expr_parse_result_p, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +int +yyparse (expr_parse_result_p, yyscanner) + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 82 "src/bin/pgbench/exprparse.y" + { + *expr_parse_result_p = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 87 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 92 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 95 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 99 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 101 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 103 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 123 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 124 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 128 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 130 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 135 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 139 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 144 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 149 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 155 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 159 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 162 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1787 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (expr_parse_result_p, yyscanner, yymsg); + } + else + { + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, expr_parse_result_p, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, expr_parse_result_p, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 165 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = + +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..3d19aa5 --- /dev/null +++ b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..8503fd6 --- /dev/null +++ b/postgres_bazel/templates/18.2/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2816 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* LCOV_EXCL_START */ + +#line 789 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 798 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 94 "src/bin/pgbench/exprscan.l" + + + +#line 98 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1094 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 116 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 126 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 136 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 138 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 140 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 150 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 151 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 152 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 153 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 154 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 155 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 156 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 157 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 158 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 177 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 181 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 196 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 215 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 221 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 227 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 232 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 234 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 242 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 255 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 267 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1493 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 267 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int lineno; + int error_detection_offset; + YYSTYPE lval; + char *full_line; + + psql_scan_get_location(state, &lineno, &error_detection_offset); + error_detection_offset--; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +/* + * (The first argument is enforced by Bison to match the first argument of + * yyparse(), but it is not used here.) + */ +void +expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* Save start offset of word, if any. */ + if (lexresult) + { + int lineno; + int end_offset; + + psql_scan_get_location(state, &lineno, &end_offset); + *offset = end_offset - word_buf->len; + } + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to end of current lexer token. If chomp is true, drop any trailing + * newline(s). + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. Also, this will + * give the wrong answer (the whole remainder of the input) if called + * before any yylex() call has been done. + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + size_t slen = strlen(scanptr); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + diff --git a/postgres_bazel/templates/18.3/files.manifest b/postgres_bazel/templates/18.3/files.manifest index 5aab7a6..c031583 100644 --- a/postgres_bazel/templates/18.3/files.manifest +++ b/postgres_bazel/templates/18.3/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..c275476 --- /dev/null +++ b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2370 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 203 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 82, 82, 87, 88, 89, 92, 93, 95, 98, + 101, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 123, 124, 128, 129, 134, 138, 144, 145, 146, 147, + 149, 150, 151, 155, 156, 159, 160, 162 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, expr_parse_result_p, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, expr_parse_result_p, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , expr_parse_result_p, yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, expr_parse_result_p, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, expr_parse_result_p, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +int +yyparse (expr_parse_result_p, yyscanner) + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 82 "src/bin/pgbench/exprparse.y" + { + *expr_parse_result_p = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 87 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 92 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 95 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 99 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 101 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 103 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 123 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 124 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 128 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 130 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 135 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 139 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 144 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 149 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 155 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 159 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 162 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1787 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (expr_parse_result_p, yyscanner, yymsg); + } + else + { + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, expr_parse_result_p, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, expr_parse_result_p, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 165 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = + +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..3d19aa5 --- /dev/null +++ b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..8503fd6 --- /dev/null +++ b/postgres_bazel/templates/18.3/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2816 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* LCOV_EXCL_START */ + +#line 789 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 798 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 94 "src/bin/pgbench/exprscan.l" + + + +#line 98 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1094 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 116 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 126 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 136 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 138 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 140 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 150 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 151 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 152 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 153 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 154 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 155 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 156 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 157 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 158 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 177 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 181 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 196 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 215 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 221 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 227 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 232 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 234 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 242 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 255 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 267 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1493 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 267 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int lineno; + int error_detection_offset; + YYSTYPE lval; + char *full_line; + + psql_scan_get_location(state, &lineno, &error_detection_offset); + error_detection_offset--; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +/* + * (The first argument is enforced by Bison to match the first argument of + * yyparse(), but it is not used here.) + */ +void +expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* Save start offset of word, if any. */ + if (lexresult) + { + int lineno; + int end_offset; + + psql_scan_get_location(state, &lineno, &end_offset); + *offset = end_offset - word_buf->len; + } + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to end of current lexer token. If chomp is true, drop any trailing + * newline(s). + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. Also, this will + * give the wrong answer (the whole remainder of the input) if called + * before any yylex() call has been done. + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + size_t slen = strlen(scanptr); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + diff --git a/postgres_bazel/templates/18.4/files.manifest b/postgres_bazel/templates/18.4/files.manifest index 5aab7a6..c031583 100644 --- a/postgres_bazel/templates/18.4/files.manifest +++ b/postgres_bazel/templates/18.4/files.manifest @@ -32,6 +32,9 @@ src/backend/utils/fmgroids.h src/backend/utils/fmgrprotos.h src/backend/utils/fmgrtab.c src/backend/utils/misc/guc-file.c +src/bin/pgbench/exprparse.c +src/bin/pgbench/exprparse.h +src/bin/pgbench/exprscan.c src/bin/psql/psqlscanslash.c src/bin/psql/sql_help.c src/bin/psql/sql_help.h diff --git a/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.c b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.c new file mode 100644 index 0000000..c275476 --- /dev/null +++ b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.c @@ -0,0 +1,2370 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse expr_yyparse +#define yylex expr_yylex +#define yyerror expr_yyerror +#define yylval expr_yylval +#define yychar expr_yychar +#define yydebug expr_yydebug +#define yynerrs expr_yynerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "src/bin/pgbench/exprparse.y" + +/*------------------------------------------------------------------------- + * + * exprparse.y + * bison grammar for a simple expression syntax + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprparse.y + * + *------------------------------------------------------------------------- + */ + +#include "postgres_fe.h" + +#include "pgbench.h" + +#define PGBENCH_NARGS_VARIABLE (-1) +#define PGBENCH_NARGS_CASE (-2) +#define PGBENCH_NARGS_HASH (-3) +#define PGBENCH_NARGS_PERMUTE (-4) + +static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list); +static PgBenchExpr *make_null_constant(void); +static PgBenchExpr *make_boolean_constant(bool bval); +static PgBenchExpr *make_integer_constant(int64 ival); +static PgBenchExpr *make_double_constant(double dval); +static PgBenchExpr *make_variable(char *varname); +static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr); +static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr); +static int find_func(yyscan_t yyscanner, const char *fname); +static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args); +static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part); + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 193 of yacc.c. */ +#line 203 "src/bin/pgbench/exprparse.c" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 216 "src/bin/pgbench/exprparse.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 25 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 320 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 42 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 47 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 88 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 30, 2, 37, 31, 2, + 40, 41, 35, 33, 39, 34, 2, 36, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 26, 28, 27, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 29, 2, 32, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 38 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 6, 8, 12, 16, 19, 22, + 25, 28, 31, 35, 39, 43, 47, 51, 55, 59, + 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, + 103, 106, 109, 113, 118, 122, 127, 129, 131, 133, + 135, 137, 142, 144, 150, 155, 159, 165 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 43, 0, -1, 45, -1, -1, 45, -1, 44, 39, + 45, -1, 40, 45, 41, -1, 33, 45, -1, 34, + 45, -1, 34, 5, -1, 32, 45, -1, 12, 45, + -1, 45, 33, 45, -1, 45, 34, 45, -1, 45, + 35, 45, -1, 45, 36, 45, -1, 45, 37, 45, + -1, 45, 26, 45, -1, 45, 14, 45, -1, 45, + 27, 45, -1, 45, 15, 45, -1, 45, 28, 45, + -1, 45, 13, 45, -1, 45, 31, 45, -1, 45, + 29, 45, -1, 45, 30, 45, -1, 45, 16, 45, + -1, 45, 17, 45, -1, 45, 10, 45, -1, 45, + 11, 45, -1, 45, 25, -1, 45, 24, -1, 45, + 18, 3, -1, 45, 18, 12, 3, -1, 45, 18, + 7, -1, 45, 18, 12, 7, -1, 3, -1, 7, + -1, 4, -1, 6, -1, 8, -1, 48, 40, 44, + 41, -1, 47, -1, 46, 20, 45, 21, 45, -1, + 20, 45, 21, 45, -1, 19, 46, 23, -1, 19, + 46, 22, 45, 23, -1, 9, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 82, 82, 87, 88, 89, 92, 93, 95, 98, + 101, 103, 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 123, 124, 128, 129, 134, 138, 144, 145, 146, 147, + 149, 150, 151, 155, 156, 159, 160, 162 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "NULL_CONST", "INTEGER_CONST", + "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST", "BOOLEAN_CONST", "VARIABLE", + "FUNCTION", "AND_OP", "OR_OP", "NOT_OP", "NE_OP", "LE_OP", "GE_OP", + "LS_OP", "RS_OP", "IS_OP", "CASE_KW", "WHEN_KW", "THEN_KW", "ELSE_KW", + "END_KW", "NOTNULL_OP", "ISNULL_OP", "'<'", "'>'", "'='", "'|'", "'#'", + "'&'", "'~'", "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "','", "'('", + "')'", "$accept", "result", "elist", "expr", "when_then_list", + "case_control", "function", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 60, 62, 61, 124, + 35, 38, 126, 43, 45, 42, 47, 37, 281, 44, + 40, 41 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 42, 43, 44, 44, 44, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 46, 46, 47, 47, 48 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 1, 3, 3, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 2, 3, 4, 3, 4, 1, 1, 1, 1, + 1, 4, 1, 5, 4, 3, 5, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 36, 38, 39, 37, 40, 47, 0, 0, 0, + 0, 0, 0, 0, 2, 42, 0, 11, 0, 0, + 10, 7, 9, 8, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 31, 30, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, + 0, 45, 6, 28, 29, 22, 18, 20, 26, 27, + 32, 34, 0, 17, 19, 21, 24, 25, 23, 12, + 13, 14, 15, 16, 0, 4, 0, 0, 0, 33, + 35, 0, 41, 44, 0, 46, 5, 43 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 13, 74, 14, 19, 15, 16 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -33 +static const yytype_int16 yypact[] = +{ + 64, -33, -33, -33, -33, -33, -33, 64, -19, 64, + 64, 46, 64, 13, 205, -33, -22, 258, 64, -6, + 11, -33, -33, -33, 92, -33, 64, 64, 64, 64, + 64, 64, 64, 3, -33, -33, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 121, 64, + 64, -33, -33, 258, 233, 283, 283, 283, 11, 11, + -33, -33, 5, 283, 283, 283, 11, 11, 11, -9, + -9, -33, -33, -33, -32, 205, 64, 149, 177, -33, + -33, 64, -33, 205, 64, -33, 205, 205 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -33, -33, -33, -7, -33, -33, -33 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_int8 yytable[] = +{ + 17, 18, 20, 21, 23, 24, 60, 81, 79, 82, + 61, 48, 80, 25, 49, 62, 50, 51, 47, 53, + 54, 55, 56, 57, 58, 59, 44, 45, 46, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 75, 0, 77, 78, 42, 43, 44, 45, 46, 1, + 2, 22, 3, 4, 5, 6, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 8, 0, 1, 2, 83, + 3, 4, 5, 6, 86, 0, 7, 87, 9, 10, + 11, 0, 0, 8, 0, 0, 12, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 9, 10, 11, 0, + 0, 0, 26, 27, 12, 28, 29, 30, 31, 32, + 33, 0, 0, 0, 0, 0, 34, 35, 36, 37, + 38, 39, 40, 41, 0, 42, 43, 44, 45, 46, + 0, 26, 27, 52, 28, 29, 30, 31, 32, 33, + 0, 0, 76, 0, 0, 34, 35, 36, 37, 38, + 39, 40, 41, 0, 42, 43, 44, 45, 46, 26, + 27, 0, 28, 29, 30, 31, 32, 33, 0, 0, + 84, 0, 0, 34, 35, 36, 37, 38, 39, 40, + 41, 0, 42, 43, 44, 45, 46, 26, 27, 0, + 28, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 85, 34, 35, 36, 37, 38, 39, 40, 41, 0, + 42, 43, 44, 45, 46, 26, 27, 0, 28, 29, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 34, + 35, 36, 37, 38, 39, 40, 41, 0, 42, 43, + 44, 45, 46, 26, 0, 0, 28, 29, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 34, 35, 36, + 37, 38, 39, 40, 41, 0, 42, 43, 44, 45, + 46, 28, 29, 30, 31, 32, 33, 0, 0, 0, + 0, 0, 34, 35, 36, 37, 38, 39, 40, 41, + 0, 42, 43, 44, 45, 46, -1, -1, -1, 31, + 32, 0, 0, 0, 0, 0, 0, 0, 0, -1, + -1, -1, 39, 40, 41, 0, 42, 43, 44, 45, + 46 +}; + +static const yytype_int8 yycheck[] = +{ + 7, 20, 9, 10, 11, 12, 3, 39, 3, 41, + 7, 18, 7, 0, 20, 12, 22, 23, 40, 26, + 27, 28, 29, 30, 31, 32, 35, 36, 37, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, -1, 49, 50, 33, 34, 35, 36, 37, 3, + 4, 5, 6, 7, 8, 9, -1, -1, 12, -1, + -1, -1, -1, -1, -1, 19, -1, 3, 4, 76, + 6, 7, 8, 9, 81, -1, 12, 84, 32, 33, + 34, -1, -1, 19, -1, -1, 40, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 32, 33, 34, -1, + -1, -1, 10, 11, 40, 13, 14, 15, 16, 17, + 18, -1, -1, -1, -1, -1, 24, 25, 26, 27, + 28, 29, 30, 31, -1, 33, 34, 35, 36, 37, + -1, 10, 11, 41, 13, 14, 15, 16, 17, 18, + -1, -1, 21, -1, -1, 24, 25, 26, 27, 28, + 29, 30, 31, -1, 33, 34, 35, 36, 37, 10, + 11, -1, 13, 14, 15, 16, 17, 18, -1, -1, + 21, -1, -1, 24, 25, 26, 27, 28, 29, 30, + 31, -1, 33, 34, 35, 36, 37, 10, 11, -1, + 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, + 33, 34, 35, 36, 37, 10, 11, -1, 13, 14, + 15, 16, 17, 18, -1, -1, -1, -1, -1, 24, + 25, 26, 27, 28, 29, 30, 31, -1, 33, 34, + 35, 36, 37, 10, -1, -1, 13, 14, 15, 16, + 17, 18, -1, -1, -1, -1, -1, 24, 25, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37, 13, 14, 15, 16, 17, 18, -1, -1, -1, + -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, + -1, 33, 34, 35, 36, 37, 13, 14, 15, 16, + 17, -1, -1, -1, -1, -1, -1, -1, -1, 26, + 27, 28, 29, 30, 31, -1, 33, 34, 35, 36, + 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 3, 4, 6, 7, 8, 9, 12, 19, 32, + 33, 34, 40, 43, 45, 47, 48, 45, 20, 46, + 45, 45, 5, 45, 45, 0, 10, 11, 13, 14, + 15, 16, 17, 18, 24, 25, 26, 27, 28, 29, + 30, 31, 33, 34, 35, 36, 37, 40, 45, 20, + 22, 23, 41, 45, 45, 45, 45, 45, 45, 45, + 3, 7, 12, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 45, 45, 44, 45, 21, 45, 45, 3, + 7, 39, 41, 45, 21, 23, 45, 45 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, yyscanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, expr_parse_result_p, yyscanner); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (!yyvaluep) + return; + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, expr_parse_result_p, yyscanner); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yy_reduce_print (yyvsp, yyrule, expr_parse_result_p, yyscanner) + YYSTYPE *yyvsp; + int yyrule; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , expr_parse_result_p, yyscanner); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, expr_parse_result_p, yyscanner); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, expr_parse_result_p, yyscanner) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +{ + YYUSE (yyvaluep); + YYUSE (expr_parse_result_p); + YYUSE (yyscanner); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner) +#else +int +yyparse (expr_parse_result_p, yyscanner) + PgBenchExpr **expr_parse_result_p; + yyscan_t yyscanner; +#endif +#endif +{ + /* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 82 "src/bin/pgbench/exprparse.y" + { + *expr_parse_result_p = (yyvsp[(1) - (1)].expr); + (void) yynerrs; /* suppress compiler warning */ + ;} + break; + + case 3: +#line 87 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = NULL; ;} + break; + + case 4: +#line 88 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(1) - (1)].expr), NULL); ;} + break; + + case 5: +#line 89 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].elist)); ;} + break; + + case 6: +#line 92 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} + break; + + case 7: +#line 93 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} + break; + + case 8: +#line 95 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", + make_integer_constant(0), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 9: +#line 99 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant(PG_INT64_MIN); ;} + break; + + case 10: +#line 101 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", + make_integer_constant(~INT64CONST(0)), (yyvsp[(2) - (2)].expr)); ;} + break; + + case 11: +#line 103 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[(2) - (2)].expr)); ;} + break; + + case 12: +#line 104 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 13: +#line 105 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 14: +#line 106 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 15: +#line 107 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 16: +#line 108 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 17: +#line 109 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 18: +#line 110 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 19: +#line 111 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 20: +#line 112 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[(3) - (3)].expr), (yyvsp[(1) - (3)].expr)); ;} + break; + + case 21: +#line 113 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 22: +#line 114 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 23: +#line 115 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 24: +#line 116 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 25: +#line 117 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 26: +#line 118 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 27: +#line 119 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 28: +#line 120 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 29: +#line 121 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} + break; + + case 30: +#line 123 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant()); ;} + break; + + case 31: +#line 124 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (2)].expr), make_null_constant())); + ;} + break; + + case 32: +#line 128 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_null_constant()); ;} + break; + + case 33: +#line 130 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_null_constant())); + ;} + break; + + case 34: +#line 135 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[(1) - (3)].expr), make_boolean_constant((yyvsp[(3) - (3)].bval))); + ;} + break; + + case 35: +#line 139 "src/bin/pgbench/exprparse.y" + { + (yyval.expr) = make_uop(yyscanner, "!not", + make_op(yyscanner, "!is", (yyvsp[(1) - (4)].expr), make_boolean_constant((yyvsp[(4) - (4)].bval)))); + ;} + break; + + case 36: +#line 144 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_null_constant(); ;} + break; + + case 37: +#line 145 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_boolean_constant((yyvsp[(1) - (1)].bval)); ;} + break; + + case 38: +#line 146 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_integer_constant((yyvsp[(1) - (1)].ival)); ;} + break; + + case 39: +#line 147 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_double_constant((yyvsp[(1) - (1)].dval)); ;} + break; + + case 40: +#line 149 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_variable((yyvsp[(1) - (1)].str)); ;} + break; + + case 41: +#line 150 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_func(yyscanner, (yyvsp[(1) - (4)].ival), (yyvsp[(3) - (4)].elist)); ;} + break; + + case 42: +#line 151 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} + break; + + case 43: +#line 155 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(5) - (5)].expr), make_elist((yyvsp[(3) - (5)].expr), (yyvsp[(1) - (5)].elist))); ;} + break; + + case 44: +#line 156 "src/bin/pgbench/exprparse.y" + { (yyval.elist) = make_elist((yyvsp[(4) - (4)].expr), make_elist((yyvsp[(2) - (4)].expr), NULL)); ;} + break; + + case 45: +#line 159 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (3)].elist), make_null_constant()); ;} + break; + + case 46: +#line 160 "src/bin/pgbench/exprparse.y" + { (yyval.expr) = make_case(yyscanner, (yyvsp[(2) - (5)].elist), (yyvsp[(4) - (5)].expr)); ;} + break; + + case 47: +#line 162 "src/bin/pgbench/exprparse.y" + { (yyval.ival) = find_func(yyscanner, (yyvsp[(1) - (1)].str)); pg_free((yyvsp[(1) - (1)].str)); ;} + break; + + +/* Line 1267 of yacc.c. */ +#line 1787 "src/bin/pgbench/exprparse.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (expr_parse_result_p, yyscanner, yymsg); + } + else + { + yyerror (expr_parse_result_p, yyscanner, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, expr_parse_result_p, yyscanner); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, expr_parse_result_p, yyscanner); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, expr_parse_result_p, yyscanner); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 165 "src/bin/pgbench/exprparse.y" + + +static PgBenchExpr * +make_null_constant(void) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_NULL; + expr->u.constant.u.ival = 0; + return expr; +} + +static PgBenchExpr * +make_integer_constant(int64 ival) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_INT; + expr->u.constant.u.ival = ival; + return expr; +} + +static PgBenchExpr * +make_double_constant(double dval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_DOUBLE; + expr->u.constant.u.dval = dval; + return expr; +} + +static PgBenchExpr * +make_boolean_constant(bool bval) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_CONSTANT; + expr->u.constant.type = PGBT_BOOLEAN; + expr->u.constant.u.bval = bval; + return expr; +} + +static PgBenchExpr * +make_variable(char *varname) +{ + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + expr->etype = ENODE_VARIABLE; + expr->u.variable.varname = varname; + return expr; +} + +/* binary operators */ +static PgBenchExpr * +make_op(yyscan_t yyscanner, const char *operator, + PgBenchExpr *lexpr, PgBenchExpr *rexpr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), + make_elist(rexpr, make_elist(lexpr, NULL))); +} + +/* unary operator */ +static PgBenchExpr * +make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr) +{ + return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL)); +} + +/* + * List of available functions: + * - fname: function name, "!..." for special internal functions + * - nargs: number of arguments. Special cases: + * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest + * meaning #args >= 1; + * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which + * has #args >= 3 and odd; + * - PGBENCH_NARGS_HASH is for hash functions, which have one required + * and one optional argument; + * - tag: function identifier from PgBenchFunction enum + */ +static const struct +{ + const char *fname; + int nargs; + PgBenchFunction tag; +} PGBENCH_FUNCTIONS[] = + +{ + /* parsed as operators, executed as functions */ + { + "+", 2, PGBENCH_ADD + }, + { + "-", 2, PGBENCH_SUB + }, + { + "*", 2, PGBENCH_MUL + }, + { + "/", 2, PGBENCH_DIV + }, + { + "mod", 2, PGBENCH_MOD + }, + /* actual functions */ + { + "abs", 1, PGBENCH_ABS + }, + { + "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST + }, + { + "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST + }, + { + "debug", 1, PGBENCH_DEBUG + }, + { + "pi", 0, PGBENCH_PI + }, + { + "sqrt", 1, PGBENCH_SQRT + }, + { + "ln", 1, PGBENCH_LN + }, + { + "exp", 1, PGBENCH_EXP + }, + { + "int", 1, PGBENCH_INT + }, + { + "double", 1, PGBENCH_DOUBLE + }, + { + "random", 2, PGBENCH_RANDOM + }, + { + "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN + }, + { + "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL + }, + { + "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN + }, + { + "pow", 2, PGBENCH_POW + }, + { + "power", 2, PGBENCH_POW + }, + /* logical operators */ + { + "!and", 2, PGBENCH_AND + }, + { + "!or", 2, PGBENCH_OR + }, + { + "!not", 1, PGBENCH_NOT + }, + /* bitwise integer operators */ + { + "&", 2, PGBENCH_BITAND + }, + { + "|", 2, PGBENCH_BITOR + }, + { + "#", 2, PGBENCH_BITXOR + }, + { + "<<", 2, PGBENCH_LSHIFT + }, + { + ">>", 2, PGBENCH_RSHIFT + }, + /* comparison operators */ + { + "=", 2, PGBENCH_EQ + }, + { + "<>", 2, PGBENCH_NE + }, + { + "<=", 2, PGBENCH_LE + }, + { + "<", 2, PGBENCH_LT + }, + { + "!is", 2, PGBENCH_IS + }, + /* "case when ... then ... else ... end" construction */ + { + "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE + }, + { + "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2 + }, + { + "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A + }, + { + "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE + }, + /* keep as last array element */ + { + NULL, 0, 0 + } +}; + +/* + * Find a function from its name + * + * return the index of the function from the PGBENCH_FUNCTIONS array + * or fail if the function is unknown. + */ +static int +find_func(yyscan_t yyscanner, const char *fname) +{ + int i = 0; + + while (PGBENCH_FUNCTIONS[i].fname) + { + if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0) + return i; + i++; + } + + expr_yyerror_more(yyscanner, "unexpected function name", fname); + + /* not reached */ + return -1; +} + +/* Expression linked list builder */ +static PgBenchExprList * +make_elist(PgBenchExpr *expr, PgBenchExprList *list) +{ + PgBenchExprLink *cons; + + if (list == NULL) + { + list = pg_malloc(sizeof(PgBenchExprList)); + list->head = NULL; + list->tail = NULL; + } + + cons = pg_malloc(sizeof(PgBenchExprLink)); + cons->expr = expr; + cons->next = NULL; + + if (list->head == NULL) + list->head = cons; + else + list->tail->next = cons; + + list->tail = cons; + + return list; +} + +/* Return the length of an expression list */ +static int +elist_length(PgBenchExprList *list) +{ + PgBenchExprLink *link = list != NULL ? list->head : NULL; + int len = 0; + + for (; link != NULL; link = link->next) + len++; + + return len; +} + +/* Build function call expression */ +static PgBenchExpr * +make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args) +{ + int len = elist_length(args); + + PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr)); + + Assert(fnumber >= 0); + + /* validate arguments number including few special cases */ + switch (PGBENCH_FUNCTIONS[fnumber].nargs) + { + /* check at least one arg for least & greatest */ + case PGBENCH_NARGS_VARIABLE: + if (len == 0) + expr_yyerror_more(yyscanner, "at least one argument expected", + PGBENCH_FUNCTIONS[fnumber].fname); + break; + + /* case (when ... then ...)+ (else ...)? end */ + case PGBENCH_NARGS_CASE: + /* 'else' branch is always present, but could be a NULL-constant */ + if (len < 3 || len % 2 != 1) + expr_yyerror_more(yyscanner, + "odd and >= 3 number of arguments expected", + "case control structure"); + break; + + /* hash functions with optional seed argument */ + case PGBENCH_NARGS_HASH: + if (len < 1 || len > 2) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 1) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* pseudorandom permutation function with optional seed argument */ + case PGBENCH_NARGS_PERMUTE: + if (len < 2 || len > 3) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + + if (len == 2) + { + PgBenchExpr *var = make_variable("default_seed"); + + args = make_elist(var, args); + } + break; + + /* common case: positive arguments number */ + default: + Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0); + + if (PGBENCH_FUNCTIONS[fnumber].nargs != len) + expr_yyerror_more(yyscanner, "unexpected number of arguments", + PGBENCH_FUNCTIONS[fnumber].fname); + } + + expr->etype = ENODE_FUNCTION; + expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag; + + /* only the link is used, the head/tail is not useful anymore */ + expr->u.function.args = args != NULL ? args->head : NULL; + if (args) + pg_free(args); + + return expr; +} + +static PgBenchExpr * +make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part) +{ + return make_func(yyscanner, + find_func(yyscanner, "!case_end"), + make_elist(else_part, when_then_list)); +} + diff --git a/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.h b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.h new file mode 100644 index 0000000..3d19aa5 --- /dev/null +++ b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprparse.h @@ -0,0 +1,117 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + NULL_CONST = 258, + INTEGER_CONST = 259, + MAXINT_PLUS_ONE_CONST = 260, + DOUBLE_CONST = 261, + BOOLEAN_CONST = 262, + VARIABLE = 263, + FUNCTION = 264, + AND_OP = 265, + OR_OP = 266, + NOT_OP = 267, + NE_OP = 268, + LE_OP = 269, + GE_OP = 270, + LS_OP = 271, + RS_OP = 272, + IS_OP = 273, + CASE_KW = 274, + WHEN_KW = 275, + THEN_KW = 276, + ELSE_KW = 277, + END_KW = 278, + NOTNULL_OP = 279, + ISNULL_OP = 280, + UNARY = 281 + }; +#endif +/* Tokens. */ +#define NULL_CONST 258 +#define INTEGER_CONST 259 +#define MAXINT_PLUS_ONE_CONST 260 +#define DOUBLE_CONST 261 +#define BOOLEAN_CONST 262 +#define VARIABLE 263 +#define FUNCTION 264 +#define AND_OP 265 +#define OR_OP 266 +#define NOT_OP 267 +#define NE_OP 268 +#define LE_OP 269 +#define GE_OP 270 +#define LS_OP 271 +#define RS_OP 272 +#define IS_OP 273 +#define CASE_KW 274 +#define WHEN_KW 275 +#define THEN_KW 276 +#define ELSE_KW 277 +#define END_KW 278 +#define NOTNULL_OP 279 +#define ISNULL_OP 280 +#define UNARY 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 48 "src/bin/pgbench/exprparse.y" +{ + int64 ival; + double dval; + bool bval; + char *str; + PgBenchExpr *expr; + PgBenchExprList *elist; +} +/* Line 1529 of yacc.c. */ +#line 110 "src/bin/pgbench/exprparse.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprscan.c b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprscan.c new file mode 100644 index 0000000..8503fd6 --- /dev/null +++ b/postgres_bazel/templates/18.4/files/src/bin/pgbench/exprscan.c @@ -0,0 +1,2816 @@ +#line 1 "src/bin/pgbench/exprscan.c" +/*------------------------------------------------------------------------- + * + * exprscan.l + * lexical scanner for pgbench backslash commands + * + * This lexer supports two operating modes: + * + * In INITIAL state, just parse off whitespace-separated words (this mode + * is basically equivalent to strtok(), which is what we used to use). + * + * In EXPR state, lex for the simple expression syntax of exprparse.y. + * + * In either mode, stop upon hitting newline or end of string. + * + * Note that this lexer operates within the framework created by psqlscan.l, + * + * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/bin/pgbench/exprscan.l + * + *------------------------------------------------------------------------- + */ +#include "postgres_fe.h" + +/* + * NB: include exprparse.h only AFTER including pgbench.h, because pgbench.h + * contains definitions needed for YYSTYPE. Likewise, pgbench.h must come after + * psqlscan_int.h for yyscan_t. + */ +#include "fe_utils/psqlscan_int.h" +#include "pgbench.h" +#include "exprparse.h" + +#line 36 "src/bin/pgbench/exprscan.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +#ifdef yy_create_buffer +#define expr_yy_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer expr_yy_create_buffer +#endif + +#ifdef yy_delete_buffer +#define expr_yy_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer expr_yy_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define expr_yy_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer expr_yy_scan_buffer +#endif + +#ifdef yy_scan_string +#define expr_yy_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string expr_yy_scan_string +#endif + +#ifdef yy_scan_bytes +#define expr_yy_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes expr_yy_scan_bytes +#endif + +#ifdef yy_init_buffer +#define expr_yy_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer expr_yy_init_buffer +#endif + +#ifdef yy_flush_buffer +#define expr_yy_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer expr_yy_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define expr_yy_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state expr_yy_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define expr_yy_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer expr_yy_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define expr_yypush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state expr_yypush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define expr_yypop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state expr_yypop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define expr_yyensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack expr_yyensure_buffer_stack +#endif + +#ifdef yylex +#define expr_yylex_ALREADY_DEFINED +#else +#define yylex expr_yylex +#endif + +#ifdef yyrestart +#define expr_yyrestart_ALREADY_DEFINED +#else +#define yyrestart expr_yyrestart +#endif + +#ifdef yylex_init +#define expr_yylex_init_ALREADY_DEFINED +#else +#define yylex_init expr_yylex_init +#endif + +#ifdef yylex_init_extra +#define expr_yylex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra expr_yylex_init_extra +#endif + +#ifdef yylex_destroy +#define expr_yylex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy expr_yylex_destroy +#endif + +#ifdef yyget_debug +#define expr_yyget_debug_ALREADY_DEFINED +#else +#define yyget_debug expr_yyget_debug +#endif + +#ifdef yyset_debug +#define expr_yyset_debug_ALREADY_DEFINED +#else +#define yyset_debug expr_yyset_debug +#endif + +#ifdef yyget_extra +#define expr_yyget_extra_ALREADY_DEFINED +#else +#define yyget_extra expr_yyget_extra +#endif + +#ifdef yyset_extra +#define expr_yyset_extra_ALREADY_DEFINED +#else +#define yyset_extra expr_yyset_extra +#endif + +#ifdef yyget_in +#define expr_yyget_in_ALREADY_DEFINED +#else +#define yyget_in expr_yyget_in +#endif + +#ifdef yyset_in +#define expr_yyset_in_ALREADY_DEFINED +#else +#define yyset_in expr_yyset_in +#endif + +#ifdef yyget_out +#define expr_yyget_out_ALREADY_DEFINED +#else +#define yyget_out expr_yyget_out +#endif + +#ifdef yyset_out +#define expr_yyset_out_ALREADY_DEFINED +#else +#define yyset_out expr_yyset_out +#endif + +#ifdef yyget_leng +#define expr_yyget_leng_ALREADY_DEFINED +#else +#define yyget_leng expr_yyget_leng +#endif + +#ifdef yyget_text +#define expr_yyget_text_ALREADY_DEFINED +#else +#define yyget_text expr_yyget_text +#endif + +#ifdef yyget_lineno +#define expr_yyget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno expr_yyget_lineno +#endif + +#ifdef yyset_lineno +#define expr_yyset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno expr_yyset_lineno +#endif + +#ifdef yyget_column +#define expr_yyget_column_ALREADY_DEFINED +#else +#define yyget_column expr_yyget_column +#endif + +#ifdef yyset_column +#define expr_yyset_column_ALREADY_DEFINED +#else +#define yyset_column expr_yyset_column +#endif + +#ifdef yywrap +#define expr_yywrap_ALREADY_DEFINED +#else +#define yywrap expr_yywrap +#endif + +#ifdef yyget_lval +#define expr_yyget_lval_ALREADY_DEFINED +#else +#define yyget_lval expr_yyget_lval +#endif + +#ifdef yyset_lval +#define expr_yyset_lval_ALREADY_DEFINED +#else +#define yyset_lval expr_yyset_lval +#endif + +#ifdef yyalloc +#define expr_yyalloc_ALREADY_DEFINED +#else +#define yyalloc expr_yyalloc +#endif + +#ifdef yyrealloc +#define expr_yyrealloc_ALREADY_DEFINED +#else +#define yyrealloc expr_yyrealloc +#endif + +#ifdef yyfree +#define expr_yyfree_ALREADY_DEFINED +#else +#define yyfree expr_yyfree +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +typedef uint64_t flex_uint64_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin , yyscanner ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + #define YY_LINENO_REWIND_TO(ptr) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + yy_size_t yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void yyrestart ( FILE *input_file , yyscan_t yyscanner ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner ); +void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner ); +void yypop_buffer_state ( yyscan_t yyscanner ); + +static void yyensure_buffer_stack ( yyscan_t yyscanner ); +static void yy_load_buffer_state ( yyscan_t yyscanner ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, yy_size_t len , yyscan_t yyscanner ); + +void *yyalloc ( yy_size_t , yyscan_t yyscanner ); +void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner ); +void yyfree ( void * , yyscan_t yyscanner ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define expr_yywrap(yyscanner) (/*CONSTCOND*/1) +#define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state ( yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner); +static int yy_get_next_buffer ( yyscan_t yyscanner ); +static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (yy_size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; +#define YY_NUM_RULES 51 +#define YY_END_OF_BUFFER 52 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[129] = + { 0, + 0, 0, 0, 0, 52, 1, 3, 5, 1, 50, + 47, 49, 50, 22, 10, 21, 24, 25, 8, 6, + 26, 7, 50, 9, 43, 43, 50, 18, 11, 19, + 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, + 50, 20, 23, 1, 1, 3, 4, 0, 47, 13, + 45, 44, 43, 0, 43, 38, 16, 14, 12, 15, + 17, 46, 46, 46, 46, 46, 46, 30, 46, 46, + 28, 46, 46, 46, 48, 0, 2, 0, 0, 44, + 0, 44, 43, 27, 46, 46, 37, 46, 46, 29, + 46, 46, 46, 46, 0, 45, 43, 33, 36, 46, + + 46, 46, 39, 35, 40, 34, 43, 41, 46, 46, + 43, 31, 46, 43, 32, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 42, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 1, 6, 1, 7, 8, 1, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 1, 28, + 29, 30, 1, 1, 31, 32, 33, 34, 35, 36, + 32, 37, 38, 32, 32, 39, 32, 40, 41, 32, + 32, 42, 43, 44, 45, 32, 46, 32, 32, 32, + 1, 47, 1, 1, 32, 1, 31, 32, 33, 34, + + 35, 36, 32, 37, 38, 32, 32, 39, 32, 40, + 41, 32, 32, 42, 43, 44, 45, 32, 46, 32, + 32, 32, 1, 48, 1, 49, 1, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32 + } ; + +static const YY_CHAR yy_meta[50] = + { 0, + 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 3, 4, 1, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, + 6, 6, 6, 6, 7, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 1, 1, 1 + } ; + +static const flex_int16_t yy_base[138] = + { 0, + 0, 3, 50, 0, 204, 156, 6, 205, 97, 205, + 7, 205, 173, 205, 205, 205, 205, 205, 205, 205, + 205, 205, 0, 205, 0, 1, 0, 0, 205, 2, + 161, 0, 169, 0, 168, 155, 0, 155, 0, 159, + 9, 205, 205, 148, 99, 15, 205, 191, 19, 205, + 158, 157, 172, 10, 171, 0, 205, 205, 205, 205, + 205, 0, 155, 145, 144, 152, 146, 144, 139, 143, + 0, 146, 135, 143, 205, 172, 205, 169, 13, 128, + 32, 0, 14, 0, 120, 110, 0, 100, 97, 101, + 101, 99, 103, 97, 92, 0, 29, 0, 0, 101, + + 95, 88, 0, 0, 0, 0, 19, 0, 93, 92, + 103, 0, 74, 88, 0, 89, 91, 92, 93, 97, + 100, 101, 104, 102, 111, 110, 7, 205, 146, 153, + 9, 157, 160, 163, 166, 171, 174 + } ; + +static const flex_int16_t yy_def[138] = + { 0, + 129, 129, 128, 3, 128, 130, 128, 128, 130, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 131, 128, 132, 132, 133, 128, 128, 128, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 128, 128, 128, 130, 130, 128, 128, 128, 128, 128, + 131, 135, 26, 136, 26, 133, 128, 128, 128, 128, + 128, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 128, 128, 128, 128, 137, 135, + 136, 81, 26, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 137, 95, 26, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 26, 134, 134, 134, + 26, 134, 134, 26, 134, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 0, 128, 128, + 128, 128, 128, 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_nxt[255] = + { 0, + 128, 7, 8, 7, 7, 8, 7, 46, 49, 46, + 49, 75, 76, 51, 52, 52, 46, 128, 46, 55, + 49, 81, 49, 81, 95, 53, 95, 57, 58, 59, + 60, 61, 53, 97, 54, 54, 72, 53, 65, 66, + 69, 73, 111, 128, 70, 128, 9, 53, 107, 9, + 10, 11, 12, 11, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 32, 34, 35, 32, 36, 32, 37, + 38, 32, 32, 39, 32, 40, 41, 42, 43, 47, + + 48, 77, 78, 128, 116, 128, 53, 53, 117, 53, + 53, 53, 115, 118, 120, 53, 119, 121, 53, 53, + 53, 114, 53, 122, 123, 124, 125, 126, 53, 53, + 113, 112, 110, 109, 127, 108, 106, 105, 104, 103, + 102, 101, 100, 45, 99, 45, 6, 6, 6, 6, + 6, 6, 6, 44, 98, 44, 44, 44, 44, 44, + 53, 53, 54, 53, 56, 56, 56, 62, 62, 62, + 80, 77, 80, 82, 75, 82, 96, 94, 96, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 53, 54, 79, 47, 45, 74, 71, 68, 67, 64, + + 63, 50, 45, 128, 5, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +static const flex_int16_t yy_chk[255] = + { 0, + 0, 1, 1, 1, 2, 2, 2, 7, 11, 7, + 11, 41, 41, 131, 25, 26, 46, 0, 46, 26, + 49, 54, 49, 54, 79, 127, 79, 28, 28, 28, + 30, 30, 83, 83, 25, 26, 39, 107, 34, 34, + 37, 39, 107, 81, 37, 81, 1, 97, 97, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, + + 9, 45, 45, 95, 114, 95, 114, 116, 116, 117, + 118, 119, 113, 117, 119, 120, 118, 120, 121, 122, + 124, 111, 123, 121, 122, 123, 124, 125, 126, 125, + 110, 109, 102, 101, 126, 100, 94, 93, 92, 91, + 90, 89, 88, 9, 86, 45, 129, 129, 129, 129, + 129, 129, 129, 130, 85, 130, 130, 130, 130, 130, + 132, 132, 80, 132, 133, 133, 133, 134, 134, 134, + 135, 78, 135, 136, 76, 136, 137, 74, 137, 73, + 72, 70, 69, 68, 67, 66, 65, 64, 63, 55, + 53, 52, 51, 48, 44, 40, 38, 36, 35, 33, + + 31, 13, 6, 5, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "src/bin/pgbench/exprscan.l" + +#line 38 "src/bin/pgbench/exprscan.l" +/* context information for reporting errors in expressions */ +static const char *expr_source = NULL; +static int expr_lineno = 0; +static int expr_start_offset = 0; +static const char *expr_command = NULL; + +/* indicates whether last yylex() call read a newline */ +static bool last_was_newline = false; + +/* LCOV_EXCL_START */ + +#line 789 "src/bin/pgbench/exprscan.c" +/* Except for the prefix, these options should match psqlscan.l */ +#define YY_NO_INPUT 1 +/* Character classes */ +/* {space} + {nonspace} + {newline} should cover all characters */ +/* Line continuation marker */ +/* case insensitive keywords */ +/* Exclusive states */ + +#line 798 "src/bin/pgbench/exprscan.c" + +#define INITIAL 0 +#define EXPR 1 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + yy_size_t yy_n_chars; + yy_size_t yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals ( yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +int yylex_init (yyscan_t* scanner); + +int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( yyscan_t yyscanner ); + +int yyget_debug ( yyscan_t yyscanner ); + +void yyset_debug ( int debug_flag , yyscan_t yyscanner ); + +YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner ); + +FILE *yyget_in ( yyscan_t yyscanner ); + +void yyset_in ( FILE * _in_str , yyscan_t yyscanner ); + +FILE *yyget_out ( yyscan_t yyscanner ); + +void yyset_out ( FILE * _out_str , yyscan_t yyscanner ); + + yy_size_t yyget_leng ( yyscan_t yyscanner ); + +char *yyget_text ( yyscan_t yyscanner ); + +int yyget_lineno ( yyscan_t yyscanner ); + +void yyset_lineno ( int _line_number , yyscan_t yyscanner ); + +int yyget_column ( yyscan_t yyscanner ); + +void yyset_column ( int _column_no , yyscan_t yyscanner ); + +YYSTYPE * yyget_lval ( yyscan_t yyscanner ); + +void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( yyscan_t yyscanner ); +#else +extern int yywrap ( yyscan_t yyscanner ); +#endif +#endif + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * , yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( yyscan_t yyscanner ); +#else +static int input ( yyscan_t yyscanner ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + yy_size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner); + +#define YY_DECL int yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_load_buffer_state( yyscanner ); + } + + { +#line 94 "src/bin/pgbench/exprscan.l" + + + +#line 98 "src/bin/pgbench/exprscan.l" + /* Declare some local variables inside yylex(), for convenience */ + PsqlScanState cur_state = yyextra; + + /* + * Force flex into the state indicated by start_state. This has a + * couple of purposes: it lets some of the functions below set a new + * starting state without ugly direct access to flex variables, and it + * allows us to transition from one flex lexer to another so that we + * can lex different parts of the source string using separate lexers. + */ + BEGIN(cur_state->start_state); + + /* Reset was-newline flag */ + last_was_newline = false; + + + /* INITIAL state */ + +#line 1094 "src/bin/pgbench/exprscan.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_current_state != 128 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 116 "src/bin/pgbench/exprscan.l" +{ + /* Found a word, emit and return it */ + psqlscan_emit(cur_state, yytext, yyleng); + return 1; + } + YY_BREAK +/* + * We need this rule to avoid returning "word\" instead of recognizing + * a continuation marker just after a word: + */ +case 2: +/* rule 2 can match eol */ +YY_RULE_SETUP +#line 126 "src/bin/pgbench/exprscan.l" +{ + /* Found "word\\\r?\n", emit and return just "word" */ + int wordlen = yyleng - 2; + if (yytext[wordlen] == '\r') + wordlen--; + Assert(yytext[wordlen] == '\\'); + psqlscan_emit(cur_state, yytext, wordlen); + return 1; + } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 136 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 138 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 140 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +/* EXPR state */ + +case 6: +YY_RULE_SETUP +#line 150 "src/bin/pgbench/exprscan.l" +{ return '+'; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 151 "src/bin/pgbench/exprscan.l" +{ return '-'; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 152 "src/bin/pgbench/exprscan.l" +{ return '*'; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 153 "src/bin/pgbench/exprscan.l" +{ return '/'; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 154 "src/bin/pgbench/exprscan.l" +{ return '%'; } /* C version, also in Pg SQL */ + YY_BREAK +case 11: +YY_RULE_SETUP +#line 155 "src/bin/pgbench/exprscan.l" +{ return '='; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 156 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 157 "src/bin/pgbench/exprscan.l" +{ return NE_OP; } /* C version, also in Pg SQL */ + YY_BREAK +case 14: +YY_RULE_SETUP +#line 158 "src/bin/pgbench/exprscan.l" +{ return LE_OP; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 159 "src/bin/pgbench/exprscan.l" +{ return GE_OP; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 160 "src/bin/pgbench/exprscan.l" +{ return LS_OP; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 161 "src/bin/pgbench/exprscan.l" +{ return RS_OP; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 162 "src/bin/pgbench/exprscan.l" +{ return '<'; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 163 "src/bin/pgbench/exprscan.l" +{ return '>'; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 164 "src/bin/pgbench/exprscan.l" +{ return '|'; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 165 "src/bin/pgbench/exprscan.l" +{ return '&'; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 166 "src/bin/pgbench/exprscan.l" +{ return '#'; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 167 "src/bin/pgbench/exprscan.l" +{ return '~'; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 169 "src/bin/pgbench/exprscan.l" +{ return '('; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 170 "src/bin/pgbench/exprscan.l" +{ return ')'; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 171 "src/bin/pgbench/exprscan.l" +{ return ','; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 173 "src/bin/pgbench/exprscan.l" +{ return AND_OP; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 174 "src/bin/pgbench/exprscan.l" +{ return OR_OP; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 175 "src/bin/pgbench/exprscan.l" +{ return NOT_OP; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 176 "src/bin/pgbench/exprscan.l" +{ return IS_OP; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 177 "src/bin/pgbench/exprscan.l" +{ return ISNULL_OP; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 178 "src/bin/pgbench/exprscan.l" +{ return NOTNULL_OP; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 180 "src/bin/pgbench/exprscan.l" +{ return CASE_KW; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 181 "src/bin/pgbench/exprscan.l" +{ return WHEN_KW; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 182 "src/bin/pgbench/exprscan.l" +{ return THEN_KW; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 183 "src/bin/pgbench/exprscan.l" +{ return ELSE_KW; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 184 "src/bin/pgbench/exprscan.l" +{ return END_KW; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 186 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext + 1); + return VARIABLE; + } + YY_BREAK +case 39: +YY_RULE_SETUP +#line 191 "src/bin/pgbench/exprscan.l" +{ return NULL_CONST; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 192 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = true; + return BOOLEAN_CONST; + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 196 "src/bin/pgbench/exprscan.l" +{ + yylval->bval = false; + return BOOLEAN_CONST; + } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 200 "src/bin/pgbench/exprscan.l" +{ + /* + * Special handling for PG_INT64_MIN, which can't + * accurately be represented here, as the minus sign is + * lexed separately and INT64_MIN can't be represented as + * a positive integer. + */ + return MAXINT_PLUS_ONE_CONST; + } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 209 "src/bin/pgbench/exprscan.l" +{ + if (!strtoint64(yytext, true, &yylval->ival)) + expr_yyerror_more(yyscanner, "bigint constant overflow", + strdup(yytext)); + return INTEGER_CONST; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 215 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 221 "src/bin/pgbench/exprscan.l" +{ + if (!strtodouble(yytext, true, &yylval->dval)) + expr_yyerror_more(yyscanner, "double constant overflow", + strdup(yytext)); + return DOUBLE_CONST; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 227 "src/bin/pgbench/exprscan.l" +{ + yylval->str = pg_strdup(yytext); + return FUNCTION; + } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 232 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 48: +/* rule 48 can match eol */ +YY_RULE_SETUP +#line 234 "src/bin/pgbench/exprscan.l" +{ /* ignore */ } + YY_BREAK +case 49: +/* rule 49 can match eol */ +YY_RULE_SETUP +#line 236 "src/bin/pgbench/exprscan.l" +{ + /* report end of command */ + last_was_newline = true; + return 0; + } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 242 "src/bin/pgbench/exprscan.l" +{ + /* + * must strdup yytext so that expr_yyerror_more doesn't + * change it while finding end of line + */ + expr_yyerror_more(yyscanner, "unexpected character", + pg_strdup(yytext)); + /* NOTREACHED, syntax_error calls exit() */ + return 0; + } + YY_BREAK + +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(EXPR): +#line 255 "src/bin/pgbench/exprscan.l" +{ + if (cur_state->buffer_stack == NULL) + return 0; /* end of input reached */ + + /* + * We were expanding a variable, so pop the inclusion + * stack and keep lexing + */ + psqlscan_pop_buffer_stack(cur_state); + psqlscan_select_top_buffer(cur_state); + } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 267 "src/bin/pgbench/exprscan.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 1493 "src/bin/pgbench/exprscan.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( yywrap( yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + yy_size_t num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + yy_size_t new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin , yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + yy_state_type yy_current_state; + char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + char *yy_cp = yyg->yy_c_buf_p; + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 129 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 128); + + (void)yyg; + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin , yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( yyscanner ) ) + return 0; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner); + yy_load_buffer_state( yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file , yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * @param yyscanner The scanner object. + */ + void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf , yyscanner ); + + yyfree( (void *) b , yyscanner ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_flush_buffer( b , yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(yyscanner); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (yyscan_t yyscanner) +{ + yy_size_t num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b , yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + yy_size_t i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n , yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n , yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yy_size_t yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +yy_size_t yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param _line_number line number + * @param yyscanner The scanner object. + */ +void yyset_lineno (int _line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_lineno called with no buffer" ); + + yylineno = _line_number; +} + +/** Set the current column. + * @param _column_no column number + * @param yyscanner The scanner object. + */ +void yyset_column (int _column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + YY_FATAL_ERROR( "yyset_column called with no buffer" ); + + yycolumn = _column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * @param yyscanner The scanner object. + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = _out_str ; +} + +int yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void yyset_debug (int _bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = _bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ +int yylex_init(yyscan_t* ptr_yy_globals) +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* yylex_init_extra has the same functionality as yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to yyalloc in + * the yyextra field. + */ +int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals ) +{ + struct yyguts_t dummy_yyguts; + + yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = NULL; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = NULL; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + yyfree(yyg->yy_buffer_stack , yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + yyfree( yyg->yy_start_stack , yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s , yyscan_t yyscanner) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + (void)yyg; + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 267 "src/bin/pgbench/exprscan.l" + + +/* LCOV_EXCL_STOP */ + +void +expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) +{ + PsqlScanState state = yyget_extra(yyscanner); + int lineno; + int error_detection_offset; + YYSTYPE lval; + char *full_line; + + psql_scan_get_location(state, &lineno, &error_detection_offset); + error_detection_offset--; + + /* + * While parsing an expression, we may not have collected the whole line + * yet from the input source. Lex till EOL so we can report whole line. + * (If we're at EOF, it's okay to call yylex() an extra time.) + */ + if (!last_was_newline) + { + while (yylex(&lval, yyscanner)) + /* skip */ ; + } + + /* Extract the line, trimming trailing newline if any */ + full_line = expr_scanner_get_substring(state, + expr_start_offset, + true); + + syntax_error(expr_source, expr_lineno, full_line, expr_command, + message, more, error_detection_offset - expr_start_offset); +} + +/* + * (The first argument is enforced by Bison to match the first argument of + * yyparse(), but it is not used here.) + */ +void +expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) +{ + expr_yyerror_more(yyscanner, message, NULL); +} + +/* + * Collect a space-separated word from a backslash command and return it + * in word_buf, along with its starting string offset in *offset. + * Returns true if successful, false if at end of command. + */ +bool +expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset) +{ + int lexresult; + YYSTYPE lval; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = word_buf; + resetPQExpBuffer(word_buf); + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = INITIAL; + + /* And lex. */ + lexresult = yylex(&lval, state->scanner); + + /* Save start offset of word, if any. */ + if (lexresult) + { + int lineno; + int end_offset; + + psql_scan_get_location(state, &lineno, &end_offset); + *offset = end_offset - word_buf->len; + } + else + *offset = -1; + + /* + * In case the caller returns to using the regular SQL lexer, reselect the + * appropriate initial state. + */ + psql_scan_reselect_sql_lexer(state); + + return (bool) lexresult; +} + +/* + * Prepare to lex an expression via expr_yyparse(). + * + * Returns the yyscan_t that is to be passed to expr_yyparse(). + * (This is just state->scanner, but callers don't need to know that.) + */ +yyscan_t +expr_scanner_init(PsqlScanState state, + const char *source, int lineno, int start_offset, + const char *command) +{ + /* Save error context info */ + expr_source = source; + expr_lineno = lineno; + expr_start_offset = start_offset; + expr_command = command; + + /* Must be scanning already */ + Assert(state->scanbufhandle != NULL); + + /* Set current output target */ + state->output_buf = NULL; + + /* Set input source */ + if (state->buffer_stack != NULL) + yy_switch_to_buffer(state->buffer_stack->buf, state->scanner); + else + yy_switch_to_buffer(state->scanbufhandle, state->scanner); + + /* Set start state */ + state->start_state = EXPR; + + return state->scanner; +} + +/* + * Finish lexing an expression. + */ +void +expr_scanner_finish(yyscan_t yyscanner) +{ + PsqlScanState state = yyget_extra(yyscanner); + + /* + * Reselect appropriate initial state for SQL lexer. + */ + psql_scan_reselect_sql_lexer(state); +} + +/* + * Get a malloc'd copy of the lexer input string from start_offset + * to end of current lexer token. If chomp is true, drop any trailing + * newline(s). + * + * We rely on the knowledge that flex modifies the scan buffer by storing + * a NUL at the end of the current token (yytext). Note that this might + * not work quite right if we were parsing a sub-buffer, but since pgbench + * never invokes that functionality, it doesn't matter. Also, this will + * give the wrong answer (the whole remainder of the input) if called + * before any yylex() call has been done. + */ +char * +expr_scanner_get_substring(PsqlScanState state, + int start_offset, + bool chomp) +{ + char *result; + const char *scanptr = state->scanbuf + start_offset; + size_t slen = strlen(scanptr); + + if (chomp) + { + while (slen > 0 && + (scanptr[slen - 1] == '\n' || scanptr[slen - 1] == '\r')) + slen--; + } + + result = (char *) pg_malloc(slen + 1); + memcpy(result, scanptr, slen); + result[slen] = '\0'; + + return result; +} + diff --git a/postgres_bazel/templates/default/BUILD.bazel.template b/postgres_bazel/templates/default/BUILD.bazel.template index 624ee14..0f4b09c 100644 --- a/postgres_bazel/templates/default/BUILD.bazel.template +++ b/postgres_bazel/templates/default/BUILD.bazel.template @@ -1,6 +1,15 @@ # Mirrors the public targets of templates/major/*/BUILD.bazel. Keep in sync by # hand when a target is added there. +_SINCE_17 = [ + "pg_combinebackup", + "pg_combinebackup_bin", + "pg_createsubscriber", + "pg_createsubscriber_bin", + "pg_walsummary", + "pg_walsummary_bin", +] + [ alias( name = name, @@ -8,12 +17,62 @@ visibility = ["//visibility:public"], ) for name in [ + "clusterdb", + "clusterdb_bin", + "createdb", + "createdb_bin", + "createuser", + "createuser_bin", + "dropdb", + "dropdb_bin", + "dropuser", + "dropuser_bin", "initdb", "initdb_bin", "libpq", + "pg_amcheck", + "pg_amcheck_bin", + "pg_archivecleanup", + "pg_archivecleanup_bin", + "pg_basebackup", + "pg_basebackup_bin", + "pg_checksums", + "pg_checksums_bin", + "pg_config", + "pg_config_bin", + "pg_controldata", + "pg_controldata_bin", "pg_ctl", "pg_ctl_bin", "pg_dist", + "pg_dump", + "pg_dump_bin", + "pg_dumpall", + "pg_dumpall_bin", + "pg_isready", + "pg_isready_bin", + "pg_receivewal", + "pg_receivewal_bin", + "pg_recvlogical", + "pg_recvlogical_bin", + "pg_resetwal", + "pg_resetwal_bin", + "pg_restore", + "pg_restore_bin", + "pg_rewind", + "pg_rewind_bin", + "pg_test_fsync", + "pg_test_fsync_bin", + "pg_test_timing", + "pg_test_timing_bin", + "pg_upgrade", + "pg_upgrade_bin", + "pg_verifybackup", + "pg_verifybackup_bin", + "pg_waldump", + "pg_waldump_bin", + "pgbench", + "pgbench_bin", "pgcommon", "pgport", "postgres", @@ -21,5 +80,9 @@ "pq", "psql", "psql_bin", - ] + "reindexdb", + "reindexdb_bin", + "vacuumdb", + "vacuumdb_bin", + ] + (_SINCE_17 if {major} >= 17 else []) ] diff --git a/postgres_bazel/templates/major/16/BUILD.bazel b/postgres_bazel/templates/major/16/BUILD.bazel index 862f9e4..b861c6c 100644 --- a/postgres_bazel/templates/major/16/BUILD.bazel +++ b/postgres_bazel/templates/major/16/BUILD.bazel @@ -1338,6 +1338,7 @@ _LIBCOMMON_TOOLS = [ "src/common/fe_memutils.c", "src/common/file_perm.c", "src/common/file_utils.c", + "src/common/hashfn.c", "src/common/ip.c", "src/common/jsonapi.c", "src/common/keywords.c", @@ -1565,7 +1566,7 @@ cc_library( # fe_memutils.c #error out under backend compilation, and restricted_token.c # and sprompt.c are frontend utilities. Everything else is upstream's # common_sources, same as the tools build. -_LIBCOMMON_SRV = ["src/common/hashfn.c"] + [ +_LIBCOMMON_SRV = [ f for f in _LIBCOMMON_TOOLS if f not in [ @@ -1767,6 +1768,239 @@ cc_binary( ], ) +_FRONTEND_DEFINES = ["FRONTEND"] + select({ + "@platforms//os:linux": ["_GNU_SOURCE"], + "//conditions:default": [], +}) + +_FRONTEND_DEPS = [ + ":include", + ":pgcommon_tools", + ":pgfeutils", + ":pgport", + ":pq", +] + +[ + cc_binary( + name = tool, + srcs = ["src/bin/{0}/{0}.c".format(tool)], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "pg_amcheck", + "pg_archivecleanup", + "pg_checksums", + "pg_controldata", + "pg_resetwal", + "pg_test_fsync", + "pg_test_timing", + ] +] + +cc_binary( + name = "pg_config", + srcs = [ + "src/bin/pg_config/pg_config.c", + "src/common/config_info.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = [ + "src/bin/scripts/common.c", + "src/bin/scripts/common.h", + "src/bin/scripts/%s.c" % tool, + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "pg_isready", + "reindexdb", + "vacuumdb", + ] +] + +cc_library( + name = "pgdump_common", + srcs = [ + "src/bin/pg_dump/compress_gzip.c", + "src/bin/pg_dump/compress_io.c", + "src/bin/pg_dump/compress_lz4.c", + "src/bin/pg_dump/compress_none.c", + "src/bin/pg_dump/compress_zstd.c", + "src/bin/pg_dump/dumputils.c", + "src/bin/pg_dump/parallel.c", + "src/bin/pg_dump/pg_backup_archiver.c", + "src/bin/pg_dump/pg_backup_custom.c", + "src/bin/pg_dump/pg_backup_db.c", + "src/bin/pg_dump/pg_backup_directory.c", + "src/bin/pg_dump/pg_backup_null.c", + "src/bin/pg_dump/pg_backup_tar.c", + "src/bin/pg_dump/pg_backup_utils.c", + ], + hdrs = glob(["src/bin/pg_dump/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_dump", + srcs = [ + "src/bin/pg_dump/common.c", + "src/bin/pg_dump/pg_dump.c", + "src/bin/pg_dump/pg_dump_sort.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_dump/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], + ) + for tool in [ + "pg_dumpall", + "pg_restore", + ] +] + +cc_library( + name = "pg_basebackup_common", + srcs = [ + "src/bin/pg_basebackup/bbstreamer_file.c", + "src/bin/pg_basebackup/bbstreamer_gzip.c", + "src/bin/pg_basebackup/bbstreamer_inject.c", + "src/bin/pg_basebackup/bbstreamer_lz4.c", + "src/bin/pg_basebackup/bbstreamer_tar.c", + "src/bin/pg_basebackup/bbstreamer_zstd.c", + "src/bin/pg_basebackup/receivelog.c", + "src/bin/pg_basebackup/streamutil.c", + "src/bin/pg_basebackup/walmethods.c", + ], + hdrs = glob(["src/bin/pg_basebackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_basebackup/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pg_basebackup_common"], + ) + for tool in [ + "pg_basebackup", + "pg_receivewal", + "pg_recvlogical", + ] +] + +cc_binary( + name = "pg_rewind", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/bin/pg_rewind/datapagemap.c", + "src/bin/pg_rewind/file_ops.c", + "src/bin/pg_rewind/filemap.c", + "src/bin/pg_rewind/libpq_source.c", + "src/bin/pg_rewind/local_source.c", + "src/bin/pg_rewind/parsexlog.c", + "src/bin/pg_rewind/pg_rewind.c", + "src/bin/pg_rewind/timeline.c", + ] + glob(["src/bin/pg_rewind/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_upgrade", + srcs = [ + "src/bin/pg_upgrade/check.c", + "src/bin/pg_upgrade/controldata.c", + "src/bin/pg_upgrade/dump.c", + "src/bin/pg_upgrade/exec.c", + "src/bin/pg_upgrade/file.c", + "src/bin/pg_upgrade/function.c", + "src/bin/pg_upgrade/info.c", + "src/bin/pg_upgrade/option.c", + "src/bin/pg_upgrade/parallel.c", + "src/bin/pg_upgrade/pg_upgrade.c", + "src/bin/pg_upgrade/relfilenumber.c", + "src/bin/pg_upgrade/server.c", + "src/bin/pg_upgrade/tablespace.c", + "src/bin/pg_upgrade/util.c", + "src/bin/pg_upgrade/version.c", + ] + glob(["src/bin/pg_upgrade/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_verifybackup", + srcs = [ + "src/bin/pg_verifybackup/parse_manifest.c", + "src/bin/pg_verifybackup/pg_verifybackup.c", + ] + glob(["src/bin/pg_verifybackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_waldump", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/backend/access/transam/xlogstats.c", + "src/bin/pg_waldump/compat.c", + "src/bin/pg_waldump/pg_waldump.c", + "src/bin/pg_waldump/rmgrdesc.c", + ] + glob([ + "src/backend/access/rmgrdesc/*.c", + "src/bin/pg_waldump/*.h", + ]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pgbench", + srcs = [ + "src/bin/pgbench/exprparse.c", + "src/bin/pgbench/exprparse.h", + "src/bin/pgbench/exprscan.c", + "src/bin/pgbench/pgbench.c", + "src/bin/pgbench/pgbench.h", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + # zic compiles the timezone database into the TZif files the server and initdb # read at runtime. It's a build-time tool, so it's always built for the exec # platform. @@ -1861,6 +2095,40 @@ cp $(execpath :plpgsql) {out}/plpgsql$S ], ) +_DIST_BINARIES = [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "initdb", + "pg_amcheck", + "pg_archivecleanup", + "pg_basebackup", + "pg_checksums", + "pg_config", + "pg_controldata", + "pg_ctl", + "pg_dump", + "pg_dumpall", + "pg_isready", + "pg_receivewal", + "pg_recvlogical", + "pg_resetwal", + "pg_restore", + "pg_rewind", + "pg_test_fsync", + "pg_test_timing", + "pg_upgrade", + "pg_verifybackup", + "pg_waldump", + "pgbench", + "postgres", + "psql", + "reindexdb", + "vacuumdb", +] + # Assembles bin/ and share/ as siblings. This layout is not cosmetic: # get_share_path() derives PGSHAREDIR by walking up from the running # executable, and only does so when the binary's directory is named "bin". @@ -1870,21 +2138,20 @@ directory_output( cmd = """ set -e mkdir -p {out}/bin {out}/share/timezonesets {out}/share/extension {out}/lib -cp $(execpath :initdb) $(execpath :pg_ctl) $(execpath :postgres) $(execpath :psql) {out}/bin/ +cp DIST_BINARIES {out}/bin/ for f in SHARE_FILES; do cp "$f" {out}/share/; done for f in $(execpaths :tznames); do cp "$f" {out}/share/timezonesets/; done cp -R $(execpath :tzdata) {out}/share/timezone cp -R $(execpath :pg_lib)/. {out}/lib/ cp $(execpath src/pl/plpgsql/src/plpgsql.control) \ $(execpath src/pl/plpgsql/src/plpgsql--1.0.sql) {out}/share/extension/ -""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])), +""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])).replace( + "DIST_BINARIES", + " ".join(["$(execpath :%s)" % b for b in _DIST_BINARIES]), + ), dirname = "dist", - srcs = _SHARE_FILES + [ - ":initdb", - ":pg_ctl", - ":postgres", + srcs = _SHARE_FILES + [":" + b for b in _DIST_BINARIES] + [ ":pg_lib", - ":psql", "src/pl/plpgsql/src/plpgsql--1.0.sql", "src/pl/plpgsql/src/plpgsql.control", ":tzdata", @@ -1909,10 +2176,5 @@ filegroup( dist = ":pg_dist", visibility = ["//visibility:public"], ) - for binary in [ - "initdb", - "pg_ctl", - "postgres", - "psql", - ] + for binary in _DIST_BINARIES ] diff --git a/postgres_bazel/templates/major/17/BUILD.bazel b/postgres_bazel/templates/major/17/BUILD.bazel index 34e4cfa..4260555 100644 --- a/postgres_bazel/templates/major/17/BUILD.bazel +++ b/postgres_bazel/templates/major/17/BUILD.bazel @@ -1344,6 +1344,7 @@ _LIBCOMMON_TOOLS = [ "src/common/fe_memutils.c", "src/common/file_perm.c", "src/common/file_utils.c", + "src/common/hashfn.c", "src/common/ip.c", "src/common/jsonapi.c", "src/common/keywords.c", @@ -1573,7 +1574,7 @@ cc_library( # fe_memutils.c #error out under backend compilation, and restricted_token.c # and sprompt.c are frontend utilities. Everything else is upstream's # common_sources, same as the tools build. -_LIBCOMMON_SRV = ["src/common/hashfn.c"] + [ +_LIBCOMMON_SRV = [ f for f in _LIBCOMMON_TOOLS if f not in [ @@ -1779,6 +1780,261 @@ cc_binary( ], ) +_FRONTEND_DEFINES = ["FRONTEND"] + select({ + "@platforms//os:linux": ["_GNU_SOURCE"], + "//conditions:default": [], +}) + +_FRONTEND_DEPS = [ + ":include", + ":pgcommon_tools", + ":pgfeutils", + ":pgport", + ":pq", +] + +[ + cc_binary( + name = tool, + srcs = ["src/bin/{0}/{0}.c".format(tool)], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "pg_amcheck", + "pg_archivecleanup", + "pg_checksums", + "pg_controldata", + "pg_resetwal", + "pg_test_fsync", + "pg_test_timing", + "pg_walsummary", + ] +] + +cc_binary( + name = "pg_config", + srcs = [ + "src/bin/pg_config/pg_config.c", + "src/common/config_info.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = [ + "src/bin/scripts/common.c", + "src/bin/scripts/common.h", + "src/bin/scripts/%s.c" % tool, + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "pg_isready", + "reindexdb", + "vacuumdb", + ] +] + +cc_binary( + name = "pg_combinebackup", + srcs = [ + "src/bin/pg_combinebackup/backup_label.c", + "src/bin/pg_combinebackup/copy_file.c", + "src/bin/pg_combinebackup/load_manifest.c", + "src/bin/pg_combinebackup/pg_combinebackup.c", + "src/bin/pg_combinebackup/reconstruct.c", + "src/bin/pg_combinebackup/write_manifest.c", + ] + glob(["src/bin/pg_combinebackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_createsubscriber", + srcs = ["src/bin/pg_basebackup/pg_createsubscriber.c"], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_library( + name = "pgdump_common", + srcs = [ + "src/bin/pg_dump/compress_gzip.c", + "src/bin/pg_dump/compress_io.c", + "src/bin/pg_dump/compress_lz4.c", + "src/bin/pg_dump/compress_none.c", + "src/bin/pg_dump/compress_zstd.c", + "src/bin/pg_dump/dumputils.c", + "src/bin/pg_dump/filter.c", + "src/bin/pg_dump/parallel.c", + "src/bin/pg_dump/pg_backup_archiver.c", + "src/bin/pg_dump/pg_backup_custom.c", + "src/bin/pg_dump/pg_backup_db.c", + "src/bin/pg_dump/pg_backup_directory.c", + "src/bin/pg_dump/pg_backup_null.c", + "src/bin/pg_dump/pg_backup_tar.c", + "src/bin/pg_dump/pg_backup_utils.c", + ], + hdrs = glob(["src/bin/pg_dump/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_dump", + srcs = [ + "src/bin/pg_dump/common.c", + "src/bin/pg_dump/pg_dump.c", + "src/bin/pg_dump/pg_dump_sort.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_dump/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], + ) + for tool in [ + "pg_dumpall", + "pg_restore", + ] +] + +cc_library( + name = "pg_basebackup_common", + srcs = [ + "src/bin/pg_basebackup/bbstreamer_file.c", + "src/bin/pg_basebackup/bbstreamer_gzip.c", + "src/bin/pg_basebackup/bbstreamer_inject.c", + "src/bin/pg_basebackup/bbstreamer_lz4.c", + "src/bin/pg_basebackup/bbstreamer_tar.c", + "src/bin/pg_basebackup/bbstreamer_zstd.c", + "src/bin/pg_basebackup/receivelog.c", + "src/bin/pg_basebackup/streamutil.c", + "src/bin/pg_basebackup/walmethods.c", + ], + hdrs = glob(["src/bin/pg_basebackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_basebackup/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pg_basebackup_common"], + ) + for tool in [ + "pg_basebackup", + "pg_receivewal", + "pg_recvlogical", + ] +] + +cc_binary( + name = "pg_rewind", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/bin/pg_rewind/datapagemap.c", + "src/bin/pg_rewind/file_ops.c", + "src/bin/pg_rewind/filemap.c", + "src/bin/pg_rewind/libpq_source.c", + "src/bin/pg_rewind/local_source.c", + "src/bin/pg_rewind/parsexlog.c", + "src/bin/pg_rewind/pg_rewind.c", + "src/bin/pg_rewind/timeline.c", + ] + glob(["src/bin/pg_rewind/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_upgrade", + srcs = [ + "src/bin/pg_upgrade/check.c", + "src/bin/pg_upgrade/controldata.c", + "src/bin/pg_upgrade/dump.c", + "src/bin/pg_upgrade/exec.c", + "src/bin/pg_upgrade/file.c", + "src/bin/pg_upgrade/function.c", + "src/bin/pg_upgrade/info.c", + "src/bin/pg_upgrade/option.c", + "src/bin/pg_upgrade/parallel.c", + "src/bin/pg_upgrade/pg_upgrade.c", + "src/bin/pg_upgrade/relfilenumber.c", + "src/bin/pg_upgrade/server.c", + "src/bin/pg_upgrade/tablespace.c", + "src/bin/pg_upgrade/util.c", + "src/bin/pg_upgrade/version.c", + ] + glob(["src/bin/pg_upgrade/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_verifybackup", + srcs = ["src/bin/pg_verifybackup/pg_verifybackup.c"], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_waldump", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/backend/access/transam/xlogstats.c", + "src/bin/pg_waldump/compat.c", + "src/bin/pg_waldump/pg_waldump.c", + "src/bin/pg_waldump/rmgrdesc.c", + ] + glob([ + "src/backend/access/rmgrdesc/*.c", + "src/bin/pg_waldump/*.h", + ]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pgbench", + srcs = [ + "src/bin/pgbench/exprparse.c", + "src/bin/pgbench/exprparse.h", + "src/bin/pgbench/exprscan.c", + "src/bin/pgbench/pgbench.c", + "src/bin/pgbench/pgbench.h", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + # zic compiles the timezone database into the TZif files the server and initdb # read at runtime. It's a build-time tool, so it's always built for the exec # platform. @@ -1873,6 +2129,43 @@ cp $(execpath :plpgsql) {out}/plpgsql$S ], ) +_DIST_BINARIES = [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "initdb", + "pg_amcheck", + "pg_archivecleanup", + "pg_basebackup", + "pg_checksums", + "pg_combinebackup", + "pg_config", + "pg_controldata", + "pg_createsubscriber", + "pg_ctl", + "pg_dump", + "pg_dumpall", + "pg_isready", + "pg_receivewal", + "pg_recvlogical", + "pg_resetwal", + "pg_restore", + "pg_rewind", + "pg_test_fsync", + "pg_test_timing", + "pg_upgrade", + "pg_verifybackup", + "pg_waldump", + "pg_walsummary", + "pgbench", + "postgres", + "psql", + "reindexdb", + "vacuumdb", +] + # Assembles bin/ and share/ as siblings. This layout is not cosmetic: # get_share_path() derives PGSHAREDIR by walking up from the running # executable, and only does so when the binary's directory is named "bin". @@ -1882,21 +2175,20 @@ directory_output( cmd = """ set -e mkdir -p {out}/bin {out}/share/timezonesets {out}/share/extension {out}/lib -cp $(execpath :initdb) $(execpath :pg_ctl) $(execpath :postgres) $(execpath :psql) {out}/bin/ +cp DIST_BINARIES {out}/bin/ for f in SHARE_FILES; do cp "$f" {out}/share/; done for f in $(execpaths :tznames); do cp "$f" {out}/share/timezonesets/; done cp -R $(execpath :tzdata) {out}/share/timezone cp -R $(execpath :pg_lib)/. {out}/lib/ cp $(execpath src/pl/plpgsql/src/plpgsql.control) \ $(execpath src/pl/plpgsql/src/plpgsql--1.0.sql) {out}/share/extension/ -""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])), +""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])).replace( + "DIST_BINARIES", + " ".join(["$(execpath :%s)" % b for b in _DIST_BINARIES]), + ), dirname = "dist", - srcs = _SHARE_FILES + [ - ":initdb", - ":pg_ctl", - ":postgres", + srcs = _SHARE_FILES + [":" + b for b in _DIST_BINARIES] + [ ":pg_lib", - ":psql", "src/pl/plpgsql/src/plpgsql--1.0.sql", "src/pl/plpgsql/src/plpgsql.control", ":tzdata", @@ -1921,10 +2213,5 @@ filegroup( dist = ":pg_dist", visibility = ["//visibility:public"], ) - for binary in [ - "initdb", - "pg_ctl", - "postgres", - "psql", - ] + for binary in _DIST_BINARIES ] diff --git a/postgres_bazel/templates/major/18/BUILD.bazel b/postgres_bazel/templates/major/18/BUILD.bazel index 55b9d5b..c77cdad 100644 --- a/postgres_bazel/templates/major/18/BUILD.bazel +++ b/postgres_bazel/templates/major/18/BUILD.bazel @@ -1317,6 +1317,7 @@ _LIBCOMMON_TOOLS = [ "src/common/fe_memutils.c", "src/common/file_perm.c", "src/common/file_utils.c", + "src/common/hashfn.c", "src/common/ip.c", "src/common/jsonapi.c", "src/common/keywords.c", @@ -1382,7 +1383,10 @@ cc_library( srcs = [ "src/fe_utils/archive.c", "src/fe_utils/astreamer_file.c", + "src/fe_utils/astreamer_gzip.c", + "src/fe_utils/astreamer_lz4.c", "src/fe_utils/astreamer_tar.c", + "src/fe_utils/astreamer_zstd.c", "src/fe_utils/cancel.c", "src/fe_utils/conditional.c", "src/fe_utils/connect_utils.c", @@ -1532,7 +1536,7 @@ cc_library( # fe_memutils.c #error out under backend compilation, and restricted_token.c # and sprompt.c are frontend utilities. Everything else is upstream's # common_sources, same as the tools build. -_LIBCOMMON_SRV = ["src/common/hashfn.c"] + [ +_LIBCOMMON_SRV = [ f for f in _LIBCOMMON_TOOLS if f not in [ @@ -1733,6 +1737,261 @@ cc_binary( ], ) +_FRONTEND_DEFINES = ["FRONTEND"] + select({ + "@platforms//os:linux": ["_GNU_SOURCE"], + "//conditions:default": [], +}) + +_FRONTEND_DEPS = [ + ":include", + ":pgcommon_tools", + ":pgfeutils", + ":pgport", + ":pq", +] + +[ + cc_binary( + name = tool, + srcs = ["src/bin/{0}/{0}.c".format(tool)], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "pg_amcheck", + "pg_archivecleanup", + "pg_checksums", + "pg_controldata", + "pg_resetwal", + "pg_test_fsync", + "pg_test_timing", + "pg_walsummary", + ] +] + +cc_binary( + name = "pg_config", + srcs = [ + "src/bin/pg_config/pg_config.c", + "src/common/config_info.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = [ + "src/bin/scripts/common.c", + "src/bin/scripts/common.h", + "src/bin/scripts/%s.c" % tool, + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, + ) + for tool in [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "pg_isready", + "reindexdb", + "vacuumdb", + ] +] + +cc_binary( + name = "pg_combinebackup", + srcs = [ + "src/bin/pg_combinebackup/backup_label.c", + "src/bin/pg_combinebackup/copy_file.c", + "src/bin/pg_combinebackup/load_manifest.c", + "src/bin/pg_combinebackup/pg_combinebackup.c", + "src/bin/pg_combinebackup/reconstruct.c", + "src/bin/pg_combinebackup/write_manifest.c", + ] + glob(["src/bin/pg_combinebackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_createsubscriber", + srcs = ["src/bin/pg_basebackup/pg_createsubscriber.c"], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_library( + name = "pgdump_common", + srcs = [ + "src/bin/pg_dump/compress_gzip.c", + "src/bin/pg_dump/compress_io.c", + "src/bin/pg_dump/compress_lz4.c", + "src/bin/pg_dump/compress_none.c", + "src/bin/pg_dump/compress_zstd.c", + "src/bin/pg_dump/connectdb.c", + "src/bin/pg_dump/dumputils.c", + "src/bin/pg_dump/filter.c", + "src/bin/pg_dump/parallel.c", + "src/bin/pg_dump/pg_backup_archiver.c", + "src/bin/pg_dump/pg_backup_custom.c", + "src/bin/pg_dump/pg_backup_db.c", + "src/bin/pg_dump/pg_backup_directory.c", + "src/bin/pg_dump/pg_backup_null.c", + "src/bin/pg_dump/pg_backup_tar.c", + "src/bin/pg_dump/pg_backup_utils.c", + ], + hdrs = glob(["src/bin/pg_dump/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_dump", + srcs = [ + "src/bin/pg_dump/common.c", + "src/bin/pg_dump/pg_dump.c", + "src/bin/pg_dump/pg_dump_sort.c", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_dump/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pgdump_common"], + ) + for tool in [ + "pg_dumpall", + "pg_restore", + ] +] + +cc_library( + name = "pg_basebackup_common", + srcs = [ + "src/bin/pg_basebackup/astreamer_inject.c", + "src/bin/pg_basebackup/receivelog.c", + "src/bin/pg_basebackup/streamutil.c", + "src/bin/pg_basebackup/walmethods.c", + ], + hdrs = glob(["src/bin/pg_basebackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + deps = _FRONTEND_DEPS, +) + +[ + cc_binary( + name = tool, + srcs = ["src/bin/pg_basebackup/%s.c" % tool], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS + [":pg_basebackup_common"], + ) + for tool in [ + "pg_basebackup", + "pg_receivewal", + "pg_recvlogical", + ] +] + +cc_binary( + name = "pg_rewind", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/bin/pg_rewind/datapagemap.c", + "src/bin/pg_rewind/file_ops.c", + "src/bin/pg_rewind/filemap.c", + "src/bin/pg_rewind/libpq_source.c", + "src/bin/pg_rewind/local_source.c", + "src/bin/pg_rewind/parsexlog.c", + "src/bin/pg_rewind/pg_rewind.c", + "src/bin/pg_rewind/timeline.c", + ] + glob(["src/bin/pg_rewind/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_upgrade", + srcs = [ + "src/bin/pg_upgrade/check.c", + "src/bin/pg_upgrade/controldata.c", + "src/bin/pg_upgrade/dump.c", + "src/bin/pg_upgrade/exec.c", + "src/bin/pg_upgrade/file.c", + "src/bin/pg_upgrade/function.c", + "src/bin/pg_upgrade/info.c", + "src/bin/pg_upgrade/option.c", + "src/bin/pg_upgrade/parallel.c", + "src/bin/pg_upgrade/pg_upgrade.c", + "src/bin/pg_upgrade/relfilenumber.c", + "src/bin/pg_upgrade/server.c", + "src/bin/pg_upgrade/tablespace.c", + "src/bin/pg_upgrade/task.c", + "src/bin/pg_upgrade/util.c", + "src/bin/pg_upgrade/version.c", + ] + glob(["src/bin/pg_upgrade/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_verifybackup", + srcs = [ + "src/bin/pg_verifybackup/astreamer_verify.c", + "src/bin/pg_verifybackup/pg_verifybackup.c", + ] + glob(["src/bin/pg_verifybackup/*.h"]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pg_waldump", + srcs = [ + "src/backend/access/transam/xlogreader.c", + "src/backend/access/transam/xlogstats.c", + "src/bin/pg_waldump/compat.c", + "src/bin/pg_waldump/pg_waldump.c", + "src/bin/pg_waldump/rmgrdesc.c", + ] + glob([ + "src/backend/access/rmgrdesc/*.c", + "src/bin/pg_waldump/*.h", + ]), + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + +cc_binary( + name = "pgbench", + srcs = [ + "src/bin/pgbench/exprparse.c", + "src/bin/pgbench/exprparse.h", + "src/bin/pgbench/exprscan.c", + "src/bin/pgbench/pgbench.c", + "src/bin/pgbench/pgbench.h", + ], + local_defines = _FRONTEND_DEFINES, + visibility = ["//visibility:public"], + deps = _FRONTEND_DEPS, +) + # zic compiles the timezone database into the TZif files the server and initdb # read at runtime. It's a build-time tool, so it's always built for the exec # platform. @@ -1827,6 +2086,43 @@ cp $(execpath :plpgsql) {out}/plpgsql$S ], ) +_DIST_BINARIES = [ + "clusterdb", + "createdb", + "createuser", + "dropdb", + "dropuser", + "initdb", + "pg_amcheck", + "pg_archivecleanup", + "pg_basebackup", + "pg_checksums", + "pg_combinebackup", + "pg_config", + "pg_controldata", + "pg_createsubscriber", + "pg_ctl", + "pg_dump", + "pg_dumpall", + "pg_isready", + "pg_receivewal", + "pg_recvlogical", + "pg_resetwal", + "pg_restore", + "pg_rewind", + "pg_test_fsync", + "pg_test_timing", + "pg_upgrade", + "pg_verifybackup", + "pg_waldump", + "pg_walsummary", + "pgbench", + "postgres", + "psql", + "reindexdb", + "vacuumdb", +] + # Assembles bin/ and share/ as siblings. This layout is not cosmetic: # get_share_path() derives PGSHAREDIR by walking up from the running # executable, and only does so when the binary's directory is named "bin". @@ -1836,21 +2132,20 @@ directory_output( cmd = """ set -e mkdir -p {out}/bin {out}/share/timezonesets {out}/share/extension {out}/lib -cp $(execpath :initdb) $(execpath :pg_ctl) $(execpath :postgres) $(execpath :psql) {out}/bin/ +cp DIST_BINARIES {out}/bin/ for f in SHARE_FILES; do cp "$f" {out}/share/; done for f in $(execpaths :tznames); do cp "$f" {out}/share/timezonesets/; done cp -R $(execpath :tzdata) {out}/share/timezone cp -R $(execpath :pg_lib)/. {out}/lib/ cp $(execpath src/pl/plpgsql/src/plpgsql.control) \ $(execpath src/pl/plpgsql/src/plpgsql--1.0.sql) {out}/share/extension/ -""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])), +""".replace("SHARE_FILES", " ".join(["$(execpath %s)" % f for f in _SHARE_FILES])).replace( + "DIST_BINARIES", + " ".join(["$(execpath :%s)" % b for b in _DIST_BINARIES]), + ), dirname = "dist", - srcs = _SHARE_FILES + [ - ":initdb", - ":pg_ctl", - ":postgres", + srcs = _SHARE_FILES + [":" + b for b in _DIST_BINARIES] + [ ":pg_lib", - ":psql", "src/pl/plpgsql/src/plpgsql--1.0.sql", "src/pl/plpgsql/src/plpgsql.control", ":tzdata", @@ -1875,10 +2170,5 @@ filegroup( dist = ":pg_dist", visibility = ["//visibility:public"], ) - for binary in [ - "initdb", - "pg_ctl", - "postgres", - "psql", - ] + for binary in _DIST_BINARIES ] diff --git a/scripts/distprep.sh b/scripts/distprep.sh index 7f0ecee..7fc2dad 100755 --- a/scripts/distprep.sh +++ b/scripts/distprep.sh @@ -231,7 +231,8 @@ for y in src/backend/parser/gram \ src/backend/replication/repl_gram \ src/backend/replication/syncrep_gram \ src/backend/utils/adt/jsonpath_gram \ - src/pl/plpgsql/src/pl_gram; do + src/pl/plpgsql/src/pl_gram \ + src/bin/pgbench/exprparse; do bison -d -o "${y}.c" "${y}.y" record "${y}.c" "${y}.h" done @@ -248,6 +249,7 @@ flex_gen "-CF -p -p" src/backend/replication/syncrep_scanner flex_gen "-CF -p -p" src/backend/utils/misc/guc-file flex_gen "-Cfe -p -p" src/fe_utils/psqlscan flex_gen "-Cfe -p -p" src/bin/psql/psqlscanslash +flex_gen "" src/bin/pgbench/exprscan sort -u "$MANIFEST" -o "$MANIFEST"