line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TestML::Compiler::Pegex; |
2
|
|
|
|
|
|
|
|
3
|
23
|
|
|
23
|
|
15391
|
use TestML::Base; |
|
23
|
|
|
|
|
31
|
|
|
23
|
|
|
|
|
95
|
|
4
|
|
|
|
|
|
|
extends 'TestML::Compiler'; |
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
8201
|
use TestML::Compiler::Pegex::Grammar; |
|
23
|
|
|
|
|
33
|
|
|
23
|
|
|
|
|
149
|
|
7
|
23
|
|
|
23
|
|
8727
|
use TestML::Compiler::Pegex::AST; |
|
23
|
|
|
|
|
48
|
|
|
23
|
|
|
|
|
570
|
|
8
|
23
|
|
|
23
|
|
8182
|
use Pegex::Parser; |
|
23
|
|
|
|
|
157042
|
|
|
23
|
|
|
|
|
7011
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has parser => (); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub compile_code { |
13
|
33
|
|
|
33
|
0
|
45
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
33
|
|
|
|
|
176
|
$self->{parser} = Pegex::Parser->new( |
16
|
|
|
|
|
|
|
grammar => TestML::Compiler::Pegex::Grammar->new, |
17
|
|
|
|
|
|
|
receiver => TestML::Compiler::Pegex::AST->new, |
18
|
|
|
|
|
|
|
); |
19
|
33
|
|
|
|
|
1549
|
$self->fixup_grammar; |
20
|
|
|
|
|
|
|
|
21
|
33
|
50
|
|
|
|
180
|
$self->parser->parse($self->code, 'code_section') |
22
|
|
|
|
|
|
|
or die "Parse TestML code section failed"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub compile_data { |
26
|
33
|
|
|
33
|
0
|
44
|
my ($self) = @_; |
27
|
|
|
|
|
|
|
|
28
|
33
|
100
|
|
|
|
178
|
if (length $self->data) { |
29
|
22
|
50
|
|
|
|
60
|
$self->parser->parse($self->data, 'data_section') |
30
|
|
|
|
|
|
|
or die "Parse TestML data section failed"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
33
|
|
|
|
|
553
|
$self->{function} = $self->parser->receiver->function; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# TODO This can be moved to the AST some day. |
37
|
|
|
|
|
|
|
sub fixup_grammar { |
38
|
33
|
|
|
33
|
0
|
44
|
my ($self) = @_; |
39
|
|
|
|
|
|
|
|
40
|
33
|
|
|
|
|
97
|
my $tree = $self->{parser}->grammar->tree; |
41
|
|
|
|
|
|
|
|
42
|
33
|
|
|
|
|
197
|
my $point_lines = $tree->{point_lines}{'.rgx'}; |
43
|
|
|
|
|
|
|
|
44
|
33
|
|
|
|
|
89
|
my $block_marker = $self->directives->{BlockMarker}; |
45
|
33
|
50
|
|
|
|
97
|
if ($block_marker) { |
46
|
33
|
|
|
|
|
85
|
$block_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g; |
47
|
33
|
|
|
|
|
309
|
$tree->{block_marker}{'.rgx'} = qr/\G$block_marker/; |
48
|
33
|
|
|
|
|
198
|
$point_lines =~ s/===/$block_marker/; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
33
|
|
|
|
|
143
|
my $point_marker = $self->directives->{PointMarker}; |
52
|
33
|
50
|
|
|
|
76
|
if ($point_marker) { |
53
|
33
|
|
|
|
|
61
|
$point_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g; |
54
|
33
|
|
|
|
|
206
|
$tree->{point_marker}{'.rgx'} = qr/\G$point_marker/; |
55
|
33
|
|
|
|
|
119
|
$point_lines =~ s/\\-\\-\\-/$point_marker/; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
33
|
|
|
|
|
624
|
$tree->{point_lines}{'.rgx'} = qr/$point_lines/; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |