line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Liberty; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
32266
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Exporter 'import'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
86
|
|
7
|
|
|
|
|
|
|
our $VERSION = 0.12; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
205
|
use liberty; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Parse::Liberty::Constants qw($e $e2 %errors); |
11
|
|
|
|
|
|
|
use Parse::Liberty::Group; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my $class = shift; |
16
|
|
|
|
|
|
|
my %options = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## untilde path |
19
|
|
|
|
|
|
|
require File::Glob; |
20
|
|
|
|
|
|
|
$options{'file'} = File::Glob::bsd_glob($options{'file'}); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
## set debug mode |
23
|
|
|
|
|
|
|
liberty::si2drPISetDebugMode(\$e) if $options{'verbose'}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## initialize |
26
|
|
|
|
|
|
|
liberty::si2drPIInit(\$e); |
27
|
|
|
|
|
|
|
printf STDERR "* PIInit: %s\n", $errors{$e} if $options{'verbose'}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
## read liberty file |
30
|
|
|
|
|
|
|
printf STDERR "* Reading %s...\n", $options{'file'} if $options{'verbose'}; |
31
|
|
|
|
|
|
|
liberty::si2drReadLibertyFile($options{'file'}, \$e); |
32
|
|
|
|
|
|
|
printf STDERR "* ReadLibertyFile: %s\n", $errors{$e} if $options{'verbose'}; |
33
|
|
|
|
|
|
|
die "\n" if $errors{$e} ne 'NO ERROR'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $self = { |
36
|
|
|
|
|
|
|
file => $options{'file'}, |
37
|
|
|
|
|
|
|
indent => $options{'indent'} || 2, |
38
|
|
|
|
|
|
|
verbose => $options{'verbose'} || 0, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
bless $self, $class; |
41
|
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub methods { |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
return (join "\n", qw(library write_library))."\n"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
################################################################################ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub library { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## get root group |
56
|
|
|
|
|
|
|
my $si2_groups = liberty::si2drPIGetGroups(\$e); |
57
|
|
|
|
|
|
|
my $si2_group = liberty::si2drIterNextGroup($si2_groups, \$e); |
58
|
|
|
|
|
|
|
liberty::si2drIterQuit($si2_groups, \$e); |
59
|
|
|
|
|
|
|
my $group = new Parse::Liberty::Group ( |
60
|
|
|
|
|
|
|
parser => $self, |
61
|
|
|
|
|
|
|
parent => $self, |
62
|
|
|
|
|
|
|
si2_object => $si2_group, |
63
|
|
|
|
|
|
|
depth => 0, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return $group; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub write_library { |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
my $file = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $si2_group = $self->library->{si2_object}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
printf "* Writing %s...\n", $file if $self->{verbose}; |
77
|
|
|
|
|
|
|
liberty::si2drWriteLibertyFile($file, $si2_group, \$e); |
78
|
|
|
|
|
|
|
printf "* WriteLibertyFile: %s\n", $errors{$e} if $self->{verbose}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return 1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
__END__ |