3 # How to generate the logic of the lookup table Perl_keyword() in toke.c
7 use vars qw(@ISA %types);
8 require ExtUtils::Constant::Base;
9 @ISA = 'ExtUtils::Constant::Base';
11 %types = (pos => "KEY_", neg => "-KEY_");
13 # We're allowing scalar references to produce evil customisation.
15 defined $types{$_[1]} or ref $_[1];
19 # This might actually be a return statement
20 sub assignment_clause_for_type {
21 my ($self, $args, $value) = @_;
22 my ($type, $item) = @{$args}{qw(type item)};
24 $comment = " /* Weight $item->{weight} */" if defined $item->{weight};
25 return "return $types{$type}$value;$comment" if $types{$type};
26 "$$type$value;$comment";
29 sub return_statement_for_notfound {
33 # Ditch the default "const"
34 sub C_constant_name_param_definition {
35 "char *" . $_[0]->name_param;
38 sub C_constant_return_type {
43 sub C_constant_prefix_param {
47 sub C_constant_prefix_param_defintion {
51 sub C_constant_namelen_param_definition {
52 'I32 ' . $_[0] -> C_constant_namelen_param;
57 my @pos = qw(__DATA__ __END__ AUTOLOAD BEGIN CHECK DESTROY do delete defined
58 END else eval elsif exists for format foreach grep goto glob INIT
59 if last local m my map next no our pos print printf package
60 prototype q qr qq qw qx redo return require s scalar sort split
61 study sub tr tie tied use undef until untie unless while y);
63 my @neg = qw(__FILE__ __LINE__ __PACKAGE__ and abs alarm atan2 accept bless
64 bind binmode CORE cmp chr cos chop close chdir chomp chmod chown
65 crypt chroot caller connect closedir continue die dump dbmopen
66 dbmclose eq eof err exp exit exec each endgrent endpwent
67 endnetent endhostent endservent endprotoent fork fcntl flock
68 fileno formline getppid getpgrp getpwent getpwnam getpwuid
69 getpeername getprotoent getpriority getprotobyname
70 getprotobynumber gethostbyname gethostbyaddr gethostent
71 getnetbyname getnetbyaddr getnetent getservbyname getservbyport
72 getservent getsockname getsockopt getgrent getgrnam getgrgid
73 getlogin getc gt ge gmtime hex int index ioctl join keys kill lt
74 le lc log link lock lstat length listen lcfirst localtime mkdir
75 msgctl msgget msgrcv msgsnd ne not or ord oct open opendir pop
76 push pack pipe quotemeta ref read rand recv rmdir reset rename
77 rindex reverse readdir readlink readline readpipe rewinddir seek
78 send semop select semctl semget setpgrp seekdir setpwent setgrent
79 setnetent setsockopt sethostent setservent setpriority
80 setprotoent shift shmctl shmget shmread shmwrite shutdown sin
81 sleep socket socketpair sprintf splice sqrt srand stat substr
82 system symlink syscall sysopen sysread sysseek syswrite tell time
83 times telldir truncate uc utime umask unpack unlink unshift
84 ucfirst values vec warn wait write waitpid wantarray x xor);
86 my %frequencies = (map {/(.*):\t(.*)/} <DATA>);
89 push @names, map {{name=>$_, type=>"pos", weight=>$frequencies{$_}}} @pos;
90 push @names, map {{name=>$_, type=>"neg", weight=>$frequencies{$_}}} @neg;
91 push @names, {name=>'elseif', type=>\"", value=><<'EOC'};
92 /* This is somewhat hacky. */
93 if(ckWARN_d(WARN_SYNTAX))
94 Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "elseif should be elsif");
98 print Toke->C_constant ({subname=>'Perl_keyword', breakout=>~0}, @names);
283 getprotobynumber: 232