diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile index 7956b4d577982382287dae463d38ae95d3cc9a1c..60cb1313d2cd1818a31095259286743b43d799f3 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_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 @@ -23,12 +23,9 @@ FLEXFLAGS = -CF 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 @@ -59,7 +56,7 @@ endif # 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 4632387f57c345b8750b284df0452b814da19b54..ecde4af0186470643809bc447066e06f9b312402 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -15455,13 +15455,3 @@ makeIsNotDistinctFromNode(Node *expr, int position) "=", NULL, expr, position), position); return n; } - -/* - * 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 b5ae4204d29690237ee3478d8f36a051074fcf73..7b03835b30b0ccd9da9fe09a49db36d030c120f1 100755 --- 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 @@ -33,11 +33,13 @@ #include #include +#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" +} +%{ #define unify_version(a,b,c) ((a<<16)+(b<<8)+c) #if unify_version(YY_FLEX_MAJOR_VERSION,YY_FLEX_MINOR_VERSION,YY_FLEX_SUBMINOR_VERSION) < unify_version(2,5,35) int base_yyget_lineno (void); diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index 997c21732503b2009288fa4047f2a0d8ae73d09f..4ef91fde03c5c05df7949d02272a762303c2cf5e 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -34,7 +34,7 @@ override CFLAGS += $(PTHREAD_CFLAGS) -DECPG_COMPILE -Wno-unused-label -Wno-erro endif 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 \ $(WIN32RES) @@ -43,9 +43,6 @@ all: submake-libpgport ecpg ecpg: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X) -# pgc is compiled as part of preproc -preproc.o: pgc.c - preproc.h: preproc.c ; preproc.c: preproc.y @@ -66,7 +63,7 @@ preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg. $(PERL) $(srcdir)/parse.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/% rm -f $@ && $(LN_S) $< . diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer index 108f4511fc93eb23cdb310d0bef758b146dd00d2..5770aff33c2fa1cbfb95fbaf613c57fa49ad15f7 100644 --- a/src/interfaces/ecpg/preproc/ecpg.trailer +++ b/src/interfaces/ecpg/preproc/ecpg.trailer @@ -1891,11 +1891,3 @@ void parser_init(void) { /* 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" diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 8c91cff0b7b158fa1202795d9d9dee75c643533b..05c590f14cca0a85547556922b0032ab88fe14a3 100755 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -1,4 +1,4 @@ -%{ +%top{ /*------------------------------------------------------------------------- * * pgc.l @@ -23,7 +23,19 @@ #include #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; static int xcdepth = 0; /* depth of nesting in slash-star comments */