Skip to content

Commit 6169482

Browse files
committed
regen_perly.pl: remove mostly dead gather_tokens code
The idea behind this code was to find the big enum block in perlytmp.h that looks like: enum yytokentype { YYEMPTY = -2, YYEOF = 0, /* "end of file" */ YYerror = 256, /* error */ YYUNDEF = 257, /* "invalid token" */ GRAMPROG = 258, /* GRAMPROG */ GRAMEXPR = 259, /* GRAMEXPR */ GRAMBLOCK = 260, /* GRAMBLOCK */ ... }; ... and append to it (in perly.h) a series of equivalent macro definitions, one for each (non-negative) enum symbol: #define YYEOF 0 #define YYerror 256 #define YYUNDEF 257 #define GRAMPROG 258 #define GRAMEXPR 259 #define GRAMBLOCK 260 ... However, due to slight formatting changes in the code generated by bison 3+, this code has been essentially dead because the starting regex didn't match anymore, so $gather_tokens was never set to a true value. The last time we had token macros in perly.h was before commit a9f5ab8 (in 2016), in which I generated perly.h using bison 3 for the first time (without noticing the disappearance of the token macros). We could try to fix the regex logic in regen_perly.pl, but given that no one has complained about the missing token macros in 8 years (as far as I know), let's just remove the code. (Yay, accidental scream tests?)
1 parent 7d1bcef commit 6169482

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

perly.act

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

perly.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

perly.tab

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

regen_perly.pl

-15
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@
133133
}
134134

135135
my $endcore_done = 0;
136-
my $gather_tokens = 0;
137-
my $tokens;
138136
while (<$tmph_fh>) {
139137
# bison 2.6 adds header guards, which break things because of where we
140138
# insert #ifdef PERL_CORE, so strip them because they aren't important
@@ -162,19 +160,6 @@
162160
$endcore_done = 1;
163161
}
164162
next if /^#line \d+ ".*"/;
165-
if (!$gather_tokens) {
166-
$gather_tokens = 1 if /^\s* enum \s* yytokentype \s* \{/x;
167-
}
168-
else {
169-
if (/^\# \s* endif/x) { # The #endif just after the end of the token enum
170-
$gather_tokens = 0;
171-
$_ .= "\n/* Tokens. */\n$tokens";
172-
}
173-
else {
174-
my ($tok, $val) = /(\w+) \s* = \s* (\d+)/x;
175-
$tokens .= "#define $tok $val\n" if $tok;
176-
}
177-
}
178163
print $h_fh $_;
179164
}
180165
close $tmph_fh;

0 commit comments

Comments
 (0)