From 4c105b7b415f0937e7fa42e8313c9452a8db1ad4 Mon Sep 17 00:00:00 2001 From: John Naylor Date: Sat, 13 Aug 2022 09:34:17 +0700 Subject: [PATCH v201 5/9] Build specscanner.c standalone --- src/test/isolation/.gitignore | 1 + src/test/isolation/Makefile | 15 +++++++++++---- src/test/isolation/specparse.y | 2 -- src/test/isolation/specscanner.l | 25 ++++++++++++++++--------- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/test/isolation/.gitignore b/src/test/isolation/.gitignore index 870dac4d28..2c13b4bf98 100644 --- a/src/test/isolation/.gitignore +++ b/src/test/isolation/.gitignore @@ -3,6 +3,7 @@ /pg_isolation_regress # Local generated source files +/specparse.h /specparse.c /specscanner.c diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile index 0d452c89d4..b8738b7c1b 100644 --- a/src/test/isolation/Makefile +++ b/src/test/isolation/Makefile @@ -15,7 +15,8 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) \ OBJS = \ $(WIN32RES) \ isolationtester.o \ - specparse.o + specparse.o \ + specscanner.o all: isolationtester$(X) pg_isolation_regress$(X) @@ -44,8 +45,14 @@ isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport distprep: specparse.c specscanner.c -# specscanner is compiled as part of specparse -specparse.o: specscanner.c +# See notes in src/backend/parser/Makefile about the following two rules +specparse.h: specparse.c + touch $@ + +specparse.c: BISONFLAGS += -d + +# Force these dependencies to be known even without dependency info built: +specparse.o specscanner.o: specparse.h # specparse.c and specscanner.c are in the distribution tarball, # so do not clean them here @@ -55,7 +62,7 @@ clean distclean: rm -rf $(pg_regress_clean_files) maintainer-clean: distclean - rm -f specparse.c specscanner.c + rm -f specparse.h specparse.c specscanner.c installcheck: all $(pg_isolation_regress_installcheck) --schedule=$(srcdir)/isolation_schedule diff --git a/src/test/isolation/specparse.y b/src/test/isolation/specparse.y index eb368184b8..657285cc23 100644 --- a/src/test/isolation/specparse.y +++ b/src/test/isolation/specparse.y @@ -276,5 +276,3 @@ blocker: ; %% - -#include "specscanner.c" diff --git a/src/test/isolation/specscanner.l b/src/test/isolation/specscanner.l index aa6e89268e..2dc292c21d 100644 --- a/src/test/isolation/specscanner.l +++ b/src/test/isolation/specscanner.l @@ -1,4 +1,4 @@ -%{ +%top{ /*------------------------------------------------------------------------- * * specscanner.l @@ -9,7 +9,14 @@ * *------------------------------------------------------------------------- */ +#include "postgres_fe.h" + +#include "isolationtester.h" +#include "specparse.h" +} + +%{ static int yyline = 1; /* line number for error reporting */ #define LITBUF_INIT 1024 /* initial size of litbuf */ @@ -75,7 +82,7 @@ teardown { return TEARDOWN; } /* Plain identifiers */ {identifier} { - yylval.str = pg_strdup(yytext); + spec_yylval.str = pg_strdup(yytext); return(identifier); } @@ -87,13 +94,13 @@ teardown { return TEARDOWN; } \"\" { addlitchar(yytext[0]); } \" { litbuf[litbufpos] = '\0'; - yylval.str = pg_strdup(litbuf); + spec_yylval.str = pg_strdup(litbuf); BEGIN(INITIAL); return(identifier); } . { addlitchar(yytext[0]); } -\n { yyerror("unexpected newline in quoted identifier"); } -<> { yyerror("unterminated quoted identifier"); } +\n { spec_yyerror("unexpected newline in quoted identifier"); } +<> { spec_yyerror("unterminated quoted identifier"); } /* SQL blocks: { UPDATE ... } */ /* We trim leading/trailing whitespace, otherwise they're unprocessed */ @@ -104,7 +111,7 @@ teardown { return TEARDOWN; } } {space}*"}" { litbuf[litbufpos] = '\0'; - yylval.str = pg_strdup(litbuf); + spec_yylval.str = pg_strdup(litbuf); BEGIN(INITIAL); return(sqlblock); } @@ -116,12 +123,12 @@ teardown { return TEARDOWN; } addlitchar(yytext[0]); } <> { - yyerror("unterminated sql block"); + spec_yyerror("unterminated sql block"); } /* Numbers and punctuation */ {digit}+ { - yylval.integer = atoi(yytext); + spec_yylval.integer = atoi(yytext); return INTEGER; } @@ -150,7 +157,7 @@ addlitchar(char c) } void -yyerror(const char *message) +spec_yyerror(const char *message) { fprintf(stderr, "%s at line %d\n", message, yyline); exit(1); -- 2.36.1