| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * gramparse.h |
| 4 | * Shared definitions for the "raw" parser (flex and bison phases only) |
| 5 | * |
| 6 | * NOTE: this file is only meant to be included in the core parsing files, |
| 7 | * ie, parser.c, gram.y, scan.l, and src/common/keywords.c. |
| 8 | * Definitions that are needed outside the core parser should be in parser.h. |
| 9 | * |
| 10 | * |
| 11 | * Portions Copyright (c) 1996-2017, PostgreSQL Global Development PGGroup |
| 12 | * Portions Copyright (c) 1994, Regents of the University of California |
| 13 | * |
| 14 | * src/include/parser/gramparse.h |
| 15 | * |
| 16 | *------------------------------------------------------------------------- |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "nodes/parsenodes.hpp" |
| 22 | #include "parser/scanner.hpp" |
| 23 | #include "parser/gram.hpp" |
| 24 | |
| 25 | /* |
| 26 | * The YY_EXTRA data that a flex scanner allows us to pass around. Private |
| 27 | * state needed for raw parsing/lexing goes here. |
| 28 | */ |
| 29 | typedef struct |
| 30 | { |
| 31 | /* |
| 32 | * Fields used by the core scanner. |
| 33 | */ |
| 34 | core_yy_extra_type ; |
| 35 | |
| 36 | /* |
| 37 | * State variables for base_yylex(). |
| 38 | */ |
| 39 | bool ; /* is lookahead info valid? */ |
| 40 | int ; /* one-token lookahead */ |
| 41 | core_YYSTYPE ; /* yylval for lookahead token */ |
| 42 | YYLTYPE ; /* yylloc for lookahead token */ |
| 43 | char *; /* end of current token */ |
| 44 | char ; /* to be put back at *lookahead_end */ |
| 45 | |
| 46 | /* |
| 47 | * State variables that belong to the grammar. |
| 48 | */ |
| 49 | PGList *; /* final parse result is delivered here */ |
| 50 | } ; |
| 51 | |
| 52 | /* |
| 53 | * In principle we should use yyget_extra() to fetch the yyextra field |
| 54 | * from a yyscanner struct. However, flex always puts that field first, |
| 55 | * and this is sufficiently performance-critical to make it seem worth |
| 56 | * cheating a bit to use an inline macro. |
| 57 | */ |
| 58 | #define (yyscanner) (*((base_yy_extra_type **) (yyscanner))) |
| 59 | |
| 60 | |
| 61 | /* from parser.c */ |
| 62 | extern int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, |
| 63 | core_yyscan_t yyscanner); |
| 64 | |
| 65 | /* from gram.y */ |
| 66 | extern void (base_yy_extra_type *yyext); |
| 67 | extern int base_yyparse(core_yyscan_t yyscanner); |
| 68 | |
| 69 | |