3 # Regenerate (overwriting only if changed):
5 # keywords.h keywords.c
7 # from information stored in the DATA section of this file.
9 # Accepts the standard regen_lib -q and -v args.
12 use Devel::Tokenizer::C 0.05;
14 require './regen/regen_lib.pl';
16 my $h = open_new('keywords.h', '>',
17 { by => 'regen/keywords.pl', from => 'its data',
18 file => 'keywords.h', style => '*',
19 copyright => [1994 .. 1997, 1999 .. 2002, 2005 .. 2007]});
20 my $c = open_new('keywords.c', '>',
21 { by => 'regen/keywords.pl', from => 'its data', style => '*'});
30 my ($strength, $keyword) = /^([- +])([A-Z_a-z2]+)/;
31 die "Bad line '$_'" unless defined $strength;
32 print $h tab(5, "#define KEY_$keyword"), $keynum++, "\n";
33 push @{$by_strength{$strength}}, $keyword;
36 # If this hash changes, make sure the equivalent hash in
37 # lib/B/Deparse.pm (%feature_keywords) is also updated.
44 # continue is already a keyword
46 evalbytes => 'evalbytes',
51 my %pos = map { ($_ => 1) } @{$by_strength{'+'}};
53 my $t = Devel::Tokenizer::C->new(TokenFunc => \&perl_keyword,
54 TokenString => 'name',
55 StringLength => 'len',
59 $t->add_tokens(@{$by_strength{'+'}}, @{$by_strength{'-'}}, 'elseif');
61 my $switch = $t->generate(Indent => ' ');
65 #define PERL_IN_KEYWORDS_C
71 Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
73 PERL_ARGS_ASSERT_KEYWORD;
84 my $sign = $pos{$k} ? '' : '-';
88 Perl_ck_warner_d(aTHX_ packWARN(WARN_SYNTAX), "elseif should be elsif");
91 elsif (my $feature = $feature_kw{$k}) {
92 $feature =~ s/([\\"])/\\$1/g;
94 return (all_keywords || FEATURE_\U$feature\E_IS_ENABLED ? ${sign}KEY_$k : 0);
102 read_only_bottom_close_and_rename($_, [$0]) foreach $c, $h;
105 # coresub_op in op.c expects __FILE__, __LINE__ and __PACKAGE__ to be the