Skip to content

Commit 46825d4

Browse files
committed
Clean up some sloppy coding in repl_gram.y.
Remove unused copy-and-pasted macro definitions, and improve formatting of recently-added productions. I got interested in this because buildfarm member protosciurus has been crashing in "bison repl_gram.y" since commit 858ec11. It's a long shot that this will fix that, though maybe the missing trailing semicolon has something to do with it? In any case, there's no need to approve of dead code, nor of code whose formatting isn't even self-consistent let alone consistent with what's around it.
1 parent 0753bdb commit 46825d4

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

src/backend/replication/repl_gram.y

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@
2525
/* Result of the parsing is returned here */
2626
Node *replication_parse_result;
2727

28-
/* Location tracking support --- simpler than bison's default */
29-
#define YYLLOC_DEFAULT(Current, Rhs, N) \
30-
do { \
31-
if (N) \
32-
(Current) = (Rhs)[1]; \
33-
else \
34-
(Current) = (Rhs)[0]; \
35-
} while (0)
3628

3729
/*
3830
* Bison doesn't allocate anything that needs to live across parser calls,
@@ -45,9 +37,6 @@ Node *replication_parse_result;
4537
#define YYMALLOC palloc
4638
#define YYFREE pfree
4739

48-
#define parser_yyerror(msg) replication_yyerror(msg, yyscanner)
49-
#define parser_errposition(pos) replication_scanner_errposition(pos)
50-
5140
%}
5241

5342
%expect 0
@@ -91,6 +80,7 @@ Node *replication_parse_result;
9180
%type <defelt> base_backup_opt
9281
%type <uintval> opt_timeline
9382
%type <str> opt_slot
83+
9484
%%
9585

9686
firstcmd: command opt_semicolon
@@ -134,34 +124,38 @@ base_backup:
134124
}
135125
;
136126

137-
base_backup_opt_list: base_backup_opt_list base_backup_opt { $$ = lappend($1, $2); }
138-
| /* EMPTY */ { $$ = NIL; }
127+
base_backup_opt_list:
128+
base_backup_opt_list base_backup_opt
129+
{ $$ = lappend($1, $2); }
130+
| /* EMPTY */
131+
{ $$ = NIL; }
132+
;
139133

140134
base_backup_opt:
141135
K_LABEL SCONST
142136
{
143137
$$ = makeDefElem("label",
144-
(Node *)makeString($2));
138+
(Node *)makeString($2));
145139
}
146140
| K_PROGRESS
147141
{
148142
$$ = makeDefElem("progress",
149-
(Node *)makeInteger(TRUE));
143+
(Node *)makeInteger(TRUE));
150144
}
151145
| K_FAST
152146
{
153147
$$ = makeDefElem("fast",
154-
(Node *)makeInteger(TRUE));
148+
(Node *)makeInteger(TRUE));
155149
}
156150
| K_WAL
157151
{
158152
$$ = makeDefElem("wal",
159-
(Node *)makeInteger(TRUE));
153+
(Node *)makeInteger(TRUE));
160154
}
161155
| K_NOWAIT
162156
{
163157
$$ = makeDefElem("nowait",
164-
(Node *)makeInteger(TRUE));
158+
(Node *)makeInteger(TRUE));
165159
}
166160
;
167161

@@ -214,7 +208,8 @@ opt_timeline:
214208
(errmsg("invalid timeline %u", $2))));
215209
$$ = $2;
216210
}
217-
| /* nothing */ { $$ = 0; }
211+
| /* EMPTY */
212+
{ $$ = 0; }
218213
;
219214

220215
/*
@@ -237,14 +232,18 @@ timeline_history:
237232
}
238233
;
239234

240-
opt_physical : K_PHYSICAL | /* EMPTY */;
235+
opt_physical:
236+
K_PHYSICAL
237+
| /* EMPTY */
238+
;
241239

240+
opt_slot:
241+
K_SLOT IDENT
242+
{ $$ = $2; }
243+
| /* EMPTY */
244+
{ $$ = NULL; }
245+
;
242246

243-
opt_slot : K_SLOT IDENT
244-
{
245-
$$ = $2;
246-
}
247-
| /* nothing */ { $$ = NULL; }
248247
%%
249248

250249
#include "repl_scanner.c"

0 commit comments

Comments
 (0)