提交 72b1e3a2 编写于 作者: T Tom Lane

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.
上级 7bafffea
...@@ -12,7 +12,7 @@ include $(top_builddir)/src/Makefile.global ...@@ -12,7 +12,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) 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_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_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 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 \ ...@@ -20,12 +20,9 @@ OBJS= analyze.o gram.o keywords.o kwlookup.o parser.o \
include $(top_srcdir)/src/backend/common.mk 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. # Latest flex causes warnings in this file.
ifeq ($(GCC),yes) ifeq ($(GCC),yes)
gram.o: CFLAGS += -Wno-error scan.o: CFLAGS += -Wno-error
endif endif
...@@ -47,7 +44,7 @@ scan.c: FLEX_NO_BACKUP=yes ...@@ -47,7 +44,7 @@ scan.c: FLEX_NO_BACKUP=yes
# Force these dependencies to be known even without dependency info built: # 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 # gram.c, gram.h, and scan.c are in the distribution tarball, so they
......
...@@ -14908,13 +14908,3 @@ parser_init(base_yy_extra_type *yyext) ...@@ -14908,13 +14908,3 @@ parser_init(base_yy_extra_type *yyext)
{ {
yyext->parsetree = NIL; /* in case grammar forgets to set it */ 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"
%{ %top{
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* scan.l * scan.l
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* NOTE NOTE NOTE: * 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, * 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 * in the sense that there is always a rule that can match the input
...@@ -34,12 +34,13 @@ ...@@ -34,12 +34,13 @@
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include "parser/gramparse.h"
#include "parser/parser.h" /* only needed for GUC variables */ #include "parser/parser.h" /* only needed for GUC variables */
#include "parser/scanner.h"
#include "parser/scansup.h" #include "parser/scansup.h"
#include "mb/pg_wchar.h" #include "mb/pg_wchar.h"
}
%{
/* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */
#undef fprintf #undef fprintf
#define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg)
......
...@@ -26,7 +26,7 @@ override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \ ...@@ -26,7 +26,7 @@ override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
override CFLAGS += $(PTHREAD_CFLAGS) -DECPG_COMPILE override CFLAGS += $(PTHREAD_CFLAGS) -DECPG_COMPILE
OBJS= preproc.o type.o ecpg.o output.o parser.o \ OBJS= preproc.o pgc.o type.o ecpg.o output.o parser.o \
keywords.o c_keywords.o ecpg_keywords.o kwlookup.o ../ecpglib/typename.o descriptor.o variable.o \ keywords.o c_keywords.o ecpg_keywords.o kwlookup.o ../ecpglib/typename.o descriptor.o variable.o \
$(WIN32RES) $(WIN32RES)
...@@ -44,9 +44,6 @@ ecpg: $(OBJS) | submake-libpgport ...@@ -44,9 +44,6 @@ ecpg: $(OBJS) | submake-libpgport
../ecpglib/typename.o: ../ecpglib/typename.c ../ecpglib/typename.o: ../ecpglib/typename.c
$(MAKE) -C $(dir $@) $(notdir $@) $(MAKE) -C $(dir $@) $(notdir $@)
# pgc is compiled as part of preproc
preproc.o: pgc.c
preproc.h: preproc.c ; preproc.h: preproc.c ;
preproc.c: BISONFLAGS += -d preproc.c: BISONFLAGS += -d
...@@ -54,7 +51,7 @@ preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg. ...@@ -54,7 +51,7 @@ preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.
$(PERL) $(srcdir)/parse.pl $(srcdir) < $< > $@ $(PERL) $(srcdir)/parse.pl $(srcdir) < $< > $@
$(PERL) $(srcdir)/check_rules.pl $(srcdir) $< $(PERL) $(srcdir)/check_rules.pl $(srcdir) $<
ecpg_keywords.o c_keywords.o keywords.o preproc.o parser.o: preproc.h ecpg_keywords.o c_keywords.o keywords.o preproc.o pgc.o parser.o: preproc.h
kwlookup.c: % : $(top_srcdir)/src/backend/parser/% kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
......
...@@ -1916,11 +1916,3 @@ void parser_init(void) ...@@ -1916,11 +1916,3 @@ void parser_init(void)
{ {
/* This function is empty. It only exists for compatibility with the backend parser right now. */ /* This function is empty. It only exists for compatibility with the backend parser right now. */
} }
/*
* Must undefine base_yylex before including pgc.c, since we want it
* to create the function base_yylex not filtered_base_yylex.
*/
#undef base_yylex
#include "pgc.c"
%{ %top{
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* *
* pgc.l * pgc.l
...@@ -23,7 +23,19 @@ ...@@ -23,7 +23,19 @@
#include <limits.h> #include <limits.h>
#include "extern.h" #include "extern.h"
#include "preproc.h"
/*
* Change symbol names as expected by preproc.l. It'd be better to do this
* with %option prefix="base_yy", but that affects some other names that
* various files expect *not* to be prefixed with "base_". Cleaning it up
* is not worth the trouble right now.
*/
#define yylex base_yylex
#define yylval base_yylval
}
%{
extern YYSTYPE yylval; extern YYSTYPE yylval;
static int xcdepth = 0; /* depth of nesting in slash-star comments */ static int xcdepth = 0; /* depth of nesting in slash-star comments */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册