aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-03-19 12:07:16 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-03-19 12:07:24 -0400
commit72b1e3a21f0540ffa5c1f8f474b6c52097a368bb (patch)
treed674d146a01972573c9db10fc4a61906d40a87e4 /src/backend
parent7bafffea647e21864cb857ab5b6fe266f2d0976a (diff)
downloadpostgresql-72b1e3a21f0540ffa5c1f8f474b6c52097a368bb.tar.gz
postgresql-72b1e3a21f0540ffa5c1f8f474b6c52097a368bb.zip
Build backend/parser/scan.l and interfaces/ecpg/preproc/pgc.l standalone.
Now that we know about the %top{} trick, we can revert to building flex lexers as separate .o files. This is worth doing for a couple of reasons besides sheer cleanliness. We can narrow the scope of the -Wno-error flag that's forced on scan.c. Also, since these grammar and lexer files are so large, splitting them into separate build targets should have some advantages in build speed, particularly in parallel or ccache'd builds. We have quite a few other .l files that could be changed likewise, but the above arguments don't apply to them, so the benefit of fixing them seems pretty minimal. Leave the rest for some other day.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/parser/Makefile9
-rw-r--r--src/backend/parser/gram.y10
-rw-r--r--src/backend/parser/scan.l9
3 files changed, 8 insertions, 20 deletions
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 0395bd5934a..9cc8946fa1b 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -12,7 +12,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
-OBJS= analyze.o gram.o keywords.o kwlookup.o parser.o \
+OBJS= analyze.o gram.o scan.o keywords.o kwlookup.o parser.o \
parse_agg.o parse_clause.o parse_coerce.o parse_collate.o parse_cte.o \
parse_expr.o parse_func.o parse_node.o parse_oper.o parse_param.o \
parse_relation.o parse_target.o parse_type.o parse_utilcmd.o scansup.o
@@ -20,12 +20,9 @@ OBJS= analyze.o gram.o keywords.o kwlookup.o parser.o \
include $(top_srcdir)/src/backend/common.mk
-# scan is compiled as part of gram
-gram.o: scan.c
-
# Latest flex causes warnings in this file.
ifeq ($(GCC),yes)
-gram.o: CFLAGS += -Wno-error
+scan.o: CFLAGS += -Wno-error
endif
@@ -47,7 +44,7 @@ scan.c: FLEX_NO_BACKUP=yes
# Force these dependencies to be known even without dependency info built:
-gram.o keywords.o parser.o: gram.h
+gram.o scan.o keywords.o parser.o: gram.h
# gram.c, gram.h, and scan.c are in the distribution tarball, so they
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index b9aeb3171f7..a74fb772e14 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -14908,13 +14908,3 @@ parser_init(base_yy_extra_type *yyext)
{
yyext->parsetree = NIL; /* in case grammar forgets to set it */
}
-
-/*
- * Must undefine this stuff before including scan.c, since it has different
- * definitions for these macros.
- */
-#undef yyerror
-#undef yylval
-#undef yylloc
-
-#include "scan.c"
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 69def847376..d6322766c7d 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -1,4 +1,4 @@
-%{
+%top{
/*-------------------------------------------------------------------------
*
* scan.l
@@ -6,7 +6,7 @@
*
* NOTE NOTE NOTE:
*
- * The rules in this file must be kept in sync with psql's lexer!!!
+ * The rules in this file must be kept in sync with psql's psqlscan.l!
*
* The rules are designed so that the scanner never has to backtrack,
* in the sense that there is always a rule that can match the input
@@ -34,12 +34,13 @@
#include <ctype.h>
#include <unistd.h>
+#include "parser/gramparse.h"
#include "parser/parser.h" /* only needed for GUC variables */
-#include "parser/scanner.h"
#include "parser/scansup.h"
#include "mb/pg_wchar.h"
+}
-
+%{
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf
#define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg)