line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
31
|
|
|
31
|
|
347
|
use v5; |
|
31
|
|
|
|
|
101
|
|
|
31
|
|
|
|
|
2188
|
|
3
|
|
|
|
|
|
|
binmode(STDOUT, ":utf8"); |
4
|
31
|
|
|
31
|
|
193
|
use Scalar::Util; |
|
31
|
|
|
|
|
59
|
|
|
31
|
|
|
|
|
2906
|
|
5
|
31
|
|
|
31
|
|
96217
|
use Encode; |
|
31
|
|
|
|
|
603919
|
|
|
31
|
|
|
|
|
5162
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$_ = Encode::decode('utf-8', $_) |
8
|
|
|
|
|
|
|
for @ARGV; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
package Perlito::Match; |
12
|
|
|
|
|
|
|
|
13
|
31
|
|
|
31
|
|
299
|
use strict; |
|
31
|
|
|
|
|
65
|
|
|
31
|
|
|
|
|
1048
|
|
14
|
31
|
|
|
31
|
|
220
|
use warnings; |
|
31
|
|
|
|
|
66
|
|
|
31
|
|
|
|
|
886
|
|
15
|
31
|
|
|
31
|
|
154
|
no warnings 'recursion'; |
|
31
|
|
|
|
|
61
|
|
|
31
|
|
|
|
|
4470
|
|
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
|
|
66763
|
); |
|
31
|
|
|
|
|
43143
|
|
|
31
|
|
|
|
|
469
|
|
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
|
286288
|
|
|
286288
|
|
1008574
|
sub bool { $_[0]{bool} } |
34
|
836
|
|
|
836
|
|
5566
|
sub capture { $_[0]{capture} } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub array { |
37
|
0
|
|
|
0
|
|
0
|
my $v = $_[0]; |
38
|
0
|
0
|
|
|
|
0
|
$v->{match} |
39
|
|
|
|
|
|
|
|| ( $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
|
0
|
|
|
|
|
0
|
bless [ map Pair->new( key => $_, value => $_[0]{$_} ), |
54
|
0
|
|
|
0
|
|
0
|
CORE::keys %{$_[0]} |
55
|
|
|
|
|
|
|
], 'ARRAY'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub flat { |
59
|
19079
|
|
|
19079
|
|
25974
|
my $obj = $_[0]; |
60
|
19079
|
|
|
|
|
32777
|
my $cap = $obj->{capture}; |
61
|
|
|
|
|
|
|
#print ref $cap; |
62
|
19079
|
100
|
|
|
|
132698
|
return $cap |
63
|
|
|
|
|
|
|
if defined $cap; |
64
|
3410
|
50
|
|
|
|
8530
|
return '' unless $obj->{bool}; |
65
|
3410
|
50
|
|
|
|
11113
|
return '' if $_[0]->from > length( $obj->{str} ); |
66
|
3410
|
|
|
|
|
11195
|
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
|
|
40591
|
return \( $_[0]->flat ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
package Perlito::Grammar; |
80
|
|
|
|
|
|
|
sub space { |
81
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
82
|
11741
|
|
|
11741
|
0
|
17956
|
my $str = $_[1]; my $pos = $_[2]; |
|
11741
|
|
|
|
|
17911
|
|
83
|
11741
|
|
|
|
|
59659
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match'; |
84
|
11741
|
100
|
|
|
|
81172
|
$MATCH->{bool} = ( |
85
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:space:]])/ |
86
|
|
|
|
|
|
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
87
|
|
|
|
|
|
|
: 0 |
88
|
|
|
|
|
|
|
); |
89
|
11741
|
|
|
|
|
46991
|
$MATCH; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
sub digit { |
92
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
93
|
15105
|
|
|
15105
|
0
|
27378
|
my $str = $_[1]; my $pos = $_[2]; |
|
15105
|
|
|
|
|
19498
|
|
94
|
15105
|
|
|
|
|
65854
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match'; |
95
|
15105
|
100
|
|
|
|
94287
|
$MATCH->{bool} = ( |
96
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:digit:]])/ |
97
|
|
|
|
|
|
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
98
|
|
|
|
|
|
|
: 0 |
99
|
|
|
|
|
|
|
); |
100
|
15105
|
|
|
|
|
56639
|
$MATCH; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub word { |
104
|
|
|
|
|
|
|
# my $grammar = $_[0]; |
105
|
16832
|
|
|
16832
|
0
|
23869
|
my $str = $_[1]; my $pos = $_[2]; |
|
16832
|
|
|
|
|
32226
|
|
106
|
16832
|
|
|
|
|
71672
|
my $MATCH = bless { str => $str, from => $pos, to => $pos }, 'Perlito::Match'; |
107
|
16832
|
100
|
|
|
|
103986
|
$MATCH->{bool} = ( |
108
|
|
|
|
|
|
|
substr($str, $MATCH->{to}) =~ m/^([[:word:]])/ |
109
|
|
|
|
|
|
|
? ( 1 + ($MATCH->{to} = ( length( $1 ) + $MATCH->{to} ))) |
110
|
|
|
|
|
|
|
: 0 |
111
|
|
|
|
|
|
|
); |
112
|
16832
|
|
|
|
|
63198
|
$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
|
33611
|
|
|
33611
|
|
38647
|
bool => sub { scalar(@{$_[0]}) }, |
|
33611
|
|
|
|
|
125798
|
|
131
|
31
|
|
|
|
|
325
|
'""' => \&Str, |
132
|
31
|
|
|
31
|
|
57070
|
); |
|
31
|
|
|
|
|
75
|
|
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
|
0
|
|
|
|
|
0
|
$_[1] |
138
|
0
|
|
|
|
|
0
|
? bless [ CORE::sort( $_[1]($_), @{$_[0]} ) ], 'ARRAY' |
139
|
0
|
0
|
|
0
|
|
0
|
: bless [ CORE::sort( @{$_[0]} ) ], 'ARRAY' |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub Str { |
143
|
5
|
|
|
5
|
|
11
|
join( " ", CORE::map { Main::Str($_) } @{$_[0]} ) |
|
11
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
46
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
package HASH; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
use overload ( |
149
|
423
|
|
|
423
|
|
755
|
bool => sub { scalar(CORE::keys %{$_[0]}) }, |
|
423
|
|
|
|
|
2668
|
|
150
|
31
|
|
|
|
|
257
|
'""' => \&Str, |
151
|
31
|
|
|
31
|
|
15824
|
); |
|
31
|
|
|
|
|
68
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub Str { |
154
|
3
|
|
|
3
|
|
8
|
join( "\n", map { $_ . "\t" . Main::Str($_[0]{$_}) } CORE::keys %{$_[0]} ) |
|
4
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
15
|
|
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
|
0
|
|
|
|
|
0
|
$_[1] |
163
|
0
|
|
|
|
|
0
|
? bless [ CORE::sort( $_[0]($_), @{$_[1]} ) ], 'ARRAY' |
164
|
0
|
0
|
|
0
|
|
0
|
: bless [ CORE::sort( @{$_[0]} ) ], 'ARRAY' |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
0
|
|
0
|
sub True { 1 } |
168
|
|
|
|
|
|
|
sub Str { |
169
|
19
|
|
|
19
|
|
45
|
my $can = UNIVERSAL::can($o => 'Str'); |
170
|
19
|
50
|
|
|
|
45
|
return $can->($o) if $can; |
171
|
19
|
100
|
|
|
|
47
|
if ( ref($_[0]) ) { |
172
|
5
|
50
|
|
|
|
31
|
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
|
|
|
|
|
62
|
return $_[0]; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
sub print { |
178
|
204
|
|
|
204
|
|
284
|
local $_; |
179
|
204
|
|
|
|
|
501
|
for (@_) { |
180
|
504
|
100
|
|
|
|
983
|
if ( ref($_) ) { |
181
|
4
|
|
|
|
|
17
|
CORE::print Main::Str($_); |
182
|
4
|
|
|
|
|
12
|
next; |
183
|
|
|
|
|
|
|
} |
184
|
500
|
|
|
|
|
1949
|
CORE::print $_ |
185
|
|
|
|
|
|
|
} |
186
|
204
|
|
|
|
|
994
|
return 1; |
187
|
|
|
|
|
|
|
} |
188
|
201
|
|
|
201
|
|
2077
|
sub say { Main::print( @_, "\n" ) } |
189
|
40034
|
|
|
40034
|
|
97683
|
sub chars { length( $_[0] ) } |
190
|
|
|
|
|
|
|
sub isa { |
191
|
11626
|
|
|
11626
|
|
27502
|
my $ref = ref($_[0]); |
192
|
11626
|
100
|
33
|
|
|
182914
|
( $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
|
|
3
|
bless [ CORE::keys %{$_[0]} ], 'ARRAY'; |
|
1
|
|
|
|
|
6
|
|
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
sub values { |
211
|
1
|
|
|
1
|
|
8
|
bless [ CORE::values %{$_[0]} ], 'ARRAY'; |
|
1
|
|
|
|
|
8
|
|
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub pairs { |
215
|
2
|
|
|
|
|
31
|
bless [ |
216
|
|
|
|
|
|
|
map Pair->new( key => $_, value => $_[0]{$_} ), |
217
|
2
|
|
|
2
|
|
5
|
CORE::keys %{$_[0]} |
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
|
|
67
|
return 'Mu' unless defined $_[0]; |
228
|
11
|
|
|
|
|
17
|
local $_; |
229
|
11
|
|
|
|
|
172
|
local %Main::_seen = %Main::_seen; |
230
|
11
|
|
|
|
|
22
|
my $o = shift; |
231
|
11
|
100
|
|
|
|
30
|
if ( ref($o) ) { |
232
|
3
|
|
|
|
|
833
|
my $key = "$o"; |
233
|
3
|
50
|
50
|
|
|
29
|
return "'!!! Recursive structure !!!' at $key" if ($Main::_seen{$key} || 0) > 3; |
234
|
3
|
|
|
|
|
10
|
$Main::_seen{$key}++; |
235
|
3
|
50
|
|
|
|
12
|
return '[' . join( ", ", map { perl($_) } @$o ) . ']' |
|
0
|
|
|
|
|
0
|
|
236
|
|
|
|
|
|
|
if ref($o) eq 'ARRAY'; |
237
|
3
|
50
|
|
|
|
21
|
return '{' . join( ", ", map { perl($_) . ' => ' . perl($o->{$_}) } sort {$a cmp $b} CORE::keys(%$o) ) . '}' |
|
4
|
|
|
|
|
13
|
|
|
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
|
|
|
82
|
return $o if $o =~ /^[0-9]/ && (0+$o) eq $o; |
244
|
4
|
|
|
|
|
10
|
$o =~ s/\\/\\\\/g; |
245
|
4
|
|
|
|
|
7
|
$o =~ s/'/\\'/g; |
246
|
4
|
|
|
|
|
32
|
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
|
0
|
|
|
|
|
0
|
return $ref . ".new(" |
253
|
0
|
|
|
|
|
0
|
. join( ", ", map { Main::perl($_) . ' => ' . Main::perl($o->{$_}) } sort {$a cmp $b} CORE::keys(%$o) ) |
|
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
|
|
3664
|
return '' unless defined $_[0]; |
270
|
1660
|
|
|
|
|
3783
|
my $can = UNIVERSAL::can($_[0] => 'join'); |
271
|
1660
|
50
|
|
|
|
2889
|
if ($can) { |
272
|
0
|
|
|
|
|
0
|
$can->(@_); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
else { |
275
|
1660
|
|
|
|
|
1893
|
join($_[1], @{$_[0]} ); |
|
1660
|
|
|
|
|
12660
|
|
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
|
|
|
|
|
|
|
# Lisp emitter |
295
|
|
|
|
|
|
|
sub to_lisp_identifier { |
296
|
0
|
|
|
0
|
|
|
my $s = $_[0]; |
297
|
0
|
|
|
|
|
|
my $sigil; |
298
|
0
|
|
|
|
|
|
( $sigil, $s ) = $s =~ /^([$@%]?)(.*)$/; |
299
|
0
|
|
|
|
|
|
return 'sv-' . $s; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
sub to_lisp_namespace { |
302
|
0
|
|
|
0
|
|
|
my $s = $_[0]; |
303
|
0
|
|
|
|
|
|
my $sigil; |
304
|
0
|
|
|
|
|
|
( $sigil, $s ) = $s =~ /^([$@%]?)(.*)$/; |
305
|
0
|
|
|
|
|
|
$s =~ s/::/-/g; |
306
|
0
|
|
|
|
|
|
return 'mp-' . $s; |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
sub lisp_escape_string { |
309
|
0
|
|
|
0
|
|
|
my $s = $_[0]; |
310
|
0
|
|
|
|
|
|
$s =~ s/\\/\\\\/g; |
311
|
0
|
|
|
|
|
|
$s =~ s/"/\\"/g; |
312
|
0
|
|
|
|
|
|
return $s; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
# Javascript emitter |
315
|
|
|
|
|
|
|
sub to_javascript_namespace { |
316
|
0
|
|
|
0
|
|
|
my $s = $_[0]; |
317
|
0
|
|
|
|
|
|
my $sigil; |
318
|
0
|
|
|
|
|
|
( $sigil, $s ) = $s =~ /^([$@%]?)(.*)$/; |
319
|
0
|
|
|
|
|
|
$s =~ s/::/\$/g; |
320
|
0
|
|
|
|
|
|
return $s; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
# Go emitter |
323
|
|
|
|
|
|
|
sub to_go_namespace { |
324
|
0
|
|
|
0
|
|
|
my $s = $_[0]; |
325
|
0
|
|
|
|
|
|
my $sigil; |
326
|
0
|
|
|
|
|
|
( $sigil, $s ) = $s =~ /^([$@%]?)(.*)$/; |
327
|
0
|
|
|
|
|
|
$s =~ s/::/__/g; |
328
|
0
|
|
|
|
|
|
return $s; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
1; |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
__END__ |