line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestML1::Compiler::Pegex::AST; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
121
|
use TestML1::Base; |
|
23
|
|
|
|
|
41
|
|
|
23
|
|
|
|
|
111
|
|
4
|
|
|
|
|
|
|
extends 'Pegex::Tree'; |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
736
|
use TestML1::Runtime; |
|
23
|
|
|
|
|
39
|
|
|
23
|
|
|
|
|
22940
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has points => []; |
9
|
|
|
|
|
|
|
has function => sub { TestML1::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
|
20895
|
my ($self, $code) = @_; |
19
|
33
|
|
|
|
|
128
|
$self->function->{statements} = $code; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub got_assignment_statement { |
23
|
94
|
|
|
94
|
0
|
8943
|
my ($self, $match) = @_; |
24
|
94
|
|
|
|
|
347
|
return TestML1::Assignment->new( |
25
|
|
|
|
|
|
|
name => $match->[0], |
26
|
|
|
|
|
|
|
expr => $match->[1], |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub got_code_statement { |
31
|
150
|
|
|
150
|
0
|
19949
|
my ($self, $list) = @_; |
32
|
150
|
|
|
|
|
201
|
my ($expression, $assertion); |
33
|
150
|
|
|
|
|
349
|
my $points = $self->points; |
34
|
150
|
|
|
|
|
212
|
$self->{points} = []; |
35
|
|
|
|
|
|
|
|
36
|
150
|
|
|
|
|
242
|
for (@$list) { |
37
|
285
|
100
|
|
|
|
508
|
if (ref eq 'TestML1::Assertion') { |
38
|
135
|
|
|
|
|
178
|
$assertion = $_; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
|
|
|
|
|
|
#if (ref eq 'TestML1::Expression') { |
42
|
150
|
|
|
|
|
205
|
$expression = $_; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
150
|
50
|
|
|
|
777
|
return TestML1::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
|
65332
|
my ($self, $list) = @_; |
54
|
418
|
|
|
|
|
549
|
my $calls = []; |
55
|
418
|
50
|
|
|
|
924
|
push @$calls, shift @$list if @$list; |
56
|
418
|
|
50
|
|
|
710
|
$list = shift @$list || []; |
57
|
418
|
|
|
|
|
607
|
for (@$list) { |
58
|
117
|
|
|
|
|
136
|
my $call = $_->[0]; #->{call_call}[0][0]; |
59
|
117
|
|
|
|
|
167
|
push @$calls, $call; |
60
|
|
|
|
|
|
|
} |
61
|
418
|
100
|
|
|
|
1094
|
return $calls->[0] if @$calls == 1; |
62
|
88
|
|
|
|
|
250
|
return TestML1::Expression->new( |
63
|
|
|
|
|
|
|
calls => $calls, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub got_string_object { |
68
|
138
|
|
|
138
|
0
|
86469
|
my ($self, $string) = @_; |
69
|
138
|
|
|
|
|
364
|
return TestML1::Str->new( |
70
|
|
|
|
|
|
|
value => $string, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub got_double_quoted_string { |
75
|
13
|
|
|
13
|
0
|
10239
|
my ($self, $string) = @_; |
76
|
13
|
|
|
|
|
26
|
$string =~ s/\\n/\n/g; |
77
|
13
|
|
|
|
|
46
|
return $string; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub got_number_object { |
81
|
56
|
|
|
56
|
0
|
151186
|
my ($self, $number) = @_; |
82
|
56
|
|
|
|
|
372
|
return TestML1::Num->new( |
83
|
|
|
|
|
|
|
value => $number + 0, |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub got_point_object { |
88
|
97
|
|
|
97
|
0
|
33568
|
my ($self, $point) = @_; |
89
|
97
|
50
|
|
|
|
381
|
$point =~ s/^\*// or die; |
90
|
97
|
|
|
|
|
127
|
push @{$self->points}, $point; |
|
97
|
|
|
|
|
220
|
|
91
|
97
|
|
|
|
|
286
|
return TestML1::Point->new( |
92
|
|
|
|
|
|
|
name => $point, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub got_assertion_call { |
97
|
135
|
|
|
135
|
0
|
9631
|
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
|
|
|
|
352
|
$call = $call->[0] if ref $call eq 'ARRAY'; |
101
|
135
|
|
|
|
|
177
|
my ($name, $expr); |
102
|
135
|
|
|
|
|
203
|
for (qw( eq has ok )) { |
103
|
201
|
100
|
|
|
|
441
|
if ($expr = $call->{"assertion_$_"}) { |
104
|
135
|
|
|
|
|
224
|
$name = uc $_; |
105
|
|
|
|
|
|
|
$expr = |
106
|
|
|
|
|
|
|
$expr->{"assertion_operator_$_"}[0] || |
107
|
135
|
|
100
|
|
|
492
|
$expr->{"assertion_function_$_"}[0]; |
108
|
135
|
|
|
|
|
199
|
last; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
135
|
100
|
|
|
|
518
|
return TestML1::Assertion->new( |
112
|
|
|
|
|
|
|
name => $name, |
113
|
|
|
|
|
|
|
$expr ? (expr => $expr) : (), |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub got_assertion_function_ok { |
118
|
29
|
|
|
29
|
0
|
5674
|
my ($self, $ok) = @_; |
119
|
|
|
|
|
|
|
return { |
120
|
29
|
|
|
|
|
83
|
assertion_function_ok => [], |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub got_function_start { |
125
|
20
|
|
|
20
|
0
|
9732
|
my ($self) = @_; |
126
|
20
|
|
|
|
|
95
|
my $function = TestML1::Function->new; |
127
|
20
|
|
|
|
|
51
|
$function->outer($self->function); |
128
|
20
|
|
|
|
|
31
|
$self->{function} = $function; |
129
|
20
|
|
|
|
|
51
|
return 1; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub got_function_object { |
133
|
20
|
|
|
20
|
0
|
12986
|
my ($self, $object) = @_; |
134
|
|
|
|
|
|
|
|
135
|
20
|
|
|
|
|
51
|
my $function = $self->function; |
136
|
20
|
|
|
|
|
52
|
$self->{function} = $function->outer; |
137
|
|
|
|
|
|
|
|
138
|
20
|
100
|
100
|
|
|
97
|
if (ref($object->[0]) and ref($object->[0][0])) { |
139
|
10
|
|
|
|
|
30
|
$function->{signature} = $object->[0][0]; |
140
|
|
|
|
|
|
|
} |
141
|
20
|
|
|
|
|
45
|
$function->{statements} = $object->[-1]; |
142
|
|
|
|
|
|
|
|
143
|
20
|
|
|
|
|
62
|
return $function; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub got_call_name { |
147
|
224
|
|
|
224
|
0
|
111781
|
my ($self, $name) = @_; |
148
|
224
|
|
|
|
|
601
|
return TestML1::Call->new(name => $name); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub got_call_object { |
152
|
224
|
|
|
224
|
0
|
15154
|
my ($self, $object) = @_; |
153
|
224
|
|
|
|
|
378
|
my $call = $object->[0]; |
154
|
224
|
|
|
|
|
309
|
my $args = $object->[1][-1]; |
155
|
224
|
100
|
|
|
|
345
|
if ($args) { |
156
|
|
|
|
|
|
|
$args = [ |
157
|
|
|
|
|
|
|
map { |
158
|
55
|
50
|
33
|
|
|
98
|
($_->isa('TestML1::Expression') and @{$_->calls} == 1 and |
|
68
|
|
|
|
|
483
|
|
159
|
|
|
|
|
|
|
( |
160
|
|
|
|
|
|
|
$_->calls->[0]->isa('TestML1::Point') || |
161
|
|
|
|
|
|
|
$_->calls->[0]->isa('TestML1::Object') |
162
|
|
|
|
|
|
|
)) ? $_->calls->[0] : $_; |
163
|
|
|
|
|
|
|
} @$args |
164
|
|
|
|
|
|
|
]; |
165
|
55
|
|
|
|
|
159
|
$call->args($args) |
166
|
|
|
|
|
|
|
} |
167
|
224
|
|
|
|
|
482
|
return $call; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub got_call_argument_list { |
171
|
55
|
|
|
55
|
0
|
12993
|
my ($self, $list) = @_; |
172
|
55
|
|
|
|
|
113
|
return $list; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub got_call_indicator { |
176
|
117
|
|
|
117
|
0
|
15327
|
my ($self) = @_; |
177
|
117
|
|
|
|
|
209
|
return; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub got_data_section { |
181
|
22
|
|
|
22
|
0
|
2135
|
my ($self, $data) = @_; |
182
|
22
|
|
|
|
|
92
|
$self->function->data($data); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub got_data_block { |
186
|
57
|
|
|
57
|
0
|
9298
|
my ($self, $block) = @_; |
187
|
|
|
|
|
|
|
return TestML1::Block->new( |
188
|
|
|
|
|
|
|
label => $block->[0][0][0], |
189
|
57
|
|
|
|
|
115
|
points => +{map %$_, @{$block->[1]}}, |
|
57
|
|
|
|
|
501
|
|
190
|
|
|
|
|
|
|
); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub got_block_point { |
194
|
140
|
|
|
140
|
0
|
103066
|
my ($self, $point) = @_; |
195
|
140
|
|
|
|
|
253
|
my ($name, $value) = @$point; |
196
|
140
|
100
|
|
|
|
400
|
my $eol = ($value =~ s/(\r?\n)\s*\z//) ? $1 : ''; |
197
|
140
|
100
|
|
|
|
274
|
if (length $value) { |
198
|
139
|
|
|
|
|
184
|
$value .= $eol; |
199
|
|
|
|
|
|
|
} |
200
|
140
|
|
|
|
|
477
|
return { $name => $value }; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |