1 |
wakaba |
1.1 |
use strict;
|
2 |
|
|
use vars qw(%PROP %SET %SET_ALIAS $VERSION);
|
3 |
wakaba |
1.9 |
$VERSION=do{my @r=(q$Revision: 1.8 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
4 |
wakaba |
1.1 |
|
5 |
wakaba |
1.8 |
$PROP{perl_namespace_name} = 'Char::Class::';
|
6 |
wakaba |
1.1 |
$PROP{module_name} = 'FooScript';
|
7 |
|
|
|
8 |
|
|
sub header () {
|
9 |
|
|
<<"EOH";
|
10 |
wakaba |
1.7 |
## This file is auto-generated (at @{[ sprintf '%04d-%02d-%02dT%02d:%02d:%02dZ', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3,2,1,0] ]}).
|
11 |
|
|
## Do not edit by hand!
|
12 |
wakaba |
1.1 |
use strict;
|
13 |
|
|
|
14 |
wakaba |
1.8 |
package $PROP{perl_namespace_name}$PROP{module_name};
|
15 |
|
|
our \$VERSION = '$PROP{version}';
|
16 |
|
|
@{[
|
17 |
wakaba |
1.9 |
#package main;
|
18 |
wakaba |
1.8 |
]}
|
19 |
wakaba |
1.9 |
use Exporter;
|
20 |
|
|
use vars qw(\@EXPORT_OK \@ISA \$VERSION);
|
21 |
|
|
\@ISA = qw(Exporter);
|
22 |
wakaba |
1.4 |
|
23 |
|
|
=head1 NAME
|
24 |
|
|
|
25 |
wakaba |
1.8 |
$PROP{module_name}.pm --- @{[ $PROP{script_name} || $PROP{module_name} ]} character set classes for C<\\p{In@{[ exists $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name} ]}HogeHoge}> regexps
|
26 |
wakaba |
1.6 |
@{[$PROP{pod_description}? "
|
27 |
|
|
=head1 DESCRIPTION
|
28 |
|
|
|
29 |
|
|
$PROP{pod_description}":'']}
|
30 |
wakaba |
1.4 |
|
31 |
|
|
=cut
|
32 |
|
|
|
33 |
wakaba |
1.9 |
sub import (\$;\@) {
|
34 |
|
|
my (\$self, \@sub) = (shift, \@_);
|
35 |
|
|
for (\@sub) {
|
36 |
|
|
no strict 'refs';
|
37 |
|
|
*{'main::'.\$_} = \\&{\$_};
|
38 |
|
|
}
|
39 |
|
|
\$self->SUPER::import (\@_);
|
40 |
|
|
}
|
41 |
|
|
|
42 |
wakaba |
1.1 |
EOH
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
sub table () {
|
46 |
wakaba |
1.3 |
my $prefix = exists $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name};
|
47 |
wakaba |
1.1 |
my $r = '';
|
48 |
|
|
my @set;
|
49 |
wakaba |
1.6 |
my %set_description;
|
50 |
wakaba |
1.1 |
for (sort keys %SET) {
|
51 |
wakaba |
1.2 |
my (@aline,@aitem);
|
52 |
wakaba |
1.1 |
$SET{$_} =~ s{^#\+(\w+)$}{
|
53 |
wakaba |
1.3 |
push @aline, qq(\&In${prefix}$1.); ''
|
54 |
wakaba |
1.1 |
}mge;
|
55 |
wakaba |
1.8 |
$SET{$_} =~ s{^!(.+)$}{ ## Pre-formatted
|
56 |
wakaba |
1.2 |
push @aitem, $1; ''
|
57 |
|
|
}mge;
|
58 |
wakaba |
1.6 |
$SET{$_} =~ s{^#DESCRIPTION\x20(.+)$}{
|
59 |
wakaba |
1.8 |
$set_description{qq(In${prefix}$_)} = $1; ''
|
60 |
wakaba |
1.6 |
}me;
|
61 |
wakaba |
1.1 |
$SET{$_} =~ s{^#.+$}{}mg;
|
62 |
|
|
$SET{$_} =~ tr/\x09\x0A\x0D\x20//d;
|
63 |
wakaba |
1.3 |
push @set, [qq(In${prefix}$_) =>
|
64 |
|
|
join "\n", qq(sub In${prefix}$_ {),
|
65 |
wakaba |
1.2 |
@aline,
|
66 |
|
|
(length $SET{$_}?
|
67 |
|
|
(q(<<EOH;),
|
68 |
|
|
@aitem,
|
69 |
|
|
(map {sprintf '%04X', $_} sort {$a <=> $b}
|
70 |
|
|
map {ord $_} split //, $SET{$_}),
|
71 |
|
|
q(EOH)):
|
72 |
|
|
@aitem > 0? (q(<<EOH;), @aitem, q(EOH)): "''"),
|
73 |
|
|
q(})
|
74 |
wakaba |
1.1 |
];
|
75 |
|
|
}
|
76 |
|
|
for (sort keys %SET_ALIAS) {
|
77 |
wakaba |
1.3 |
push @set, [qq(In${prefix}$_) => qq(\*In${prefix}$_ = \\&In${prefix}$SET_ALIAS{$_};)];
|
78 |
wakaba |
1.1 |
}
|
79 |
|
|
|
80 |
wakaba |
1.9 |
$r = qq(\@EXPORT_OK = qw(@{[map {$_->[0]} @set]});\n\n);
|
81 |
wakaba |
1.1 |
$r .= join '', map {$_->[1]."\n\n"} @set;
|
82 |
wakaba |
1.4 |
|
83 |
|
|
$r .= "=head1 COLLECTION NAMES\n\n=over 4\n\n";
|
84 |
wakaba |
1.6 |
for (sort {$a->[0] cmp $b->[0]} @set) {
|
85 |
wakaba |
1.4 |
$r .= sprintf "=item %s\n\n", $_->[0];
|
86 |
wakaba |
1.6 |
$r .= sprintf "%s\n\n", $set_description{ $_->[0] }
|
87 |
|
|
if $set_description{ $_->[0] };
|
88 |
wakaba |
1.4 |
}
|
89 |
|
|
$r .= "=cut\n\n";
|
90 |
|
|
|
91 |
wakaba |
1.1 |
$r;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
sub footer () {
|
95 |
|
|
my $r = <<EOH;
|
96 |
wakaba |
1.6 |
@{[$PROP{pod_example}? "
|
97 |
wakaba |
1.4 |
=head1 EXAMPLE
|
98 |
wakaba |
1.1 |
|
99 |
wakaba |
1.8 |
$PROP{pod_example}":"
|
100 |
|
|
=head1 EXAMPLE
|
101 |
|
|
|
102 |
|
|
use $PROP{perl_namespace_name}$PROP{module_name};
|
103 |
|
|
if (\$s =~ /\\p{In$PROP{module_name}HogeHoge}/) {
|
104 |
|
|
print \"Match!\\n\";
|
105 |
|
|
}
|
106 |
|
|
"]}@{[$PROP{pod_see_also}? "
|
107 |
wakaba |
1.4 |
=head1 SEE ALSO
|
108 |
wakaba |
1.2 |
|
109 |
wakaba |
1.4 |
$PROP{pod_see_also}":'']}@{[$PROP{pod_license}? "
|
110 |
|
|
=head1 LICENSE
|
111 |
wakaba |
1.1 |
|
112 |
wakaba |
1.6 |
$PROP{pod_license}":"
|
113 |
|
|
=head1 LICENSE
|
114 |
wakaba |
1.1 |
|
115 |
wakaba |
1.2 |
Copyright @{[(gmtime)[5]+1900]} $PROP{author_name} <$PROP{author_mail}>
|
116 |
wakaba |
1.1 |
|
117 |
|
|
This library and the library generated by it is free software;
|
118 |
|
|
you can redistribute them and/or modify them under the same
|
119 |
|
|
terms as Perl itself.
|
120 |
wakaba |
1.4 |
"]}
|
121 |
wakaba |
1.1 |
=cut
|
122 |
|
|
|
123 |
|
|
1;
|
124 |
|
|
### $PROP{module_name}.pm ends here
|
125 |
|
|
EOH
|
126 |
|
|
$r;
|
127 |
|
|
}
|
128 |
|
|
|
129 |
wakaba |
1.3 |
sub col2list ($) {
|
130 |
|
|
my $s = shift;
|
131 |
|
|
my @s;
|
132 |
wakaba |
1.6 |
my @c;
|
133 |
|
|
$s =~ s{^(#.+)}{
|
134 |
|
|
push @c, $1; '';
|
135 |
|
|
}gem;
|
136 |
wakaba |
1.3 |
$s =~ s{^[\x20\x09]*([0-9A-F][0-9A-F])((?:[\x20\x09]+[0-9A-F][0-9A-F](?:-[0-9A-F][0-9A-F])?)+)}{
|
137 |
|
|
my ($r, @c) = ($1, grep {length} split /\s+/, $2);
|
138 |
|
|
for (@c) {
|
139 |
|
|
if (/([0-9A-F][0-9A-F])-([0-9A-F][0-9A-F])/) {
|
140 |
|
|
push @s, sprintf '%s%s %s%s ', $r,$1, $r,$2;
|
141 |
|
|
} else {
|
142 |
|
|
push @s, sprintf '%s%s', $r,$_;
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
}gem;
|
146 |
wakaba |
1.6 |
join ("\n", @c, map {'!'.$_} @s)."\n";
|
147 |
wakaba |
1.3 |
}
|
148 |
|
|
|
149 |
wakaba |
1.1 |
sub print_module () {
|
150 |
|
|
no warnings;
|
151 |
|
|
print &header.&table.&footer;
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
=head1 NAME
|
155 |
|
|
|
156 |
wakaba |
1.8 |
mkpm.pl --- Char::Class::* modules generating library
|
157 |
wakaba |
1.1 |
|
158 |
|
|
=head1 LICENSE
|
159 |
|
|
|
160 |
wakaba |
1.8 |
Copyright 2002-2003 Wakaba <w@suika.fam.cx>
|
161 |
wakaba |
1.1 |
|
162 |
|
|
This library and the library generated by it is free software;
|
163 |
|
|
you can redistribute them and/or modify them under the same
|
164 |
|
|
terms as Perl itself.
|
165 |
|
|
|
166 |
|
|
=cut
|
167 |
|
|
|
168 |
wakaba |
1.9 |
1; ## $Date: 2003/04/24 22:34:02 $
|
169 |
wakaba |
1.1 |
### mkpm.pl ends here
|