*
* 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
*
* src/include/parser/gramparse.h
*
* -------------------------------------------------------------------------
*/
#ifndef GRAMPARSE_H
#define GRAMPARSE_H
#include "parser/scanner.h"
* NB: include gram.h only AFTER including scanner.h, because scanner.h
* is what #defines YYLTYPE.
*/
#ifndef FRONTEND_PARSER
#ifdef PARSE_HINT_h
#include "parser/hint_gram.hpp"
#else
#include "parser/gram.hpp"
#endif
#else
#include "nodes/value.h"
#include "frontend_parser/gram.hpp"
#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;
YYLTYPE yyleng;
YYLTYPE 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;
base_yy_lookahead lookaheads[MAX_LOOKAHEAD_LEN];
* State variables that belong to the grammar.
*/
List* parsetree;
} base_yy_extra_type;
#ifdef FRONTEND_PARSER
typedef struct fe_base_yy_extra_type {
* Fields used by the core scanner.
*/
fe_core_yy_extra_type core_yy_extra;
* State variables for base_yylex().
*/
int lookahead_num;
int lookahead_token[MAX_LOOKAHEAD_LEN];
core_YYSTYPE lookahead_yylval[MAX_LOOKAHEAD_LEN];
YYLTYPE lookahead_yylloc[MAX_LOOKAHEAD_LEN];
* State variables that belong to the grammar.
*/
List *parsetree;
} fe_base_yy_extra_type;
#endif
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 scanbuflen;
* The keyword list to use.
*/
const ScanKeywordList *keywordlist;
const uint16 *keyword_tokens;
* 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;
List* query_string_locationlist;
bool in_slash_proc_body;
int paren_depth;
bool is_createstmt;
bool is_hint_str;
List* parameter_list;
} hint_yy_extra_type;
#ifdef PARSE_HINT_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 pg_yyget_extra(yyscanner) (*((base_yy_extra_type**)(yyscanner)))
#ifdef FRONTEND_PARSER
#define fe_pg_yyget_extra(yyscanner) (*((fe_base_yy_extra_type **) (yyscanner)))
#endif
extern int 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);
#ifdef FRONTEND_PARSER
extern void fe_parser_init(fe_base_yy_extra_type *yyext);
#endif
#endif
#endif