line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Language::Expr::Interpreter::var_enumer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2016-06-29'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.27'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
27
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
437
|
use Role::Tiny::With; |
|
1
|
|
|
|
|
3754
|
|
|
1
|
|
|
|
|
52
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
358
|
use parent 'Language::Expr::Interpreter::Base'; |
|
1
|
|
|
|
|
244
|
|
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
with 'Language::Expr::InterpreterRole'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _add_var { |
16
|
14
|
|
|
14
|
|
15
|
my ($self, $v) = @_; |
17
|
14
|
100
|
|
|
|
9
|
push @{$self->{_result}}, $v unless grep {$_ eq $v} @{$self->{_result}}; |
|
12
|
|
|
|
|
242
|
|
|
10
|
|
|
|
|
61
|
|
|
14
|
|
|
|
|
29
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
0
|
0
|
|
sub rule_pair_simple { } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
0
|
0
|
|
sub rule_pair_string { } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
0
|
0
|
|
sub rule_or_xor { } |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
0
|
0
|
|
sub rule_ternary { } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
0
|
0
|
|
sub rule_and { } |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
0
|
0
|
|
sub rule_bit_or_xor { } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
0
|
0
|
|
sub rule_bit_and { } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
0
|
0
|
|
sub rule_comparison3 { } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
0
|
0
|
|
sub rule_comparison { } |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
0
|
0
|
|
sub rule_bit_shift { } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
5
|
0
|
|
sub rule_add { } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
2
|
0
|
|
sub rule_mult { } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
0
|
0
|
|
sub rule_unary { } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
0
|
0
|
|
sub rule_power { } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
1
|
0
|
|
sub rule_subscripting_var { } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
1
|
0
|
|
sub rule_subscripting_expr { } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
2
|
0
|
|
sub rule_array { } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
0
|
0
|
|
sub rule_hash { } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
0
|
0
|
|
sub rule_undef { } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
1
|
0
|
|
sub rule_squotestr { } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub rule_dquotestr { |
61
|
1
|
|
|
1
|
0
|
2
|
my ($self, %args) = @_; |
62
|
1
|
|
|
|
|
1
|
my $match = $args{match}; |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
1
|
for (@{ $match->{part} }) { |
|
1
|
|
|
|
|
3
|
|
65
|
|
|
|
|
|
|
# extract 'foo' from '${foo}' |
66
|
3
|
100
|
|
|
|
11
|
if (substr($_, 0, 2) eq '${') { |
|
|
100
|
|
|
|
|
|
67
|
1
|
|
|
|
|
3
|
$self->_add_var(substr($_, 2, length()-3)); |
68
|
|
|
|
|
|
|
# extract 'foo' from '$foo' |
69
|
|
|
|
|
|
|
} elsif (substr($_, 0, 1) eq '$') { |
70
|
1
|
|
|
|
|
3
|
$self->_add_var(substr($_, 1, length()-1)); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
0
|
0
|
|
sub rule_bool { } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
6
|
0
|
|
sub rule_num { } |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub rule_var { |
80
|
12
|
|
|
12
|
0
|
16
|
my ($self, %args) = @_; |
81
|
12
|
|
|
|
|
12
|
my $match = $args{match}; |
82
|
12
|
|
|
|
|
26
|
$self->_add_var($match->{var}); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
1
|
0
|
|
sub rule_func { } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
0
|
0
|
|
sub rule_func_map { |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
0
|
0
|
|
sub rule_func_grep { |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
0
|
0
|
|
sub rule_func_usort { |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
1
|
0
|
|
sub rule_parenthesis {} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub expr_preprocess { |
99
|
9
|
|
|
9
|
0
|
20
|
my ($self, %args) = @_; |
100
|
9
|
|
|
|
|
22
|
$self->{_result} = []; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
9
|
0
|
|
sub expr_postprocess {} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub eval { |
106
|
9
|
|
|
9
|
1
|
3873
|
my ($self, $expr) = @_; |
107
|
9
|
|
|
|
|
23
|
my $res = Language::Expr::Parser::parse_expr($expr, $self); |
108
|
9
|
|
|
|
|
49
|
$self->{_result}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
# ABSTRACT: Enumerate variables mentioned in Language::Expr expression |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=pod |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=encoding UTF-8 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 NAME |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Language::Expr::Interpreter::var_enumer - Enumerate variables mentioned in Language::Expr expression |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 VERSION |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This document describes version 0.27 of Language::Expr::Interpreter::var_enumer (from Perl distribution Language-Expr), released on 2016-06-29. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=for Pod::Coverage ^((rule|expr)_.+)$ |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 BUGS/TODOS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Currently $_ in map/grep variables and $a & $b in usort are counted. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 METHODS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 HOMEPAGE |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Language-Expr>. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SOURCE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Language-Expr>. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 BUGS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Language-Expr> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
151
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
152
|
|
|
|
|
|
|
feature. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This software is copyright (c) 2016 by perlancar@cpan.org. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
163
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |