| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::sh2p::Operators; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3444
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
38
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use App::sh2p::Utils; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
992
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub App::sh2p::Parser::convert(\@\@); |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
|
10
|
|
|
|
|
|
|
my $g_specials = '\[|\*|\?'; |
|
11
|
|
|
|
|
|
|
my %g_perl_ops; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
@g_perl_ops{qw( eq ne lt gt le ge )} = undef; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
###################################################### |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub no_change { |
|
18
|
0
|
|
|
0
|
0
|
|
my ($op, @rest) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
out $op; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
return 1; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
###################################################### |
|
26
|
|
|
|
|
|
|
# Altered for changed tokenising 0.04 |
|
27
|
|
|
|
|
|
|
sub shortcut { |
|
28
|
0
|
|
|
0
|
0
|
|
my ($input, @rest) = @_; |
|
29
|
0
|
|
|
|
|
|
my $ntok = @_; |
|
30
|
0
|
|
|
|
|
|
my $op; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# operators are followed by whitespace |
|
33
|
0
|
0
|
|
|
|
|
if ($input =~ s/(.+?)\s+//) { |
|
34
|
0
|
|
|
|
|
|
$op = $1; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
else { |
|
37
|
0
|
|
|
|
|
|
$op = $input; |
|
38
|
0
|
|
|
|
|
|
$input = ''; # Avoid recursion |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
out "$op "; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
return $ntok if !@rest; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my @types; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if (@rest >= 3) { |
|
48
|
|
|
|
|
|
|
# string op string |
|
49
|
0
|
|
|
|
|
|
@types = App::sh2p::Parser::identify (1, @rest); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#print_types_tokens (\@types,\@rest); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Token may already have been converted |
|
54
|
0
|
0
|
0
|
|
|
|
if ($types[1][0] eq 'UNKNOWN' && exists $g_perl_ops{$rest[1]}) { |
|
|
|
0
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$types[1] = [('OPERATOR', \&App::sh2p::Operators::boolean)]; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ($types[1][0] ne 'OPERATOR') { |
|
58
|
0
|
|
|
|
|
|
@types = App::sh2p::Parser::identify (0, @rest); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
else { |
|
62
|
0
|
|
|
|
|
|
@types = App::sh2p::Parser::identify (0, @rest); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
App::sh2p::Parser::convert (@rest, @types); |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return $ntok; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
###################################################### |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub boolean { |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
0
|
|
my ($op, @rest) = @_; |
|
75
|
0
|
|
|
|
|
|
my $ntok = 1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#print STDERR "boolean: <$op> <@rest>\n"; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
if (substr($op,0,1) eq '-' && length($op) eq 2) { |
|
|
|
0
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
out "$op ("; |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
if (@rest) { |
|
83
|
0
|
|
|
|
|
|
$ntok = @_; |
|
84
|
0
|
|
|
|
|
|
App::sh2p::Handlers::interpolation ("@rest"); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
out ")"; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
elsif ($op) { # $op might be an empty string (ignore) |
|
89
|
0
|
|
|
|
|
|
out " $op "; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return $ntok; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
###################################################### |
|
96
|
|
|
|
|
|
|
# Used for patterns like +([0-9]) -> [0-9]+ |
|
97
|
|
|
|
|
|
|
sub swap1stchar { |
|
98
|
0
|
|
|
0
|
0
|
|
my ($op) = @_; |
|
99
|
0
|
|
|
|
|
|
my $ntok = 1; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Remove parentheses & swap quanifier |
|
102
|
0
|
|
|
|
|
|
$op =~ s/(.)(\(.+\))/$2$1/; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$op = App::sh2p::Compound::glob2pat($op); |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
out " /$op/ "; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
return $ntok; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
###################################################### |
|
112
|
|
|
|
|
|
|
# Used for patterns like @(one|two) -> (one|two) |
|
113
|
|
|
|
|
|
|
sub chop1stchar { |
|
114
|
0
|
|
|
0
|
0
|
|
my ($op) = @_; |
|
115
|
0
|
|
|
|
|
|
my $ntok = 1; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Remove first char |
|
118
|
0
|
|
|
|
|
|
$op =~ s/^.//; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
$op = App::sh2p::Compound::glob2pat($op); |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
out " /$op/ "; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $ntok; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
###################################################### |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Module end |
|
130
|
|
|
|
|
|
|
1; |