line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestML::Compiler::Pegex::AST; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
96
|
use TestML::Base; |
|
23
|
|
|
|
|
29
|
|
|
23
|
|
|
|
|
114
|
|
4
|
|
|
|
|
|
|
extends 'Pegex::Tree'; |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
1366
|
use TestML::Runtime; |
|
23
|
|
|
|
|
30
|
|
|
23
|
|
|
|
|
21184
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has points => []; |
9
|
|
|
|
|
|
|
has function => sub { TestML::Function->new }; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# sub final { |
12
|
|
|
|
|
|
|
# my ($self, $match, $top) = @_; |
13
|
|
|
|
|
|
|
# XXX $match; |
14
|
|
|
|
|
|
|
# } |
15
|
|
|
|
|
|
|
# __END__ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub got_code_section { |
18
|
33
|
|
|
33
|
0
|
14600
|
my ($self, $code) = @_; |
19
|
33
|
|
|
|
|
108
|
$self->function->{statements} = $code; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub got_assignment_statement { |
23
|
94
|
|
|
94
|
0
|
6543
|
my ($self, $match) = @_; |
24
|
94
|
|
|
|
|
363
|
return TestML::Assignment->new( |
25
|
|
|
|
|
|
|
name => $match->[0], |
26
|
|
|
|
|
|
|
expr => $match->[1], |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub got_code_statement { |
31
|
150
|
|
|
150
|
0
|
13893
|
my ($self, $list) = @_; |
32
|
150
|
|
|
|
|
137
|
my ($expression, $assertion); |
33
|
150
|
|
|
|
|
313
|
my $points = $self->points; |
34
|
150
|
|
|
|
|
230
|
$self->{points} = []; |
35
|
|
|
|
|
|
|
|
36
|
150
|
|
|
|
|
216
|
for (@$list) { |
37
|
285
|
100
|
|
|
|
419
|
if (ref eq 'TestML::Assertion') { |
38
|
135
|
|
|
|
|
167
|
$assertion = $_; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
|
|
|
|
|
|
#if (ref eq 'TestML::Expression') { |
42
|
150
|
|
|
|
|
169
|
$expression = $_; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
150
|
50
|
|
|
|
806
|
return TestML::Statement->new( |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$expression ? ( expr => $expression ) : (), |
47
|
|
|
|
|
|
|
$assertion ? ( assert => $assertion ) : (), |
48
|
|
|
|
|
|
|
@$points ? ( points => $points ) : (), |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub got_code_expression { |
53
|
418
|
|
|
418
|
0
|
48765
|
my ($self, $list) = @_; |
54
|
418
|
|
|
|
|
397
|
my $calls = []; |
55
|
418
|
50
|
|
|
|
881
|
push @$calls, shift @$list if @$list; |
56
|
418
|
|
50
|
|
|
670
|
$list = shift @$list || []; |
57
|
418
|
|
|
|
|
580
|
for (@$list) { |
58
|
117
|
|
|
|
|
108
|
my $call = $_->[0]; #->{call_call}[0][0]; |
59
|
117
|
|
|
|
|
157
|
push @$calls, $call; |
60
|
|
|
|
|
|
|
} |
61
|
418
|
100
|
|
|
|
1183
|
return $calls->[0] if @$calls == 1; |
62
|
88
|
|
|
|
|
259
|
return TestML::Expression->new( |
63
|
|
|
|
|
|
|
calls => $calls, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub got_string_object { |
68
|
138
|
|
|
138
|
0
|
59078
|
my ($self, $string) = @_; |
69
|
138
|
|
|
|
|
360
|
return TestML::Str->new( |
70
|
|
|
|
|
|
|
value => $string, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub got_double_quoted_string { |
75
|
13
|
|
|
13
|
0
|
7703
|
my ($self, $string) = @_; |
76
|
13
|
|
|
|
|
26
|
$string =~ s/\\n/\n/g; |
77
|
13
|
|
|
|
|
35
|
return $string; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub got_number_object { |
81
|
56
|
|
|
56
|
0
|
118608
|
my ($self, $number) = @_; |
82
|
56
|
|
|
|
|
336
|
return TestML::Num->new( |
83
|
|
|
|
|
|
|
value => $number + 0, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub got_point_object { |
88
|
97
|
|
|
97
|
0
|
24486
|
my ($self, $point) = @_; |
89
|
97
|
50
|
|
|
|
375
|
$point =~ s/^\*// or die; |
90
|
97
|
|
|
|
|
106
|
push @{$self->points}, $point; |
|
97
|
|
|
|
|
239
|
|
91
|
97
|
|
|
|
|
285
|
return TestML::Point->new( |
92
|
|
|
|
|
|
|
name => $point, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub got_assertion_call { |
97
|
135
|
|
|
135
|
0
|
7644
|
my ($self, $call) = @_; |
98
|
|
|
|
|
|
|
# XXX $call strangley becomes an array when $PERL_PEGEX_DEBUG is on. |
99
|
|
|
|
|
|
|
# Workaround for now, until I figure it out. |
100
|
135
|
50
|
|
|
|
298
|
$call = $call->[0] if ref $call eq 'ARRAY'; |
101
|
135
|
|
|
|
|
105
|
my ($name, $expr); |
102
|
135
|
|
|
|
|
182
|
for (qw( eq has ok )) { |
103
|
201
|
100
|
|
|
|
430
|
if ($expr = $call->{"assertion_$_"}) { |
104
|
135
|
|
|
|
|
195
|
$name = uc $_; |
105
|
|
|
|
|
|
|
$expr = |
106
|
|
|
|
|
|
|
$expr->{"assertion_operator_$_"}[0] || |
107
|
135
|
|
66
|
|
|
442
|
$expr->{"assertion_function_$_"}[0]; |
108
|
135
|
|
|
|
|
136
|
last; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
135
|
100
|
|
|
|
536
|
return TestML::Assertion->new( |
112
|
|
|
|
|
|
|
name => $name, |
113
|
|
|
|
|
|
|
$expr ? (expr => $expr) : (), |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub got_assertion_function_ok { |
118
|
29
|
|
|
29
|
0
|
3907
|
my ($self, $ok) = @_; |
119
|
|
|
|
|
|
|
return { |
120
|
29
|
|
|
|
|
90
|
assertion_function_ok => [], |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub got_function_start { |
125
|
20
|
|
|
20
|
0
|
6797
|
my ($self) = @_; |
126
|
20
|
|
|
|
|
68
|
my $function = TestML::Function->new; |
127
|
20
|
|
|
|
|
50
|
$function->outer($self->function); |
128
|
20
|
|
|
|
|
27
|
$self->{function} = $function; |
129
|
20
|
|
|
|
|
45
|
return 1; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub got_function_object { |
133
|
20
|
|
|
20
|
0
|
8880
|
my ($self, $object) = @_; |
134
|
|
|
|
|
|
|
|
135
|
20
|
|
|
|
|
53
|
my $function = $self->function; |
136
|
20
|
|
|
|
|
67
|
$self->{function} = $function->outer; |
137
|
|
|
|
|
|
|
|
138
|
20
|
100
|
100
|
|
|
90
|
if (ref($object->[0]) and ref($object->[0][0])) { |
139
|
10
|
|
|
|
|
22
|
$function->{signature} = $object->[0][0]; |
140
|
|
|
|
|
|
|
} |
141
|
20
|
|
|
|
|
34
|
$function->{statements} = $object->[-1]; |
142
|
|
|
|
|
|
|
|
143
|
20
|
|
|
|
|
52
|
return $function; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub got_call_name { |
147
|
224
|
|
|
224
|
0
|
75862
|
my ($self, $name) = @_; |
148
|
224
|
|
|
|
|
581
|
return TestML::Call->new(name => $name); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub got_call_object { |
152
|
224
|
|
|
224
|
0
|
10839
|
my ($self, $object) = @_; |
153
|
224
|
|
|
|
|
236
|
my $call = $object->[0]; |
154
|
224
|
|
|
|
|
231
|
my $args = $object->[1][-1]; |
155
|
224
|
100
|
|
|
|
352
|
if ($args) { |
156
|
|
|
|
|
|
|
$args = [ |
157
|
|
|
|
|
|
|
map { |
158
|
55
|
50
|
33
|
|
|
66
|
($_->isa('TestML::Expression') and @{$_->calls} == 1 and |
|
68
|
|
|
|
|
469
|
|
159
|
|
|
|
|
|
|
( |
160
|
|
|
|
|
|
|
$_->calls->[0]->isa('TestML::Point') || |
161
|
|
|
|
|
|
|
$_->calls->[0]->isa('TestML::Object') |
162
|
|
|
|
|
|
|
)) ? $_->calls->[0] : $_; |
163
|
|
|
|
|
|
|
} @$args |
164
|
|
|
|
|
|
|
]; |
165
|
55
|
|
|
|
|
155
|
$call->args($args) |
166
|
|
|
|
|
|
|
} |
167
|
224
|
|
|
|
|
479
|
return $call; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub got_call_argument_list { |
171
|
55
|
|
|
55
|
0
|
9536
|
my ($self, $list) = @_; |
172
|
55
|
|
|
|
|
120
|
return $list; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub got_call_indicator { |
176
|
117
|
|
|
117
|
0
|
10888
|
my ($self) = @_; |
177
|
117
|
|
|
|
|
204
|
return; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub got_data_section { |
181
|
22
|
|
|
22
|
0
|
1521
|
my ($self, $data) = @_; |
182
|
22
|
|
|
|
|
68
|
$self->function->data($data); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub got_data_block { |
186
|
57
|
|
|
57
|
0
|
6788
|
my ($self, $block) = @_; |
187
|
|
|
|
|
|
|
return TestML::Block->new( |
188
|
|
|
|
|
|
|
label => $block->[0][0][0], |
189
|
57
|
|
|
|
|
95
|
points => +{map %$_, @{$block->[1]}}, |
|
57
|
|
|
|
|
492
|
|
190
|
|
|
|
|
|
|
); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub got_block_point { |
194
|
140
|
|
|
140
|
0
|
74721
|
my ($self, $point) = @_; |
195
|
140
|
|
|
|
|
184
|
my ($name, $value) = @$point; |
196
|
140
|
100
|
|
|
|
394
|
my $eol = ($value =~ s/(\r?\n)\s*\z//) ? $1 : ''; |
197
|
140
|
100
|
|
|
|
254
|
if (length $value) { |
198
|
139
|
|
|
|
|
152
|
$value .= $eol; |
199
|
|
|
|
|
|
|
} |
200
|
140
|
|
|
|
|
481
|
return { $name => $value }; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |