00001 /*------------------------------------------------------------------------- 00002 * 00003 * gramparse.h 00004 * Shared definitions for the "raw" parser (flex and bison phases only) 00005 * 00006 * NOTE: this file is only meant to be included in the core parsing files, 00007 * ie, parser.c, gram.y, scan.l, and keywords.c. Definitions that are needed 00008 * outside the core parser should be in parser.h. 00009 * 00010 * 00011 * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group 00012 * Portions Copyright (c) 1994, Regents of the University of California 00013 * 00014 * src/include/parser/gramparse.h 00015 * 00016 *------------------------------------------------------------------------- 00017 */ 00018 00019 #ifndef GRAMPARSE_H 00020 #define GRAMPARSE_H 00021 00022 #include "nodes/parsenodes.h" 00023 #include "parser/scanner.h" 00024 00025 /* 00026 * NB: include gram.h only AFTER including scanner.h, because scanner.h 00027 * is what #defines YYLTYPE. 00028 */ 00029 #include "parser/gram.h" 00030 00031 /* 00032 * The YY_EXTRA data that a flex scanner allows us to pass around. Private 00033 * state needed for raw parsing/lexing goes here. 00034 */ 00035 typedef struct base_yy_extra_type 00036 { 00037 /* 00038 * Fields used by the core scanner. 00039 */ 00040 core_yy_extra_type core_yy_extra; 00041 00042 /* 00043 * State variables for base_yylex(). 00044 */ 00045 bool have_lookahead; /* is lookahead info valid? */ 00046 int lookahead_token; /* one-token lookahead */ 00047 core_YYSTYPE lookahead_yylval; /* yylval for lookahead token */ 00048 YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */ 00049 00050 /* 00051 * State variables that belong to the grammar. 00052 */ 00053 List *parsetree; /* final parse result is delivered here */ 00054 } base_yy_extra_type; 00055 00056 /* 00057 * In principle we should use yyget_extra() to fetch the yyextra field 00058 * from a yyscanner struct. However, flex always puts that field first, 00059 * and this is sufficiently performance-critical to make it seem worth 00060 * cheating a bit to use an inline macro. 00061 */ 00062 #define pg_yyget_extra(yyscanner) (*((base_yy_extra_type **) (yyscanner))) 00063 00064 00065 /* from parser.c */ 00066 extern int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, 00067 core_yyscan_t yyscanner); 00068 00069 /* from gram.y */ 00070 extern void parser_init(base_yy_extra_type *yyext); 00071 extern int base_yyparse(core_yyscan_t yyscanner); 00072 00073 #endif /* GRAMPARSE_H */