Move some declarations in the raw-parser header files to create a clearer
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Jul 2009 17:12:34 +0000 (17:12 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 12 Jul 2009 17:12:34 +0000 (17:12 +0000)
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.

12 files changed:
src/backend/commands/proclang.c
src/backend/commands/tablecmds.c
src/backend/parser/gram.y
src/backend/parser/keywords.c
src/backend/parser/parse_utilcmd.c
src/backend/parser/parser.c
src/backend/parser/scan.l
src/backend/utils/adt/ruleutils.c
src/backend/utils/misc/guc.c
src/include/parser/gramparse.h
src/include/parser/parser.h
src/pl/plpgsql/src/pl_comp.c

index 3faf44568b9cd56704425263b58007c7330bdf3a..9dec622a18c59218390eb859c911a41080ee9ffa 100644 (file)
@@ -28,8 +28,8 @@
 #include "commands/defrem.h"
 #include "commands/proclang.h"
 #include "miscadmin.h"
-#include "parser/gramparse.h"
 #include "parser/parse_func.h"
+#include "parser/parser.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
index 7afe6e7f026352ffc2727c0fee0d9af886616e84..2f84e7d8fcdd401e7680a73e610250a141bfefed 100644 (file)
@@ -51,7 +51,6 @@
 #include "nodes/nodeFuncs.h"
 #include "nodes/parsenodes.h"
 #include "optimizer/clauses.h"
-#include "parser/gramparse.h"
 #include "parser/parse_clause.h"
 #include "parser/parse_coerce.h"
 #include "parser/parse_expr.h"
index 20ab0bac2afa791781c91e107ab0154b78678405..265bf54a315b94704f2ed7b8c816cab75d1d874d 100644 (file)
@@ -4,7 +4,7 @@
 /*-------------------------------------------------------------------------
  *
  * gram.y
- *       POSTGRES SQL YACC rules/actions
+ *       POSTGRESQL BISON rules/actions
  *
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
@@ -58,6 +58,7 @@
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
 #include "parser/gramparse.h"
+#include "parser/parser.h"
 #include "storage/lmgr.h"
 #include "utils/date.h"
 #include "utils/datetime.h"
@@ -6807,7 +6808,7 @@ opt_hold: /* EMPTY */                                             { $$ = 0; }
  *
  * There is an ambiguity when a sub-SELECT is within an a_expr and there
  * are excess parentheses: do the parentheses belong to the sub-SELECT or
- * to the surrounding a_expr?  We don't really care, but yacc wants to know.
+ * to the surrounding a_expr?  We don't really care, but bison wants to know.
  * To resolve the ambiguity, we are careful to define the grammar so that
  * the decision is staved off as long as possible: as long as we can keep
  * absorbing parentheses into the sub-SELECT, we will do so, and only when
@@ -8204,7 +8205,7 @@ a_expr:           c_expr                                                                  { $$ = $1; }
                                }
                /*
                 * These operators must be called out explicitly in order to make use
-                * of yacc/bison's automatic operator-precedence handling.  All other
+                * of bison's automatic operator-precedence handling.  All other
                 * operator names are handled by the generic productions using "Op",
                 * below; and all those operators will have the same precedence.
                 *
index 83db2d2b9c8caa799677caa4e0ebe67b84cb1abe..5a56a1f17cda513d934d8bac670841fbc71ec3e0 100644 (file)
  */
 #include "postgres.h"
 
-#include "nodes/nodes.h"
-#include "nodes/parsenodes.h"
+#include "parser/gramparse.h"
 #include "parser/keywords.h"
-#include "parser/gram.h"
 
 #define PG_KEYWORD(a,b,c) {a,b,c},
 
index d9ce64adbd727621522802ff47f91c803f9da196..2bcf2619cf5a520c0b09ea1f8366f3c4724bb916 100644 (file)
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
 #include "parser/analyze.h"
-#include "parser/gramparse.h"
 #include "parser/parse_clause.h"
 #include "parser/parse_expr.h"
 #include "parser/parse_relation.h"
 #include "parser/parse_type.h"
 #include "parser/parse_utilcmd.h"
+#include "parser/parser.h"
 #include "rewrite/rewriteManip.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
index 48465f62bd232cfa7efd81488bd1d535945feab6..ad8f1a740a70e04eeda048a4879410f07ef1318e 100644 (file)
@@ -21,8 +21,7 @@
 
 #include "postgres.h"
 
-#include "parser/gramparse.h"  /* required before parser/gram.h! */
-#include "parser/gram.h"
+#include "parser/gramparse.h"
 #include "parser/parser.h"
 
 
index 6448cf2bcfc90fffe2a5ac019baebd402887e090..54d82bf16b1d42d67c75c3d96d606b58034aee13 100644 (file)
@@ -35,8 +35,6 @@
 
 #include "parser/gramparse.h"
 #include "parser/keywords.h"
-/* Not needed now that this file is compiled as part of gram.y */
-/* #include "parser/gram.h" */
 #include "parser/scansup.h"
 #include "mb/pg_wchar.h"
 
index d302fb852803587ca00049622941acad3d7aff7a..1562a5444c7395e303e85d30c143abd4c1cf7e36 100644 (file)
 #include "nodes/nodeFuncs.h"
 #include "optimizer/clauses.h"
 #include "optimizer/tlist.h"
-#include "parser/gramparse.h"
 #include "parser/keywords.h"
 #include "parser/parse_func.h"
 #include "parser/parse_oper.h"
+#include "parser/parser.h"
 #include "parser/parsetree.h"
 #include "rewrite/rewriteHandler.h"
 #include "rewrite/rewriteManip.h"
index 24301852b856a8cf56def5b98d9c314c12ffbf91..11ebac80b34aa90bf7cf9c61ec7e872a66abb192 100644 (file)
 #include "optimizer/geqo.h"
 #include "optimizer/paths.h"
 #include "optimizer/planmain.h"
-#include "parser/gramparse.h"
 #include "parser/parse_expr.h"
 #include "parser/parse_relation.h"
 #include "parser/parse_type.h"
+#include "parser/parser.h"
 #include "parser/scansup.h"
 #include "pgstat.h"
 #include "postmaster/autovacuum.h"
index 6781bcec505bccc4f38de31e5871ebae17a3c842..a42c8f671f3fb766595efe6626fec483734c9788 100644 (file)
@@ -1,7 +1,11 @@
 /*-------------------------------------------------------------------------
  *
  * gramparse.h
- *       Declarations for routines exported from lexer and parser files.
+ *             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-2009, PostgreSQL Global Development Group
  */
 #define YYLTYPE  int
 
-typedef enum
-{
-       BACKSLASH_QUOTE_OFF,
-       BACKSLASH_QUOTE_ON,
-       BACKSLASH_QUOTE_SAFE_ENCODING
-} BackslashQuoteType;
-
-/* GUC variables in scan.l (every one of these is a bad idea :-() */
-extern int     backslash_quote;
-extern bool escape_string_warning;
-extern bool standard_conforming_strings;
+/*
+ * After defining YYLTYPE, it's safe to include gram.h.
+ */
+#include "parser/gram.h"
 
 
 /* from parser.c */
@@ -53,7 +50,5 @@ extern void base_yyerror(const char *message);
 /* from gram.y */
 extern void parser_init(void);
 extern int     base_yyparse(void);
-extern List *SystemFuncName(char *name);
-extern TypeName *SystemTypeName(char *name);
 
 #endif   /* GRAMPARSE_H */
index c64c390156b1fdf9abef19fb1f8201f3d72956e7..24aded5a3d18107bd72e5e749eb2e9dbd35adea6 100644 (file)
@@ -1,8 +1,9 @@
 /*-------------------------------------------------------------------------
  *
  * parser.h
- *             Definitions for the "raw" parser (lex and yacc phases only)
+ *             Definitions for the "raw" parser (flex and bison phases only)
  *
+ * This is the external API for the raw lexing/parsing functions.
  *
  * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
 #ifndef PARSER_H
 #define PARSER_H
 
-#include "nodes/pg_list.h"
+#include "nodes/parsenodes.h"
 
+
+typedef enum
+{
+       BACKSLASH_QUOTE_OFF,
+       BACKSLASH_QUOTE_ON,
+       BACKSLASH_QUOTE_SAFE_ENCODING
+} BackslashQuoteType;
+
+/* GUC variables in scan.l (every one of these is a bad idea :-() */
+extern int     backslash_quote;
+extern bool escape_string_warning;
+extern bool standard_conforming_strings;
+
+
+/* Primary entry points for the raw parsing functions */
 extern List *raw_parser(const char *str);
 
 extern char *pg_parse_string_token(const char *token);
 
+/* Utility functions exported by gram.y (perhaps these should be elsewhere) */
+extern List *SystemFuncName(char *name);
+extern TypeName *SystemTypeName(char *name);
+
 #endif   /* PARSER_H */
index 62f689ec21adfc53c3f40b6cafa7cf3158020ff4..028013f860f531dcb76f8170a1fa4a63ac94a8d7 100644 (file)
@@ -28,7 +28,6 @@
 #include "catalog/pg_type.h"
 #include "funcapi.h"
 #include "nodes/makefuncs.h"
-#include "parser/gramparse.h"
 #include "parser/parse_type.h"
 #include "tcop/tcopprot.h"
 #include "utils/array.h"