/[suikacvs]/perl/charclass/lib/Char/Class/mkpm.pl
Suika

Contents of /perl/charclass/lib/Char/Class/mkpm.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sat Sep 7 12:55:01 2002 UTC (22 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +21 -8 lines
File MIME type: text/plain
2002-09-07  Wakaba <w@suika.fam.cx>

	* UCS-src.upl (SecondEdition): Checked with JIS X 0221-1:2001
	(IDT ISO/IEC 10646-1:2000) A.3.3.
	* Han-src.upl:
	- (_JP_*): Renamed to "JP_*".
	- (Senjimon, SenjimonJP): New collection.
	- (pod SEE ALSO): Added some Senjimon reference URIs.
	* JISX4051-src.upl, JISX4052-src.upl: New scripts.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24