*
* gramparse.h
* Shared definitions for the "raw" parser (flex and bison phases only)
*
* NOTE: this file is only meant to be included in the core parsing files,
* ie, parser.c, gram.y, scan.l, and keywords.c. Definitions that are needed
* outside the core parser should be in parser.h.
*
*
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* pkg/src/ogsql/parser/gramparse.h
*
* -------------------------------------------------------------------------
*/
#ifndef GRAMPARSE_H
#define GRAMPARSE_H
#include "scanner.h"
#include "scansup.h"
#include "ogsql_expr.h"
#include "func_parser.h"
#include "expr_parser.h"
#include "ogsql_cond.h"
#include "ogsql_json_utils.h"
#include "pivot_parser.h"
#include "persist_defs.h"
#include "ddl_index_parser.h"
#include "ddl_partition_parser.h"
#include "ddl_column_parser.h"
#include "ddl_table_attr_parser.h"
#include "pl_memory.h"
#include "pl_compiler.h"
#include "ddl_space_parser.h"
#include "dcl_alter_parser.h"
#include "dcl_database_parser.h"
#include "dcl_transaction_parser.h"
#include "dml_parser.h"
* NB: include gram.h only AFTER including scanner.h, because scanner.h
* is what #defines YYLTYPE.
*/
#ifdef __HINT_PARSER_H__
#include "hint_gram.h"
#else
#include "gram.h"
#endif
* When dealing with some grammar, we must take more than one token lookahead.
*/
#define MAX_LOOKAHEAD_LEN 3
* States for the look ahead token.
*/
struct base_yy_lookahead {
int token;
core_YYSTYPE yylval;
YYLTYPE yylloc;
int yyleng;
int prev_hold_char_loc;
char prev_hold_char;
};
* The `YY_EXTRA` data that a flex scanner allows us to pass around. Private
* state needed for raw parsing/lexing goes here.
*/
typedef struct base_yy_extra_type {
* Fields used by the core scanner.
*/
core_yy_extra_type core_yy_extra;
* State variables for base_yylex().
*/
int lookahead_len;
struct base_yy_lookahead lookaheads[MAX_LOOKAHEAD_LEN];
* State variables that belong to the grammar.
*/
void* parsetree;
} base_yy_extra_type;
typedef struct hint_yy_extra_type {
* The string the scanner is physically scanning. We keep this mainly so
* that we can cheaply compute the offset of the current token (yytext).
*/
char* scanbuf;
size_t scanbuflen;
sql_stmt_t *stmt;
* literalbuf is used to accumulate literal values when multiple rules are
* needed to parse a single literal. Call startlit() to reset buffer to
* empty, addlit() to add text. NOTE: the string in literalbuf is NOT
* necessarily null-terminated, but there always IS room to add a trailing
* null at offset literallen. We store a null only when we need it.
*/
char* literalbuf;
int literallen;
int literalalloc;
int xcdepth;
char* dolqstart;
int32 utf16_first_part;
bool warn_on_first_escape;
bool saw_non_ascii;
bool ident_quoted;
bool warnOnTruncateIdent;
bool in_slash_proc_body;
int paren_depth;
bool is_createstmt;
bool is_hint_str;
galist_t *hint_lst;
} hint_yy_extra_type;
#define og_hint_yyget_extra(yyscanner) (*((hint_yy_extra_type**)(yyscanner)))
#ifdef __HINT_PARSER_H__
extern int yylex(YYSTYPE* lvalp, yyscan_t yyscanner);
extern int yyparse(yyscan_t yyscanner);
#else
* In principle we should use yyget_extra() to fetch the yyextra field
* from a yyscanner struct. However, flex always puts that field first,
* and this is sufficiently performance-critical to make it seem worth
* cheating a bit to use an inline macro.
*/
#define og_yyget_extra(yyscanner) (*((base_yy_extra_type**)(yyscanner)))
typedef int (*core_yylex_func)(core_YYSTYPE*, YYLTYPE*, core_yyscan_t);
extern int base_yylex_common(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner, core_yylex_func yylex_func);
extern int base_yylex(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner);
extern int a_base_yylex(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner);
extern int b_base_yylex(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner);
extern int c_base_yylex(YYSTYPE* lvalp, YYLTYPE* llocp, core_yyscan_t yyscanner);
extern void parser_init(base_yy_extra_type* yyext);
extern int base_yyparse(core_yyscan_t yyscanner);
extern void a_parser_init(base_yy_extra_type* yyext);
extern int a_base_yyparse(core_yyscan_t yyscanner);
extern void a_scanner_finish(core_yyscan_t yyscanner);
extern void b_parser_init(base_yy_extra_type* yyext);
extern int b_base_yyparse(core_yyscan_t yyscanner);
extern void b_scanner_finish(core_yyscan_t yyscanner);
extern void c_parser_init(base_yy_extra_type* yyext);
extern int c_base_yyparse(core_yyscan_t yyscanner);
extern void c_scanner_finish(core_yyscan_t yyscanner);
#endif
typedef struct flex_mem_header {
uint32 magic_number;
size_t bytes;
} flex_mem_header;
#define FLEX_MEM_MAGIC_NUMBER 0xa1b2c3d4
#define FLEX_MEM_HEADER_SIZE CM_ALIGN8(sizeof(flex_mem_header))
#define FLEX_MEM_GET_HEADER(ptr) ((flex_mem_header*)(((char*)(ptr)) - FLEX_MEM_HEADER_SIZE))
#define FLEX_MEM_GET_POINTER(ptr) ((void*)(((char*)(ptr)) + FLEX_MEM_HEADER_SIZE))
#endif