TestML1/Compiler/Pegex.pm

filter: Statementstmt 100% 37 / 37 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 87.7% 50 / 57 CC 6 SCAR 7.8
CC
6
Cov
91%
compile_data
3.0
fixup_grammar
3.0
compile_code
2.0
CRAP 2.2
« TestML1/Base.pm ↑ Summary TestML1/Library/Debug.pm »
1 package TestML1::Compiler::Pegex;
2  
3 22 ▶use TestML1::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 extends 'TestML1::Compiler';
5  
6 22 ▶use TestML1::Compiler::Pegex::Grammar;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use TestML1::Compiler::Pegex::AST;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 22 ▶use Pegex::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 22 has parser => ();
11  
12 21 ▶sub compile_code {
Subroutine compile_code: called CC=2 SCAR=7.0
Pod undocumented
13 21 my ($self) = @_;
14  
15 21 $self->{parser} = Pegex::Parser->new(
16 grammar => TestML1::Compiler::Pegex::Grammar->new,
17 receiver => TestML1::Compiler::Pegex::AST->new,
18 );
19 21 $self->fixup_grammar;
20  
21 21 ▶ $self->parser->parse($self->code, 'code_section')
Branch: 1 branch
BranchTrueFalseTotal
$self->parser->parse($self->code, "code_section") or die "Parse TestML1 code section failed" 21 0 21
22 or die "Parse TestML1 code section failed";
23 }
24  
25 21 ▶sub compile_data {
Subroutine compile_data: called CC=3 SCAR=11.0
Pod undocumented
26 21 my ($self) = @_;
27  
28 21 ▶ if (length $self->data) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $self->data) 14 7 21
29 14 ▶ $self->parser->parse($self->data, 'data_section')
Branch: 1 branch
BranchTrueFalseTotal
$self->parser->parse($self->data, "data_section") or die "Parse TestML1 data section failed" 14 0 14
30 or die "Parse TestML1 data section failed";
31 }
32  
33 21 $self->{function} = $self->parser->receiver->function;
34 }
35  
36 # TODO This can be moved to the AST some day.
37 21 ▶sub fixup_grammar {
Subroutine fixup_grammar: called CC=3 SCAR=11.0
Pod undocumented
38 21 my ($self) = @_;
39  
40 21 my $tree = $self->{parser}->grammar->tree;
41  
42 21 my $point_lines = $tree->{point_lines}{'.rgx'};
43  
44 21 my $block_marker = $self->directives->{BlockMarker};
45 21 ▶ if ($block_marker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($block_marker) 21 0 21
46 21 $block_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g;
47 21 $tree->{block_marker}{'.rgx'} = qr/\G$block_marker/;
48 21 $point_lines =~ s/===/$block_marker/;
49 }
50  
51 21 my $point_marker = $self->directives->{PointMarker};
52 21 ▶ if ($point_marker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($point_marker) 21 0 21
53 21 $point_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g;
54 21 $tree->{point_marker}{'.rgx'} = qr/\G$point_marker/;
55 21 $point_lines =~ s/\\-\\-\\-/$point_marker/;
56 }
57  
58 21 $tree->{point_lines}{'.rgx'} = qr/$point_lines/;
59 }
60  
61 22 1;
« TestML1/Base.pm ↑ Summary TestML1/Library/Debug.pm »