line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl6::Variables; |
2
|
|
|
|
|
|
|
$VERSION = '0.02_002'; |
3
|
1
|
|
|
1
|
|
8686
|
use Filter::Simple; |
|
1
|
|
|
|
|
67517
|
|
|
1
|
|
|
|
|
10
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
my $ident = qr/ [_a-z] \w* (?: :: [_a-z] \w* )* /ix; |
6
|
|
|
|
|
|
|
my $listlikely = qr/ (?: \.\. | => | , | qw | \@ $ident \b [^[] ) /x; |
7
|
|
|
|
|
|
|
my $alist = qr/ [^]]* $listlikely /x; |
8
|
|
|
|
|
|
|
my $hlist = qr/ [^}]* $listlikely /x; |
9
|
|
|
|
|
|
|
my $clist = qr/ [^>]+ /x; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
FILTER { |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$DB::single=1; |
14
|
|
|
|
|
|
|
my $text = ""; |
15
|
|
|
|
|
|
|
pos = 0; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
while (pos($_)
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# array reference slice |
20
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? \[ (?=$alist) /sxgc and |
21
|
|
|
|
|
|
|
$text .= qq/\@{\$$1}[/ and next; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# array reference |
24
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? \[ (?!$alist) /sxgc and |
25
|
|
|
|
|
|
|
$text .= qq/\$$1\->[/ and next; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# hash reference constant slice |
28
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? << (?=$clist) /sxgc and do { |
29
|
|
|
|
|
|
|
my $varname = $1; |
30
|
|
|
|
|
|
|
m/\G (.*?) >> /sxgc; |
31
|
|
|
|
|
|
|
my $quotedwords = $1; |
32
|
|
|
|
|
|
|
my $requotedwords = "'" . join("', '", split /\s+/, $quotedwords) . "'"; |
33
|
|
|
|
|
|
|
#warn "debug: quotedwords: $quotedwords\n"; |
34
|
|
|
|
|
|
|
#warn "debug: requotedwords: $requotedwords\n"; |
35
|
|
|
|
|
|
|
if($quotedwords =~ /\s/) { |
36
|
|
|
|
|
|
|
# @{$hashref}{foo, bar}; |
37
|
|
|
|
|
|
|
#warn 'hash reference constant slice: ' . '@{$' . $varname . '}{' . $requotedwords . '}'; |
38
|
|
|
|
|
|
|
$text .= '@{$' . $varname . '}{' . $requotedwords . '}'; |
39
|
|
|
|
|
|
|
} else { |
40
|
|
|
|
|
|
|
# $hashref->{foo} |
41
|
|
|
|
|
|
|
#warn 'hash reference constant non-slice: ' . '$' . $varname . '->{q<' . $quotedwords . '>}'; |
42
|
|
|
|
|
|
|
$text .= '$' . $varname . '->{q<' . $quotedwords . '>}'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
goto chain; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# hash reference slice |
48
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? \{ (?=$hlist) /sxgc and |
49
|
|
|
|
|
|
|
$text .= qq/\@{\$$1}{/ and next; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# hash reference with function subscript |
52
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? \{ ($ident) \} /sxgc and |
53
|
|
|
|
|
|
|
$text .= '$' . $1 . '->{' . $2 . '()}' and next; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# hash reference |
56
|
|
|
|
|
|
|
m/\G \$ ($ident) \.? \{ (?!$hlist) /sxgc and |
57
|
|
|
|
|
|
|
$text .= qq/\$$1\->{/ and next; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# array slice |
60
|
|
|
|
|
|
|
m/\G \@ ($ident) \[ (?=$alist) /sxgc and |
61
|
|
|
|
|
|
|
$text .= qq/\@$1\[/ and next; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# array |
64
|
|
|
|
|
|
|
m/\G \@ ($ident) \[ (?!$alist) /sxgc and |
65
|
|
|
|
|
|
|
$text .= qq/\$$1\[/ and next; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# hash constant slice |
68
|
|
|
|
|
|
|
m/\G \% ($ident) << (?=$clist) /sxgc and do { |
69
|
|
|
|
|
|
|
my $varname = $1; |
70
|
|
|
|
|
|
|
m/\G (.*?) >> /sxgc; |
71
|
|
|
|
|
|
|
my $quotedwords = $1; |
72
|
|
|
|
|
|
|
my $requotedwords = "'" . join("', '", split /\s+/, $quotedwords) . "'"; |
73
|
|
|
|
|
|
|
#warn "debug: quotedwords: $quotedwords\n"; |
74
|
|
|
|
|
|
|
#warn "debug: requotedwords: $requotedwords\n"; |
75
|
|
|
|
|
|
|
# $hash{foo} or @hash{foo, bar} |
76
|
|
|
|
|
|
|
$text .= ($quotedwords =~ /\s/ ? '@' : '$') . $varname . '{' . $requotedwords . '}'; |
77
|
|
|
|
|
|
|
goto chain; |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# hash slice |
81
|
|
|
|
|
|
|
m/\G \% ($ident) \{ (?=$hlist) /sxgc and |
82
|
|
|
|
|
|
|
$text .= qq/\@$1\{/ and next; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# hash with function subscript |
85
|
|
|
|
|
|
|
m/\G \% ($ident) \{ ($ident) \} /sxgc and |
86
|
|
|
|
|
|
|
$text .= '$' . $1 . '{' . $2 . '()}' and next; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# hash |
89
|
|
|
|
|
|
|
m/\G \% ($ident) \{ (?!$hlist) /sxgc and |
90
|
|
|
|
|
|
|
$text .= qq/\$$1\{/ and next; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
m/\G ([^\$\@%]+|.) /xgcs and |
93
|
|
|
|
|
|
|
$text .= $1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
next; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
chain: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
if(m/\G << ($ident) >> /sxgc) { |
100
|
|
|
|
|
|
|
$text .= "{'" . $1 . "'}"; |
101
|
|
|
|
|
|
|
goto chain; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
next; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
$_ = $text . substr($_, pos); |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__END__ |