line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
31
|
|
|
31
|
|
218
|
use v5; |
|
31
|
|
|
|
|
64
|
|
3
|
|
|
|
|
|
|
binmode(STDOUT, ":utf8"); |
4
|
31
|
|
|
31
|
|
109
|
use Scalar::Util; |
|
31
|
|
|
|
|
32
|
|
|
31
|
|
|
|
|
1370
|
|
5
|
31
|
|
|
31
|
|
14801
|
use Encode; |
|
31
|
|
|
|
|
225700
|
|
|
31
|
|
|
|
|
2742
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$_ = Encode::decode('utf-8', $_) |
8
|
|
|
|
|
|
|
for @ARGV; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
package Perlito6::Match; |
12
|
|
|
|
|
|
|
|
13
|
31
|
|
|
31
|
|
165
|
use strict; |
|
31
|
|
|
|
|
35
|
|
|
31
|
|
|
|
|
463
|
|
14
|
31
|
|
|
31
|
|
88
|
use warnings; |
|
31
|
|
|
|
|
38
|
|
|
31
|
|
|
|
|
550
|
|
15
|
31
|
|
|
31
|
|
89
|
no warnings 'recursion'; |
|
31
|
|
|
|
|
32
|
|
|
31
|
|
|
|
|
2287
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use overload ( |
18
|
|
|
|
|
|
|
'@{}' => \&array, |
19
|
|
|
|
|
|
|
bool => \&bool, |
20
|
|
|
|
|
|
|
'${}' => \&scalar, |
21
|
|
|
|
|
|
|
'""' => \&flat, |
22
|
|
|
|
|
|
|
'0+' => \&flat, |
23
|
0
|
|
|
0
|
|
0
|
'eq' => sub { "$_[0]" eq "$_[1]" }, |
24
|
31
|
|
|
31
|
|
28538
|
); |
|
31
|
|
|
|
|
23355
|
|
|
31
|
|
|
|
|
277
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
|
|
|
|
|
|
my ($class, %data) = @_; |
28
|
|
|
|
|
|
|
return bless \%data, $class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub from { $_[0]{from} } |
32
|
|
|
|
|
|
|
sub to { $_[0]{to} } |
33
|
291682
|
|
|
291682
|
|
407904
|
sub bool { $_[0]{bool} } |
34
|
836
|
|
|
836
|
|
2639
|
sub capture { $_[0]{capture} } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub array { |
37
|
0
|
|
|
0
|
|
0
|
my $v = $_[0]; |
38
|
|
|
|
|
|
|
$v->{match} |
39
|
0
|
0
|
|
|
|
0
|
|| ( $v->{match} = [] ) |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub hash { |
43
|
0
|
|
|
0
|
|
0
|
$_[0] |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub keys { |
47
|
0
|
|
|
0
|
|
0
|
bless [ CORE::keys %{$_[0]} ], 'ARRAY'; |
|
0
|
|
|
|
|
0
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
sub values { |
50
|
0
|
|
|
0
|
|
0
|
bless [ CORE::values %{$_[0]} ], 'ARRAY'; |
|
0
|
|
|
|
|
0
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
sub pairs { |
53
|
|
|
|
|
|
|
bless [ map Pair->new( key => $_, value => $_[0]{$_} ), |
54
|
0
|
|
|
0
|
|
0
|
CORE::keys %{$_[0]} |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
], 'ARRAY'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub flat { |
59
|
19079
|
|
|
19079
|
|
13116
|
my $obj = $_[0]; |
60
|
19079
|
|
|
|
|
15471
|
my $cap = $obj->{capture}; |
61
|
|
|
|
|
|
|
#print ref $cap; |
62
|
19079
|
100
|
|
|
|
50852
|
return $cap |
63
|
|
|
|
|
|
|
if defined $cap; |
64
|
3410
|
50
|
|
|
|
4628
|
return '' unless $obj->{bool}; |
65
|
3410
|
50
|
|
|
|
5276
|
return '' if $_[0]->from > length( $obj->{str} ); |
66
|
3410
|
|
|
|
|
5393
|
return substr( $obj->{str}, $_[0]->from, $_[0]->to - $_[0]->from ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub str { |
70
|
|
|
|
|
|
|
"" . $_[0]->flat; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub scalar { |
74
|
15608
|
|
|
15608
|
|
18945
|
return \( $_[0]->flat ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
package Perlito6::Grammar; |
80
|
|
|
|
|
|
|
sub space { |
81
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
82
|
11741
|
|
|
11741
|
0
|
9203
|
my $str = $_[1]; my $pos = $_[2]; |
|
11741
|
|
|
|
|
7500
|
|
83
|
11741
|
|
|
|
|
18676
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match'; |
84
|
|
|
|
|
|
|
$MATCH->{bool} = ( |
85
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:space:]])/ |
86
|
11741
|
100
|
|
|
|
42479
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
87
|
|
|
|
|
|
|
: 0 |
88
|
|
|
|
|
|
|
); |
89
|
11741
|
|
|
|
|
16797
|
$MATCH; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
sub digit { |
92
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
93
|
15105
|
|
|
15105
|
0
|
11362
|
my $str = $_[1]; my $pos = $_[2]; |
|
15105
|
|
|
|
|
9539
|
|
94
|
15105
|
|
|
|
|
23904
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match'; |
95
|
|
|
|
|
|
|
$MATCH->{bool} = ( |
96
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:digit:]])/ |
97
|
15105
|
100
|
|
|
|
43419
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
98
|
|
|
|
|
|
|
: 0 |
99
|
|
|
|
|
|
|
); |
100
|
15105
|
|
|
|
|
21518
|
$MATCH; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub word { |
104
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
105
|
16853
|
|
|
16853
|
0
|
12648
|
my $str = $_[1]; my $pos = $_[2]; |
|
16853
|
|
|
|
|
10481
|
|
106
|
16853
|
|
|
|
|
25894
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito6::Match'; |
107
|
|
|
|
|
|
|
$MATCH->{bool} = ( |
108
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:word:]])/ |
109
|
16853
|
100
|
|
|
|
49526
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
110
|
|
|
|
|
|
|
: 0 |
111
|
|
|
|
|
|
|
); |
112
|
16853
|
|
|
|
|
22901
|
$MATCH; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
package IO; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub slurp { |
118
|
0
|
|
|
0
|
0
|
0
|
my $source_filename = shift; |
119
|
0
|
0
|
|
|
|
0
|
open FILE, $source_filename |
120
|
|
|
|
|
|
|
or die "Cannot read $source_filename\n"; |
121
|
0
|
|
|
|
|
0
|
local $/ = undef; |
122
|
0
|
|
|
|
|
0
|
$source = ; |
123
|
0
|
|
|
|
|
0
|
close FILE; |
124
|
0
|
|
|
|
|
0
|
return Encode::decode( 'utf-8', $source ); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package ARRAY; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
use overload ( |
130
|
33665
|
|
|
33665
|
|
20295
|
bool => sub { scalar(@{$_[0]}) }, |
|
33665
|
|
|
|
|
54486
|
|
131
|
31
|
|
|
|
|
2688
|
'""' => \&Str, |
132
|
31
|
|
|
31
|
|
22087
|
); |
|
31
|
|
|
|
|
40
|
|
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
|
0
|
sub map { bless [ CORE::map( $_[1]($_), @{$_[0]} ) ], 'ARRAY' } |
|
0
|
|
|
|
|
0
|
|
135
|
0
|
|
|
0
|
|
0
|
sub grep { bless [ CORE::grep( $_[1]($_), @{$_[0]} ) ], 'ARRAY' } |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
sub sort { |
137
|
|
|
|
|
|
|
$_[1] |
138
|
0
|
|
|
|
|
0
|
? bless [ CORE::sort( $_[1]($_), @{$_[0]} ) ], 'ARRAY' |
139
|
0
|
0
|
|
0
|
|
0
|
: bless [ CORE::sort( @{$_[0]} ) ], 'ARRAY' |
|
0
|
|
|
|
|
0
|
|
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub Str { |
143
|
5
|
|
|
5
|
|
6
|
join( " ", CORE::map { Main::Str($_) } @{$_[0]} ) |
|
11
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
27
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
package HASH; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
use overload ( |
149
|
423
|
|
|
423
|
|
378
|
bool => sub { scalar(CORE::keys %{$_[0]}) }, |
|
423
|
|
|
|
|
991
|
|
150
|
31
|
|
|
|
|
2151
|
'""' => \&Str, |
151
|
31
|
|
|
31
|
|
9859
|
); |
|
31
|
|
|
|
|
41
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub Str { |
154
|
3
|
|
|
3
|
|
3
|
join( "\n", map { $_ . "\t" . Main::Str($_[0]{$_}) } CORE::keys %{$_[0]} ) |
|
4
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
7
|
|
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
package Main; |
158
|
|
|
|
|
|
|
|
159
|
0
|
|
|
0
|
|
0
|
sub map { bless [ CORE::map( $_[0]($_), @{$_[1]} ) ], 'ARRAY' } |
|
0
|
|
|
|
|
0
|
|
160
|
0
|
|
|
0
|
|
0
|
sub grep { bless [ CORE::grep( $_[0]($_), @{$_[1]} ) ], 'ARRAY' } |
|
0
|
|
|
|
|
0
|
|
161
|
|
|
|
|
|
|
sub sort { |
162
|
|
|
|
|
|
|
$_[1] |
163
|
0
|
|
|
|
|
0
|
? bless [ CORE::sort( $_[0]($_), @{$_[1]} ) ], 'ARRAY' |
164
|
0
|
0
|
|
0
|
|
0
|
: bless [ CORE::sort( @{$_[0]} ) ], 'ARRAY' |
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
0
|
|
0
|
sub True { 1 } |
168
|
|
|
|
|
|
|
sub Str { |
169
|
19
|
|
|
19
|
|
26
|
my $can = UNIVERSAL::can($o => 'Str'); |
170
|
19
|
50
|
|
|
|
27
|
return $can->($o) if $can; |
171
|
19
|
100
|
|
|
|
30
|
if ( ref($_[0]) ) { |
172
|
5
|
50
|
|
|
|
23
|
return ARRAY::Str($_[0]) if ref($_[0]) eq 'ARRAY'; |
173
|
0
|
0
|
|
|
|
0
|
return HASH::Str($_[0]) if ref($_[0]) eq 'HASH'; |
174
|
|
|
|
|
|
|
} |
175
|
14
|
|
|
|
|
33
|
return $_[0]; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
sub print { |
178
|
204
|
|
|
204
|
|
160
|
local $_; |
179
|
204
|
|
|
|
|
252
|
for (@_) { |
180
|
504
|
100
|
|
|
|
861
|
if ( ref($_) ) { |
181
|
4
|
|
|
|
|
11
|
CORE::print Main::Str($_); |
182
|
4
|
|
|
|
|
8
|
next; |
183
|
|
|
|
|
|
|
} |
184
|
500
|
|
|
|
|
776
|
CORE::print $_ |
185
|
|
|
|
|
|
|
} |
186
|
204
|
|
|
|
|
283
|
return 1; |
187
|
|
|
|
|
|
|
} |
188
|
201
|
|
|
201
|
|
1353
|
sub say { Main::print( @_, "\n" ) } |
189
|
40034
|
|
|
40034
|
|
44390
|
sub chars { length( $_[0] ) } |
190
|
|
|
|
|
|
|
sub isa { |
191
|
11328
|
|
|
11328
|
|
9730
|
my $ref = ref($_[0]); |
192
|
11328
|
100
|
33
|
|
|
88125
|
( $ref eq 'ARRAY' |
|
|
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
100
|
|
|
|
|
193
|
|
|
|
|
|
|
&& $_[1] eq 'Array' |
194
|
|
|
|
|
|
|
) |
195
|
|
|
|
|
|
|
|| ( $ref eq 'HASH' |
196
|
|
|
|
|
|
|
&& $_[1] eq 'Hash' |
197
|
|
|
|
|
|
|
) |
198
|
|
|
|
|
|
|
|| ( $ref eq '' |
199
|
|
|
|
|
|
|
&& $_[1] eq 'Str' |
200
|
|
|
|
|
|
|
) |
201
|
|
|
|
|
|
|
|| $ref eq $_[1] |
202
|
|
|
|
|
|
|
|| ( ref( $_[1] ) |
203
|
|
|
|
|
|
|
&& $ref eq ref( $_[1] ) |
204
|
|
|
|
|
|
|
) |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub keys { |
208
|
1
|
|
|
1
|
|
1
|
bless [ CORE::keys %{$_[0]} ], 'ARRAY'; |
|
1
|
|
|
|
|
5
|
|
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
sub values { |
211
|
1
|
|
|
1
|
|
5
|
bless [ CORE::values %{$_[0]} ], 'ARRAY'; |
|
1
|
|
|
|
|
6
|
|
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub pairs { |
215
|
|
|
|
|
|
|
bless [ |
216
|
|
|
|
|
|
|
map Pair->new( key => $_, value => $_[0]{$_} ), |
217
|
2
|
|
|
2
|
|
2
|
CORE::keys %{$_[0]} |
|
2
|
|
|
|
|
12
|
|
218
|
|
|
|
|
|
|
], 'ARRAY'; |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub id { |
222
|
0
|
0
|
|
0
|
|
0
|
Scalar::Util::refaddr($_[0]) |
223
|
|
|
|
|
|
|
|| "_id_" . $_[0] |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub perl { |
227
|
11
|
50
|
|
11
|
|
34
|
return 'Mu' unless defined $_[0]; |
228
|
11
|
|
|
|
|
10
|
local $_; |
229
|
11
|
|
|
|
|
14
|
local %Main::_seen = %Main::_seen; |
230
|
11
|
|
|
|
|
11
|
my $o = shift; |
231
|
11
|
100
|
|
|
|
13
|
if ( ref($o) ) { |
232
|
3
|
|
|
|
|
5
|
my $key = "$o"; |
233
|
3
|
50
|
50
|
|
|
15
|
return "'!!! Recursive structure !!!' at $key" if ($Main::_seen{$key} || 0) > 3; |
234
|
3
|
|
|
|
|
5
|
$Main::_seen{$key}++; |
235
|
3
|
50
|
|
|
|
5
|
return '[' . join( ", ", map { perl($_) } @$o ) . ']' |
|
0
|
|
|
|
|
0
|
|
236
|
|
|
|
|
|
|
if ref($o) eq 'ARRAY'; |
237
|
3
|
50
|
|
|
|
12
|
return '{' . join( ", ", map { perl($_) . ' => ' . perl($o->{$_}) } sort {$a cmp $b} CORE::keys(%$o) ) . '}' |
|
4
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
5
|
|
238
|
|
|
|
|
|
|
if ref($o) eq 'HASH'; |
239
|
0
|
0
|
|
|
|
0
|
return 'sub { ... }' |
240
|
|
|
|
|
|
|
if ref($o) eq 'CODE'; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
else { |
243
|
8
|
100
|
66
|
|
|
44
|
return $o if $o =~ /^[0-9]/ && (0+$o) eq $o; |
244
|
4
|
|
|
|
|
9
|
$o =~ s/\\/\\\\/g; |
245
|
4
|
|
|
|
|
4
|
$o =~ s/'/\\'/g; |
246
|
4
|
|
|
|
|
11
|
return "'" . $o . "'"; |
247
|
|
|
|
|
|
|
} |
248
|
0
|
|
|
|
|
0
|
my $can = UNIVERSAL::can($o => 'perl'); |
249
|
0
|
0
|
|
|
|
0
|
return $can->($o) if $can; |
250
|
0
|
|
|
|
|
0
|
my $ref = ref($o); |
251
|
0
|
0
|
|
|
|
0
|
return perl($$o) if $ref eq 'SCALAR'; |
252
|
|
|
|
|
|
|
return $ref . ".new(" |
253
|
0
|
|
|
|
|
0
|
. join( ", ", map { Main::perl($_) . ' => ' . Main::perl($o->{$_}) } sort {$a cmp $b} CORE::keys(%$o) ) |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
254
|
|
|
|
|
|
|
. ")"; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub yaml { |
258
|
0
|
|
|
0
|
|
0
|
my $can = UNIVERSAL::can($_[0] => 'yaml'); |
259
|
0
|
0
|
|
|
|
0
|
if ($can) { |
260
|
0
|
|
|
|
|
0
|
$can->($_[0]); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
else { |
263
|
0
|
|
|
|
|
0
|
require YAML::Syck; |
264
|
0
|
|
|
|
|
0
|
YAML::Syck::Dump($_[0]); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub join { |
269
|
1660
|
50
|
|
1660
|
|
2144
|
return '' unless defined $_[0]; |
270
|
1660
|
|
|
|
|
2327
|
my $can = UNIVERSAL::can($_[0] => 'join'); |
271
|
1660
|
50
|
|
|
|
1615
|
if ($can) { |
272
|
0
|
|
|
|
|
0
|
$can->(@_); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
else { |
275
|
1660
|
|
|
|
|
1081
|
join($_[1], @{$_[0]} ); |
|
1660
|
|
|
|
|
6421
|
|
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub split { |
280
|
0
|
0
|
|
0
|
|
|
return '' unless defined $_[0]; |
281
|
0
|
|
|
|
|
|
my $can = UNIVERSAL::can($_[0] => 'split'); |
282
|
0
|
0
|
|
|
|
|
if ($can) { |
283
|
0
|
|
|
|
|
|
$can->(@_); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
else { |
286
|
0
|
|
|
|
|
|
[ split($_[1], $_[0], -1) ]; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub bool { |
291
|
0
|
0
|
|
0
|
|
|
$_[0] ? 1 : 0 |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
1; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
__END__ |