line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PYX::Optimization; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
118597
|
use strict; |
|
6
|
|
|
|
|
43
|
|
|
6
|
|
|
|
|
172
|
|
4
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
162
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1899
|
use Class::Utils qw(set_params); |
|
6
|
|
|
|
|
47501
|
|
|
6
|
|
|
|
|
156
|
|
7
|
6
|
|
|
6
|
|
3729
|
use Encode; |
|
6
|
|
|
|
|
67174
|
|
|
6
|
|
|
|
|
454
|
|
8
|
6
|
|
|
6
|
|
44
|
use Error::Pure qw(err); |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
244
|
|
9
|
6
|
|
|
6
|
|
2582
|
use PYX qw(char comment); |
|
6
|
|
|
|
|
47929
|
|
|
6
|
|
|
|
|
122
|
|
10
|
6
|
|
|
6
|
|
3252
|
use PYX::Parser; |
|
6
|
|
|
|
|
8341
|
|
|
6
|
|
|
|
|
189
|
|
11
|
6
|
|
|
6
|
|
39
|
use PYX::Utils; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
4300
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.05; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
16
|
|
|
|
|
|
|
sub new { |
17
|
6
|
|
|
6
|
1
|
4957
|
my ($class, @params) = @_; |
18
|
6
|
|
|
|
|
21
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Output encoding. |
21
|
6
|
|
|
|
|
34
|
$self->{'output_encoding'} = 'utf-8'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Output handler. |
24
|
6
|
|
|
|
|
22
|
$self->{'output_handler'} = \*STDOUT; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Process params. |
27
|
6
|
|
|
|
|
29
|
set_params($self, @params); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# PYX::Parser object. |
30
|
|
|
|
|
|
|
$self->{'pyx_parser'} = PYX::Parser->new( |
31
|
|
|
|
|
|
|
'output_encoding' => $self->{'output_encoding'}, |
32
|
|
|
|
|
|
|
'output_handler' => $self->{'output_handler'}, |
33
|
|
|
|
|
|
|
'output_rewrite' => 1, |
34
|
|
|
|
|
|
|
'callbacks' => { |
35
|
|
|
|
|
|
|
'data' => \&_data, |
36
|
|
|
|
|
|
|
'comment' => \&_comment, |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
'non_parser_options' => { |
39
|
4
|
|
|
|
|
124
|
'output_encoding' => $self->{'output_encoding'}, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Object. |
44
|
4
|
|
|
|
|
371
|
return $self; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Parse pyx text or array of pyx text. |
48
|
|
|
|
|
|
|
sub parse { |
49
|
6
|
|
|
6
|
1
|
8984
|
my ($self, $pyx, $out) = @_; |
50
|
|
|
|
|
|
|
|
51
|
6
|
|
|
|
|
28
|
$self->{'pyx_parser'}->parse($pyx, $out); |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
609
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Parse file with pyx text. |
57
|
|
|
|
|
|
|
sub parse_file { |
58
|
6
|
|
|
6
|
1
|
9200
|
my ($self, $file, $out) = @_; |
59
|
|
|
|
|
|
|
|
60
|
6
|
|
|
|
|
36
|
$self->{'pyx_parser'}->parse_file($file, $out); |
61
|
|
|
|
|
|
|
|
62
|
6
|
|
|
|
|
1067
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Parse from handler. |
66
|
|
|
|
|
|
|
sub parse_handler { |
67
|
6
|
|
|
6
|
1
|
9953
|
my ($self, $input_file_handler, $out) = @_; |
68
|
|
|
|
|
|
|
|
69
|
6
|
|
|
|
|
36
|
$self->{'pyx_parser'}->parse_handler($input_file_handler, $out); |
70
|
|
|
|
|
|
|
|
71
|
6
|
|
|
|
|
932
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Process data. |
75
|
|
|
|
|
|
|
sub _data { |
76
|
63
|
|
|
63
|
|
5034
|
my ($pyx_parser_obj, $data) = @_; |
77
|
|
|
|
|
|
|
|
78
|
63
|
|
|
|
|
169
|
my $tmp = PYX::Utils::encode($data); |
79
|
63
|
100
|
|
|
|
640
|
if ($tmp =~ /^[\s\n]*$/) { |
80
|
6
|
|
|
|
|
16
|
return; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# TODO Preserve? |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# White space on begin of data. |
86
|
57
|
|
|
|
|
208
|
$tmp =~ s/^[\s\n]*//s; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# White space on end of data. |
89
|
57
|
|
|
|
|
265
|
$tmp =~ s/[\s\n]*$//s; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# White space on middle of data. |
92
|
57
|
|
|
|
|
162
|
$tmp =~ s/[\s\n]+/\ /sg; |
93
|
|
|
|
|
|
|
|
94
|
57
|
|
|
|
|
131
|
$data = PYX::Utils::decode($tmp); |
95
|
57
|
|
|
|
|
336
|
my $out = $pyx_parser_obj->{'output_handler'}; |
96
|
|
|
|
|
|
|
my $encoded_output = Encode::encode( |
97
|
57
|
|
|
|
|
147
|
$pyx_parser_obj->{'non_parser_options'}->{'output_encoding'}, |
98
|
|
|
|
|
|
|
char($data), |
99
|
|
|
|
|
|
|
); |
100
|
57
|
|
|
|
|
2720
|
print {$out} $encoded_output, "\n"; |
|
57
|
|
|
|
|
1068
|
|
101
|
|
|
|
|
|
|
|
102
|
57
|
|
|
|
|
269
|
return; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Process comment. |
106
|
|
|
|
|
|
|
sub _comment { |
107
|
24
|
|
|
24
|
|
2296
|
my ($pyx_parser_obj, $comment) = @_; |
108
|
|
|
|
|
|
|
|
109
|
24
|
|
|
|
|
116
|
my $tmp = PYX::Utils::encode($comment); |
110
|
24
|
100
|
|
|
|
270
|
if ($tmp =~ /^[\s\n]*$/) { |
111
|
3
|
|
|
|
|
11
|
return; |
112
|
|
|
|
|
|
|
} |
113
|
21
|
|
|
|
|
77
|
$tmp =~ s/^[\s\n]*//s; |
114
|
21
|
|
|
|
|
95
|
$tmp =~ s/[\s\n]*$//s; |
115
|
21
|
|
|
|
|
54
|
$comment = PYX::Utils::decode($tmp); |
116
|
21
|
|
|
|
|
124
|
my $out = $pyx_parser_obj->{'output_handler'}; |
117
|
|
|
|
|
|
|
my $encoded_output = Encode::encode( |
118
|
21
|
|
|
|
|
71
|
$pyx_parser_obj->{'non_parser_options'}->{'output_encoding'}, |
119
|
|
|
|
|
|
|
comment($comment), |
120
|
|
|
|
|
|
|
); |
121
|
21
|
|
|
|
|
1228
|
print {$out} $encoded_output, "\n"; |
|
21
|
|
|
|
|
519
|
|
122
|
|
|
|
|
|
|
|
123
|
21
|
|
|
|
|
107
|
return; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |