line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Expression::Evaluator::Util; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Math::Expression::Evaluator::Util - Common functions for |
6
|
|
|
|
|
|
|
Math::Expression::Evaluator |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNPOSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Math::Expression::Evaluator::Util qw(is_lvalue); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ... |
13
|
|
|
|
|
|
|
if (is_lvalue($ast)){ |
14
|
|
|
|
|
|
|
# $ast represents an lvalue, at the moment just a variable |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This is package with common functions used in the different modules in |
20
|
|
|
|
|
|
|
the Math::Expression::Evaluator distribution. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item is_lvalue |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
C checks if (a simplified version of) C<$ast> represents |
27
|
|
|
|
|
|
|
something that can be assigned to, i.e. is a variable. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=back |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
16
|
|
|
16
|
|
84
|
use strict; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
682
|
|
34
|
16
|
|
|
16
|
|
85
|
use warnings; |
|
16
|
|
|
|
|
25
|
|
|
16
|
|
|
|
|
1845
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
require Exporter; |
37
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
38
|
|
|
|
|
|
|
our @EXPORT_OK = qw(is_lvalue); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# checks if the given AST represents a lvalue of an _assignment |
41
|
|
|
|
|
|
|
sub is_lvalue { |
42
|
16
|
|
|
16
|
1
|
23
|
my $ast = shift; |
43
|
16
|
100
|
100
|
|
|
89
|
if (ref($ast) && $ast->[0] eq '$'){ |
44
|
|
|
|
|
|
|
# simple variable name |
45
|
13
|
|
|
|
|
57
|
return 1; |
46
|
|
|
|
|
|
|
} else { |
47
|
3
|
|
|
|
|
12
|
return 0; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
# vim: sw=4 ts=4 expandtab |