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