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 | |
24 | namespace duckdb_libpgquery { |
25 | #include "parser/gram.hpp" |
26 | |
27 | /* |
28 | * The YY_EXTRA data that a flex scanner allows us to pass around. Private |
29 | * state needed for raw parsing/lexing goes here. |
30 | */ |
31 | typedef struct { |
32 | /* |
33 | * Fields used by the core scanner. |
34 | */ |
35 | core_yy_extra_type ; |
36 | |
37 | /* |
38 | * State variables for base_yylex(). |
39 | */ |
40 | bool ; /* is lookahead info valid? */ |
41 | int ; /* one-token lookahead */ |
42 | core_YYSTYPE ; /* yylval for lookahead token */ |
43 | YYLTYPE ; /* yylloc for lookahead token */ |
44 | char *; /* end of current token */ |
45 | char ; /* to be put back at *lookahead_end */ |
46 | |
47 | /* |
48 | * State variables that belong to the grammar. |
49 | */ |
50 | PGList *; /* final parse result is delivered here */ |
51 | } ; |
52 | |
53 | /* |
54 | * In principle we should use yyget_extra() to fetch the yyextra field |
55 | * from a yyscanner struct. However, flex always puts that field first, |
56 | * and this is sufficiently performance-critical to make it seem worth |
57 | * cheating a bit to use an inline macro. |
58 | */ |
59 | #define (yyscanner) (*((base_yy_extra_type **)(yyscanner))) |
60 | |
61 | /* from parser.c */ |
62 | int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, core_yyscan_t yyscanner); |
63 | |
64 | /* from gram.y */ |
65 | void (base_yy_extra_type *yyext); |
66 | int base_yyparse(core_yyscan_t yyscanner); |
67 | |
68 | } |