1 |
wakaba |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
use strict; |
3 |
|
|
use Message::Util::QName::Filter { |
4 |
|
|
ManakaiDOM => q<http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#>, |
5 |
|
|
}; |
6 |
|
|
|
7 |
|
|
use Getopt::Long; |
8 |
|
|
use Pod::Usage; |
9 |
|
|
use Storable qw/nstore retrieve/; |
10 |
|
|
my %Opt; |
11 |
|
|
GetOptions ( |
12 |
|
|
'for=s' => \$Opt{For}, |
13 |
|
|
'help' => \$Opt{help}, |
14 |
|
|
'input-cdis-file-name=s' => \$Opt{input_file_name}, |
15 |
|
|
'output-file-name=s' => \$Opt{output_file_name}, |
16 |
wakaba |
1.2 |
'search-path|I=s' => ($Opt{module_file_search_path} = []), |
17 |
wakaba |
1.1 |
'undef-check!' => \$Opt{no_undef_check}, |
18 |
|
|
'verbose!' => $Opt{verbose}, |
19 |
|
|
) or pod2usage (2); |
20 |
|
|
pod2usage ({-exitval => 0, -verbose => 1}) if $Opt{help}; |
21 |
|
|
$Opt{file_name} = shift; |
22 |
|
|
pod2usage ({-exitval => 2, -verbose => 0}) unless $Opt{file_name}; |
23 |
|
|
pod2usage ({-exitval => 2, -verbose => 0}) unless $Opt{output_file_name}; |
24 |
|
|
$Opt{no_undef_check} = defined $Opt{no_undef_check} |
25 |
|
|
? $Opt{no_undef_check} ? 0 : 1 : 0; |
26 |
wakaba |
1.2 |
push @{$Opt{module_file_search_path}}, '.'; |
27 |
wakaba |
1.1 |
|
28 |
|
|
BEGIN { |
29 |
|
|
require 'manakai/genlib.pl'; |
30 |
|
|
require 'manakai/dis.pl'; |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
eval q{ |
34 |
|
|
sub impl_msg ($;%) { |
35 |
|
|
warn shift () . "\n"; |
36 |
|
|
} |
37 |
|
|
} unless $Opt{verbose}; |
38 |
|
|
|
39 |
|
|
our $State; |
40 |
|
|
if (defined $Opt{input_file_name}) { |
41 |
|
|
$State = retrieve ($Opt{input_file_name}) |
42 |
|
|
or die "$0: $Opt{input_file_name}: Cannot load"; |
43 |
|
|
} |
44 |
|
|
$State->{DefaultFor} = $Opt{For} if defined $Opt{For}; |
45 |
wakaba |
1.3 |
$State->{Namespace} = {}; |
46 |
|
|
$State->{ETBinding} = {}; |
47 |
|
|
undef $State->{module}; |
48 |
wakaba |
1.2 |
my $source = dis_load_module_file |
49 |
|
|
(module_file_name => $Opt{file_name}, |
50 |
|
|
For => $Opt{For}, |
51 |
|
|
use_default_for => 1, |
52 |
|
|
module_file_search_path => $Opt{module_file_search_path}); |
53 |
|
|
$State->{def_required}->{For}->{$State->{DefaultFor}} ||= 1; |
54 |
wakaba |
1.1 |
dis_check_undef_type_and_for () unless $Opt{no_undef_check}; |
55 |
|
|
if (dis_uri_for_match (ExpandedURI q<ManakaiDOM:Perl>, $State->{DefaultFor})) { |
56 |
|
|
dis_perl_init ($source, For => $State->{DefaultFor}); |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
nstore $State, $Opt{output_file_name}; |
60 |
|
|
|
61 |
|
|
__END__ |
62 |
|
|
|
63 |
|
|
=head1 NAME |
64 |
|
|
|
65 |
|
|
disc - dis compiler |
66 |
|
|
|
67 |
|
|
=head1 SYNOPSIS |
68 |
|
|
|
69 |
|
|
perl disc.pl Source.dis --output-file-name=s.tmp [options...] |
70 |
|
|
perl disc.pl --help |
71 |
|
|
|
72 |
|
|
=head1 DESCRIPTION |
73 |
|
|
|
74 |
|
|
C<disc> is a disc compiler that read "dis" files (a dis file specified |
75 |
|
|
as a command-line argument and other dis files, if any, referred from that file), |
76 |
|
|
convert it to the internal object and write it down to a file. |
77 |
|
|
The compiled file can be used as an input for dis to some format converter |
78 |
|
|
such as L<dis2pm> or L<dis2rdf>. |
79 |
|
|
|
80 |
|
|
Note: Compiled dis files depend on the version of dis utilities. |
81 |
|
|
|
82 |
|
|
=head2 OPTIONS |
83 |
|
|
|
84 |
|
|
=over 4 |
85 |
|
|
|
86 |
|
|
=item I<Source.dis> |
87 |
|
|
|
88 |
|
|
A dis file that is first parsed. |
89 |
|
|
|
90 |
|
|
=item --help |
91 |
|
|
|
92 |
|
|
Show the help message. |
93 |
|
|
|
94 |
|
|
=item --for=I<ForURI> |
95 |
|
|
|
96 |
|
|
A "For" URI referenece that is first set. This is optional; |
97 |
|
|
if missing, the C<Module/DefaultFor> attribute of I<Source.dis> |
98 |
|
|
is used. |
99 |
|
|
|
100 |
|
|
=item --input-cdis-file-name=I<s.orig> |
101 |
|
|
|
102 |
|
|
A compiled dis file that is loaded before the parse of I<Source.dis> |
103 |
|
|
as base of new compiled dis. In other word, I<Source.dis> (and |
104 |
|
|
other included files) are merged to I<s.orig> data. |
105 |
|
|
|
106 |
|
|
=item --output-file-name=I<s.tmp> |
107 |
|
|
|
108 |
|
|
A file name the result compiled dis is written to. |
109 |
|
|
|
110 |
|
|
=back |
111 |
|
|
|
112 |
|
|
=head1 LICENSE |
113 |
|
|
|
114 |
|
|
Copyright 2004 Wakaba <w@suika.fam.cx>. All rights reserved. |
115 |
|
|
|
116 |
|
|
This program is free software; you can redistribute it and/or |
117 |
|
|
modify it under the same terms as Perl itself. |
118 |
|
|
|
119 |
|
|
=cut |
120 |
|
|
|