Builder/Tokenizer.pm

filter: Statementstmt 84.6% 22 / 26 Branchbran 81.2% 13 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 3 totaltotal 77.5% 38 / 49 CC 10 SCAR 19.3
CC
10
Cov
83%
_next
9.2
new
2.0
info
2.0
CRAP 6.9
↑ Summary Builder/Class.pm »
1 package Lang::Tree::Builder::Tokenizer;
2  
3 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
4 1 my ($class, $file) = @_;
5 1 my $fh = new FileHandle($file);
6 1 ▶ return undef unless $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 1 1
7 1 bless {
8 file => $file,
9 lineno => 0,
10 error => '',
11 line => '',
12 fh => $fh,
13 }, $class;
14 }
15  
16 11 ▶sub next {
Subroutine next: called CC=1 SCAR=0.0
Pod undocumented
17 11 my ($self) = @_;
18 11 my $token = $self->_next();
19 11 $self->{last_token} = $token;
20 11 return $token;
21 }
22  
23 11 ▶sub _next {
Subroutine _next: called CC=9 SCAR=22.2
24 11 my ($self) = @_;
25  
26 11 ▶ return undef unless defined $self->{line};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"line"} 0 11 11
27  
28 11 ▶ while ($self->{line} =~ /^\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"line"} =~ /^\s*$/) 3 10 13
29 3 $self->{line} = $self->{fh}->getline();
30 3 $self->{lineno}++;
31 3 ▶ return undef unless defined $self->{line};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"line"} 1 2 3
32 2 $self->{line} =~ s/^\s+//;
33 2 $self->{line} =~ s/#.*//;
34 }
35  
36 10 for ($self->{line}) {
37 10 ▶ s/^\(\s*// && return '(';
Branch: 1 branch
BranchTrueFalseTotal
s/^\(\s*// and return "(" 1 9 10
38 9 ▶ s/^\)\s*// && return ')';
Branch: 1 branch
BranchTrueFalseTotal
s/^\)\s*// and return ")" 1 8 9
39 8 ▶ s/^\,\s*// && return ',';
Branch: 1 branch
BranchTrueFalseTotal
s/^\,\s*// and return "," 2 6 8
40 6 ▶ s/([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\s*//
Branch: 1 branch
BranchTrueFalseTotal
s/([A-Za-z_][A-Za-z_0-9]*(?:::[A-Za-z_][A-Za-z_0-9]*)*)\s*// and return $1 6 0 6
41 && return $1;
42 }
43  
44 0 $self->{error} = "can't parse: '$self->{line}'"
45 . " in $self->{file}"
46 . " at line $self->{lineno}";
47 0 return undef;
48 }
49  
50 0 ▶sub info {
Subroutine info: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my ($self) = @_;
52 0 return "file: $self->{file}"
53 . " line: $self->{lineno}"
54 . " $self->{lasttoken} <> $self->{line}";
55 }
56  
57 3 1;
↑ Summary Builder/Class.pm »