Skip to content

Commit 6566e37

Browse files
committed
Move some declarations in the raw-parser header files to create a clearer
distinction between the external API (parser.h) and declarations that only need to be visible within the raw parser code (gramparse.h, which now is only included by parser.c, gram.y, scan.l, and keywords.c). This is in preparation for the upcoming change to a reentrant lexer, which will require referencing YYSTYPE in the declarations of base_yylex and filtered_base_yylex, hence gram.h will have to be included by gramparse.h. We don't want any more files than absolutely necessary to depend on gram.h, so some cleanup is called for.
1 parent 23d830b commit 6566e37

File tree

12 files changed

+53
-44
lines changed

12 files changed

+53
-44
lines changed

src/backend/commands/proclang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.85 2009/06/11 14:48:56 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.86 2009/07/12 17:12:33 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -28,8 +28,8 @@
2828
#include "commands/defrem.h"
2929
#include "commands/proclang.h"
3030
#include "miscadmin.h"
31-
#include "parser/gramparse.h"
3231
#include "parser/parse_func.h"
32+
#include "parser/parser.h"
3333
#include "utils/acl.h"
3434
#include "utils/builtins.h"
3535
#include "utils/fmgroids.h"

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.288 2009/06/18 01:27:02 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.289 2009/07/12 17:12:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -51,7 +51,6 @@
5151
#include "nodes/nodeFuncs.h"
5252
#include "nodes/parsenodes.h"
5353
#include "optimizer/clauses.h"
54-
#include "parser/gramparse.h"
5554
#include "parser/parse_clause.h"
5655
#include "parser/parse_coerce.h"
5756
#include "parser/parse_expr.h"

src/backend/parser/gram.y

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/*-------------------------------------------------------------------------
55
*
66
* gram.y
7-
* POSTGRES SQL YACC rules/actions
7+
* POSTGRESQL BISON rules/actions
88
*
99
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.666 2009/07/06 02:58:40 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.667 2009/07/12 17:12:33 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -58,6 +58,7 @@
5858
#include "nodes/makefuncs.h"
5959
#include "nodes/nodeFuncs.h"
6060
#include "parser/gramparse.h"
61+
#include "parser/parser.h"
6162
#include "storage/lmgr.h"
6263
#include "utils/date.h"
6364
#include "utils/datetime.h"
@@ -6807,7 +6808,7 @@ opt_hold: /* EMPTY */ { $$ = 0; }
68076808
*
68086809
* There is an ambiguity when a sub-SELECT is within an a_expr and there
68096810
* are excess parentheses: do the parentheses belong to the sub-SELECT or
6810-
* to the surrounding a_expr? We don't really care, but yacc wants to know.
6811+
* to the surrounding a_expr? We don't really care, but bison wants to know.
68116812
* To resolve the ambiguity, we are careful to define the grammar so that
68126813
* the decision is staved off as long as possible: as long as we can keep
68136814
* absorbing parentheses into the sub-SELECT, we will do so, and only when
@@ -8204,7 +8205,7 @@ a_expr: c_expr { $$ = $1; }
82048205
}
82058206
/*
82068207
* These operators must be called out explicitly in order to make use
8207-
* of yacc/bison's automatic operator-precedence handling. All other
8208+
* of bison's automatic operator-precedence handling. All other
82088209
* operator names are handled by the generic productions using "Op",
82098210
* below; and all those operators will have the same precedence.
82108211
*

src/backend/parser/keywords.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.212 2009/03/08 16:53:30 alvherre Exp $
12+
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.213 2009/07/12 17:12:33 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
1616
#include "postgres.h"
1717

18-
#include "nodes/nodes.h"
19-
#include "nodes/parsenodes.h"
18+
#include "parser/gramparse.h"
2019
#include "parser/keywords.h"
21-
#include "parser/gram.h"
2220

2321
#define PG_KEYWORD(a,b,c) {a,b,c},
2422

src/backend/parser/parse_utilcmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
22-
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.21 2009/06/11 14:49:00 momjian Exp $
22+
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.22 2009/07/12 17:12:34 tgl Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -42,12 +42,12 @@
4242
#include "nodes/makefuncs.h"
4343
#include "nodes/nodeFuncs.h"
4444
#include "parser/analyze.h"
45-
#include "parser/gramparse.h"
4645
#include "parser/parse_clause.h"
4746
#include "parser/parse_expr.h"
4847
#include "parser/parse_relation.h"
4948
#include "parser/parse_type.h"
5049
#include "parser/parse_utilcmd.h"
50+
#include "parser/parser.h"
5151
#include "rewrite/rewriteManip.h"
5252
#include "utils/acl.h"
5353
#include "utils/builtins.h"

src/backend/parser/parser.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.78 2009/06/11 14:49:00 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.79 2009/07/12 17:12:34 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
2121

2222
#include "postgres.h"
2323

24-
#include "parser/gramparse.h" /* required before parser/gram.h! */
25-
#include "parser/gram.h"
24+
#include "parser/gramparse.h"
2625
#include "parser/parser.h"
2726

2827

src/backend/parser/scan.l

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
2626
* IDENTIFICATION
27-
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.153 2009/05/05 21:09:23 tgl Exp $
27+
* $PostgreSQL: pgsql/src/backend/parser/scan.l,v 1.154 2009/07/12 17:12:34 tgl Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -35,8 +35,6 @@
3535

3636
#include "parser/gramparse.h"
3737
#include "parser/keywords.h"
38-
/* Not needed now that this file is compiled as part of gram.y */
39-
/* #include "parser/gram.h" */
4038
#include "parser/scansup.h"
4139
#include "mb/pg_wchar.h"
4240

src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.300 2009/06/11 14:49:04 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.301 2009/07/12 17:12:34 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -39,10 +39,10 @@
3939
#include "nodes/nodeFuncs.h"
4040
#include "optimizer/clauses.h"
4141
#include "optimizer/tlist.h"
42-
#include "parser/gramparse.h"
4342
#include "parser/keywords.h"
4443
#include "parser/parse_func.h"
4544
#include "parser/parse_oper.h"
45+
#include "parser/parser.h"
4646
#include "parser/parsetree.h"
4747
#include "rewrite/rewriteHandler.h"
4848
#include "rewrite/rewriteManip.h"

src/backend/utils/misc/guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.505 2009/06/11 14:49:06 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.506 2009/07/12 17:12:34 tgl Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -44,10 +44,10 @@
4444
#include "optimizer/geqo.h"
4545
#include "optimizer/paths.h"
4646
#include "optimizer/planmain.h"
47-
#include "parser/gramparse.h"
4847
#include "parser/parse_expr.h"
4948
#include "parser/parse_relation.h"
5049
#include "parser/parse_type.h"
50+
#include "parser/parser.h"
5151
#include "parser/scansup.h"
5252
#include "pgstat.h"
5353
#include "postmaster/autovacuum.h"

src/include/parser/gramparse.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/*-------------------------------------------------------------------------
22
*
33
* gramparse.h
4-
* Declarations for routines exported from lexer and parser files.
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 keywords.c. Definitions that are needed
8+
* outside the core parser should be in parser.h.
59
*
610
*
711
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
812
* Portions Copyright (c) 1994, Regents of the University of California
913
*
10-
* $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.44 2009/06/11 14:49:11 momjian Exp $
14+
* $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.45 2009/07/12 17:12:34 tgl Exp $
1115
*
1216
*-------------------------------------------------------------------------
1317
*/
@@ -27,17 +31,10 @@
2731
*/
2832
#define YYLTYPE int
2933

30-
typedef enum
31-
{
32-
BACKSLASH_QUOTE_OFF,
33-
BACKSLASH_QUOTE_ON,
34-
BACKSLASH_QUOTE_SAFE_ENCODING
35-
} BackslashQuoteType;
36-
37-
/* GUC variables in scan.l (every one of these is a bad idea :-() */
38-
extern int backslash_quote;
39-
extern bool escape_string_warning;
40-
extern bool standard_conforming_strings;
34+
/*
35+
* After defining YYLTYPE, it's safe to include gram.h.
36+
*/
37+
#include "parser/gram.h"
4138

4239

4340
/* from parser.c */
@@ -53,7 +50,5 @@ extern void base_yyerror(const char *message);
5350
/* from gram.y */
5451
extern void parser_init(void);
5552
extern int base_yyparse(void);
56-
extern List *SystemFuncName(char *name);
57-
extern TypeName *SystemTypeName(char *name);
5853

5954
#endif /* GRAMPARSE_H */

src/include/parser/parser.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
11
/*-------------------------------------------------------------------------
22
*
33
* parser.h
4-
* Definitions for the "raw" parser (lex and yacc phases only)
4+
* Definitions for the "raw" parser (flex and bison phases only)
55
*
6+
* This is the external API for the raw lexing/parsing functions.
67
*
78
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
89
* Portions Copyright (c) 1994, Regents of the University of California
910
*
10-
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.25 2009/04/19 21:50:08 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.26 2009/07/12 17:12:34 tgl Exp $
1112
*
1213
*-------------------------------------------------------------------------
1314
*/
1415
#ifndef PARSER_H
1516
#define PARSER_H
1617

17-
#include "nodes/pg_list.h"
18+
#include "nodes/parsenodes.h"
1819

20+
21+
typedef enum
22+
{
23+
BACKSLASH_QUOTE_OFF,
24+
BACKSLASH_QUOTE_ON,
25+
BACKSLASH_QUOTE_SAFE_ENCODING
26+
} BackslashQuoteType;
27+
28+
/* GUC variables in scan.l (every one of these is a bad idea :-() */
29+
extern int backslash_quote;
30+
extern bool escape_string_warning;
31+
extern bool standard_conforming_strings;
32+
33+
34+
/* Primary entry points for the raw parsing functions */
1935
extern List *raw_parser(const char *str);
2036

2137
extern char *pg_parse_string_token(const char *token);
2238

39+
/* Utility functions exported by gram.y (perhaps these should be elsewhere) */
40+
extern List *SystemFuncName(char *name);
41+
extern TypeName *SystemTypeName(char *name);
42+
2343
#endif /* PARSER_H */

src/pl/plpgsql/src/pl_comp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.136 2009/06/11 14:49:14 momjian Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.137 2009/07/12 17:12:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -28,7 +28,6 @@
2828
#include "catalog/pg_type.h"
2929
#include "funcapi.h"
3030
#include "nodes/makefuncs.h"
31-
#include "parser/gramparse.h"
3231
#include "parser/parse_type.h"
3332
#include "tcop/tcopprot.h"
3433
#include "utils/array.h"

0 commit comments

Comments
 (0)