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