Data/ZPath/_Lexer.pm

filter: Statementstmt 91.0% 194 / 213 Branchbran 84.9% 90 / 106 Conditioncond 87.3% 69 / 79 MC/DCmcdc 78.0% 32 / 41 Subroutinesub 93.7% 15 / 16 Podpod 0.0% 0 / 5 totaltotal 86.9% 400 / 460 CC 80 SCAR 38.3
CC
80
Cov
89%
_tokenize
65.5
_unescape_char
20.0
_read_name
8.4
CRAP 46.0
« Data/ZPath/_Evaluate.pm ↑ Summary Data/ZPath/_Parser.pm »
1 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Data::ZPath::_Lexer;
5  
6 9 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 our $VERSION = '0.001000';
9  
10 437 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
11 437 my ( $class, $src ) = @_;
12 437 my $self = bless {
13 src => $src,
14 i => 0,
15 toks => [],
16 pos => 0,
17 }, $class;
18  
19 437 $self->{toks} = $self->_tokenize($src);
20 432 return $self;
21 }
22  
23 17342 ▶sub peek_kind { $_[0]->{toks}->[$_[0]->{pos}]->{k} }
Subroutine peek_kind: called CC=1 SCAR=0.0
Pod undocumented
24 751 ▶sub peek_kind_n { $_[0]->{toks}->[$_[0]->{pos} + $_[1]]->{k} }
Subroutine peek_kind_n: called CC=1 SCAR=0.0
Pod undocumented
25  
26 2510 ▶sub next_tok {
Subroutine next_tok: called CC=1 SCAR=0.0
Pod undocumented
27 2510 my ( $self ) = @_;
28 2510 return $self->{toks}->[$self->{pos}++];
29 }
30  
31 768 ▶sub expect {
Subroutine expect: called CC=2 SCAR=6.9
Pod undocumented
32 768 my ( $self, $k ) = @_;
33 768 my $t = $self->next_tok;
34 768 ▶ croak "Expected $k, got $t->{k}" unless $t->{k} eq $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $t->{"k"} eq $k 5 763 768
35 763 return $t;
36 }
37  
38 1463 ▶sub _is_ws {
Subroutine _is_ws: called CC=2 SCAR=6.9
39 1463 my ( $c ) = @_;
40 1463 ▶ return defined $c && $c =~ /\s/;
Condition100%3/3
defined $c && $c =~ /\s/
!ll&&!rl&&r
3161042105
MC/DC100%2/2
defined $c && $c =~ /\s/
defined $c $c =~ /\s/
Truth table100%3/3
A && B
A= defined $cB= $c =~ /\s/
ABresult
0X0
100
111
41 }
42  
43 437 ▶sub _tokenize {
Subroutine _tokenize: called CC=64 SCAR=41.8
44 437 my ( $self, $src ) = @_;
45 437 my @t;
46  
47 437 my @c = split //, $src;
48 437 my $n = @c;
49 437 my $i = 0;
50  
51 437 ▶ my $push = sub { push @t, @_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
52 1999 ▶ my $prev_sig = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
53 1999 my ( $idx ) = @_;
54 1999 ▶ for ( my $j = $idx - 1; $j >= 0; $j-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j >= 0) 1777 437 2214
55 1777 ▶ next if $c[$j] =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $c[$j] =~ /\s/ 215 1562 1777
56 1562 return $c[$j];
57 }
58 437 return undef;
59 437 };
60 1999 ▶ my $next_sig = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
61 1999 my ( $idx ) = @_;
62 1999 ▶ for ( my $j = $idx + 1; $j < $n; $j++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $n) 1907 228 2135
63 1907 ▶ next if $c[$j] =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $c[$j] =~ /\s/ 136 1771 1907
64 1771 return $c[$j];
65 }
66 228 return undef;
67 437 };
68 586 ▶ my $ws_on_both = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
69 586 my ( $left, $right ) = @_;
70 586 ▶ return ( _is_ws($left) and _is_ws($right) );
Condition100%3/3
_is_ws($left) && _is_ws($right)
!ll&&!rl&&r
5291542
MC/DC100%2/2
_is_ws($left) && _is_ws($right)
_is_ws($left) _is_ws($right)
Truth table100%3/3
A && B
A= _is_ws($left)B= _is_ws($right)
ABresult
0X0
100
111
71 437 };
72  
73 437 ▶ while ( $i < $n ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $n) 2436 432 2868
74 2436 my $ch = $c[$i];
75  
76 2436 ▶ if ( $ch =~ /\s/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch =~ /\s/) 325 2111 2436
77 325 $i++;
78 325 next;
79 }
80  
81 2111 ▶ my $prev = $i > 0 ? $c[$i - 1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$i > 0 ? : 1674 437 2111
82 2111 ▶ my $next = $i + 1 < $n ? $c[$i + 1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$i + 1 < $n ? : 1883 228 2111
83 2111 ▶ my $pair = $i + 1 < $n ? $ch . $c[$i + 1] : '';
Branch: 1 branch
BranchTrueFalseTotal
$i + 1 < $n ? : 1883 228 2111
84  
85 2111 my %two_char = (
86 '&&' => 'ANDAND',
87 '||' => 'OROR',
88 '==' => 'EQEQ',
89 '!=' => 'NEQ',
90 '>=' => 'GE',
91 '<=' => 'LE',
92 );
93 2111 ▶ if ( exists $two_char{$pair} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $two_char{$pair}) 90 2021 2111
94 90 $push->({ k => $two_char{$pair}, v => $pair });
95 90 $i += 2;
96 90 next;
97 }
98  
99 2021 my %one_char = (
100 '+' => 'PLUS',
101 '-' => 'MINUS',
102 '%' => 'PCT',
103 '^' => 'BXOR',
104 '&' => 'BAND',
105 '|' => 'BOR',
106 '>' => 'GT',
107 '<' => 'LT',
108 );
109 2021 ▶ if ( exists $one_char{$ch} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $one_char{$ch}) 22 1999 2021
110 # Keep arithmetic operators strict to avoid ambiguity with path syntax.
111 22 ▶ if ( $ch eq '+' || $ch eq '-' || $ch eq '%' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "+" or $ch eq "-" or $ch eq "%") 15 7 22
Condition100%6/6
$ch eq "+" or $ch eq "-" or $ch eq "%"
l!l&&r!l&&!r
1237
$ch eq "+" or $ch eq "-"
l!l&&r!l&&!r
10210
MC/DC100%3/3
$ch eq "+" or $ch eq "-" or $ch eq "%"
$ch eq "+" $ch eq "-" $ch eq "%"
Truth table100%4/4
A or B or C
A= $ch eq "+"B= $ch eq "-"C= $ch eq "%"
ABCresult
1XX1
01X1
0011
0000
112 15 ▶ if ( $ws_on_both->( $prev, $next ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$ws_on_both($prev, $next)) 13 2 15
113 13 $push->({ k => $one_char{$ch}, v => $ch });
114 13 $i++;
115 13 next;
116 }
117 2 croak "Binary operator '$ch' requires whitespace around it";
118 }
119  
120 7 $push->({ k => $one_char{$ch}, v => $ch });
121 7 $i++;
122 7 next;
123 }
124  
125 1999 my $prev_nonws = $prev_sig->($i);
126 1999 my $next_nonws = $next_sig->($i);
127  
128 1999 ▶ if ( $ch eq '/' and $ws_on_both->( $prev, $next )
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>) 5 1994 1999
Condition73%11/15
$ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>
!ll&&!rl&&r
199405
$ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]>
!ll&&!rl&&r
199405
$ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws and defined $next_nonws
!ll&&!rl&&r
199405
$ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws
!ll&&!rl&&r
199405
$ch eq "/" and &$ws_on_both($prev, $next)
!ll&&!rl&&r
15844105
MC/DC33%2/6
$ch eq "/" and &$ws_on_both($prev, $next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>
$ch eq "/" &$ws_on_both($prev, $next) defined $prev_nonws defined $next_nonws not $prev_nonws =~ m<[\[\(,:?/]> not $next_nonws =~ m<[\]\),:?/]>
Truth table42%3/7
A and B and C and D and not(E) and not(F)
A= $ch eq "/"B= &$ws_on_both($prev, $next)C= defined $prev_nonwsD= defined $next_nonwsE= not $prev_nonws =~ m<[\[\(,:?/]>F= not $next_nonws =~ m<[\]\),:?/]>
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
129 and defined $prev_nonws and defined $next_nonws
130 and $prev_nonws !~ m{[\[\(,:?/]}
131 and $next_nonws !~ m{[\]\),:?/]} ) {
132 5 $push->({ k => 'SLASH', v => '/' });
133 5 $i++;
134 5 next;
135 }
136  
137 1994 ▶ if ( $ch eq '/' and ( _is_ws($prev) xor _is_ws($next) )
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>) 3 1991 1994
Condition89%17/19
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>
!ll&&!rl&&r
199103
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]>
!ll&&!rl&&r
199013
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws and defined $next_nonws
!ll&&!rl&&r
198914
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws
!ll&&!rl&&r
198815
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next)
!ll&&!rl&&r
15844046
_is_ws($prev) xor _is_ws($next)
l&&rl&&!r!l&&r!l&&!r
033404
MC/DC85%6/7
$ch eq "/" and _is_ws($prev) ^^ _is_ws($next) and defined $prev_nonws and defined $next_nonws and not $prev_nonws =~ m<[\[\(,:?/]> and not $next_nonws =~ m<[\]\),:?/]>
$ch eq "/" _is_ws($prev) _is_ws($next) defined $prev_nonws defined $next_nonws not $prev_nonws =~ m<[\[\(,:?/]> not $next_nonws =~ m<[\]\),:?/]>
Truth table53%7/13
A and B xor C and D and E and not(F) and not(G)
A= $ch eq "/"B= _is_ws($prev)C= _is_ws($next)D= defined $prev_nonwsE= defined $next_nonwsF= not $prev_nonws =~ m<[\[\(,:?/]>G= not $next_nonws =~ m<[\]\),:?/]>
ABCDEFGresult
0XXXXXX0
111XXXX0
100XXXX0
1100XXX0
1010XXX0
11010XX0
10110XX0
110110X0
101110X0
11011100
10111100
11011111
10111111
138 and defined $prev_nonws and defined $next_nonws
139 and $prev_nonws !~ m{[\[\(,:?/]}
140 and $next_nonws !~ m{[\]\),:?/]} ) {
141 3 croak "Binary operator '/' requires whitespace around it";
142 }
143  
144 1991 ▶ if ( $ch eq '/' ) { $push->({ k => 'SLASH_PATH', v => '/' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "/") 407 1584 1991
145 1584 ▶ if ( $ch eq '(' ) { $push->({ k => 'LPAREN', v => '(' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "(") 121 1463 1584
146 1463 ▶ if ( $ch eq ')' ) { $push->({ k => 'RPAREN', v => ')' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq ")") 121 1342 1463
147 1342 ▶ if ( $ch eq '[' ) { $push->({ k => 'LBRACK', v => '[' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "[") 96 1246 1342
148 1246 ▶ if ( $ch eq ']' ) { $push->({ k => 'RBRACK', v => ']' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "]") 96 1150 1246
149 1150 ▶ if ( $ch eq ',' ) { $push->({ k => 'COMMA', v => ',' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq ",") 46 1104 1150
150  
151 1104 ▶ if ( $ch eq '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq ".") 31 1073 1104
152 31 ▶ if ( $i + 2 < $n and $c[$i + 1] eq '.' and $c[$i + 2] eq '*' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 2 < $n and $c[$i + 1] eq "." and $c[$i + 2] eq "*") 2 29 31
Condition100%6/6
$i + 2 < $n and $c[$i + 1] eq "." and $c[$i + 2] eq "*"
!ll&&!rl&&r
2542
$i + 2 < $n and $c[$i + 1] eq "."
!ll&&!rl&&r
10156
MC/DC100%3/3
$i + 2 < $n and $c[$i + 1] eq "." and $c[$i + 2] eq "*"
$i + 2 < $n $c[$i + 1] eq "." $c[$i + 2] eq "*"
Truth table100%4/4
A and B and C
A= $i + 2 < $nB= $c[$i + 1] eq "."C= $c[$i + 2] eq "*"
ABCresult
0XX0
10X0
1100
1111
153 2 $push->({ k => 'DOTDOTSTAR', v => '..*' });
154 2 $i += 3;
155 2 next;
156 }
157 29 ▶ if ( $i + 1 < $n and $c[$i + 1] eq '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $n and $c[$i + 1] eq ".") 11 18 29
Condition100%3/3
$i + 1 < $n and $c[$i + 1] eq "."
!ll&&!rl&&r
31511
MC/DC100%2/2
$i + 1 < $n and $c[$i + 1] eq "."
$i + 1 < $n $c[$i + 1] eq "."
Truth table100%3/3
A and B
A= $i + 1 < $nB= $c[$i + 1] eq "."
ABresult
0X0
100
111
158 11 $push->({ k => 'DOTDOT', v => '..' });
159 11 $i += 2;
160 11 next;
161 }
162 18 $push->({ k => 'DOT', v => '.' });
163 18 $i++;
164 18 next;
165 }
166  
167 1073 ▶ if ( $ch eq '*' and $ws_on_both->( $prev, $next ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "*" and &$ws_on_both($prev, $next)) 10 1063 1073
Condition100%3/3
$ch eq "*" and &$ws_on_both($prev, $next)
!ll&&!rl&&r
93113210
MC/DC100%2/2
$ch eq "*" and &$ws_on_both($prev, $next)
$ch eq "*" &$ws_on_both($prev, $next)
Truth table100%3/3
A and B
A= $ch eq "*"B= &$ws_on_both($prev, $next)
ABresult
0X0
100
111
168 10 $push->({ k => 'STAR', v => '*' });
169 10 $i++;
170 10 next;
171 }
172  
173 1063 ▶ if ( $ch eq '*' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "*") 132 931 1063
174 132 ▶ if ( $i + 1 < $n and $c[$i + 1] eq '*' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $n and $c[$i + 1] eq "*") 85 47 132
Condition100%3/3
$i + 1 < $n and $c[$i + 1] eq "*"
!ll&&!rl&&r
113685
MC/DC100%2/2
$i + 1 < $n and $c[$i + 1] eq "*"
$i + 1 < $n $c[$i + 1] eq "*"
Truth table100%3/3
A and B
A= $i + 1 < $nB= $c[$i + 1] eq "*"
ABresult
0X0
100
111
175 85 $push->({ k => 'STARSTAR', v => '**' });
176 85 $i += 2;
177 85 next;
178 }
179 47 $push->({ k => 'STAR_PATH', v => '*' });
180 47 $i++;
181 47 next;
182 }
183  
184 931 ▶ if ( $ch eq '!' ) { $push->({ k => 'NOT', v => '!' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "!") 7 924 931
185 924 ▶ if ( $ch eq '~' ) { $push->({ k => 'BNOT', v => '~' }); $i++; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "~") 1 923 924
186  
187 923 ▶ if ( $ch eq '?' || $ch eq ':' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "?" or $ch eq ":") 14 909 923
Condition100%3/3
$ch eq "?" or $ch eq ":"
l!l&&r!l&&!r
77909
MC/DC100%2/2
$ch eq "?" or $ch eq ":"
$ch eq "?" $ch eq ":"
Truth table100%3/3
A or B
A= $ch eq "?"B= $ch eq ":"
ABresult
1X1
011
000
188 14 ▶ if ( $ws_on_both->( $prev, $next ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$ws_on_both($prev, $next)) 14 0 14
189 14 ▶ $push->({ k => ( $ch eq '?' ) ? 'QMARK' : 'COLON', v => $ch });
Branch: 1 branch
BranchTrueFalseTotal
$ch eq '?' ? : 7 7 14
190 14 $i++;
191 14 next;
192 }
193 0 croak "Ternary operator '$ch' requires whitespace around it";
194 }
195  
196 909 ▶ if ( $ch eq '"' || $ch eq "'" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "\"" or $ch eq "'") 137 772 909
Condition100%3/3
$ch eq "\"" or $ch eq "'"
l!l&&r!l&&!r
10433772
MC/DC100%2/2
$ch eq "\"" or $ch eq "'"
$ch eq "\"" $ch eq "'"
Truth table100%3/3
A or B
A= $ch eq "\""B= $ch eq "'"
ABresult
1X1
011
000
197 137 my $quote = $ch;
198 137 $i++;
199 137 my $s = '';
200 137 my $esc = 0;
201 137 ▶ while ( $i < $n ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $n) 1040 0 1040
202 1040 my $cc = $c[$i++];
203 1040 ▶ if ( $esc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) 0 1040 1040
204 0 $s .= _unescape_char($cc);
205 0 $esc = 0;
206 0 next;
207 }
208 1040 ▶ if ( $cc eq '\\' ) { $esc = 1; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($cc eq "\\") 0 1040 1040
209 1040 ▶ last if $cc eq $quote;
Branch: 1 branch
BranchTrueFalseTotal
if $cc eq $quote 137 903 1040
210 903 $s .= $cc;
211 }
212 137 $push->({ k => 'STRING', v => $s });
213 137 next;
214 }
215  
216 772 ▶ if ( $ch eq '#' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "#") 7 765 772
217 7 my $j = $i + 1;
218 7 ▶ croak "Invalid index '#'" unless $j < $n and $c[$j] =~ /\d/;
Branch: 1 branch
BranchTrueFalseTotal
unless $j < $n and $c[$j] =~ /\d/ 0 7 7
Condition33%1/3
$j < $n and $c[$j] =~ /\d/
!ll&&!rl&&r
007
MC/DC0%0/2
$j < $n and $c[$j] =~ /\d/
$j < $n $c[$j] =~ /\d/
Truth table33%1/3
A and B
A= $j < $nB= $c[$j] =~ /\d/
ABresult
0X0
100
111
219 7 my $num = '';
220 7 ▶ while ( $j < $n and $c[$j] =~ /\d/ ) { $num .= $c[$j++]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $n and $c[$j] =~ /\d/) 7 7 14
Condition100%3/3
$j < $n and $c[$j] =~ /\d/
!ll&&!rl&&r
347
MC/DC100%2/2
$j < $n and $c[$j] =~ /\d/
$j < $n $c[$j] =~ /\d/
Truth table100%3/3
A and B
A= $j < $nB= $c[$j] =~ /\d/
ABresult
0X0
100
111
221 7 $push->({ k => 'INDEX', v => 0 + $num });
222 7 $i = $j;
223 7 next;
224 }
225  
226 765 ▶ if ( $ch =~ /[0-9]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch =~ /[0-9]/) 173 592 765
227 173 my $j = $i;
228 173 my $num = '';
229 173 ▶ while ( $j < $n and $c[$j] =~ /[0-9.]/ ) { $num .= $c[$j++]; }
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $n and $c[$j] =~ /[0-9.]/) 231 173 404
Condition100%3/3
$j < $n and $c[$j] =~ /[0-9.]/
!ll&&!rl&&r
8291231
MC/DC100%2/2
$j < $n and $c[$j] =~ /[0-9.]/
$j < $n $c[$j] =~ /[0-9.]/
Truth table100%3/3
A and B
A= $j < $nB= $c[$j] =~ /[0-9.]/
ABresult
0X0
100
111
230 173 $push->({ k => 'NUMBER', v => 0 + $num });
231 173 $i = $j;
232 173 next;
233 }
234  
235 592 my $name = _read_name( \@c, $i );
236 592 ▶ if ( defined $name->{v} and length $name->{v} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name->{"v"} and length $name->{"v"}) 592 0 592
Condition33%1/3
defined $name->{"v"} and length $name->{"v"}
!ll&&!rl&&r
00592
MC/DC0%0/2
defined $name->{"v"} and length $name->{"v"}
defined $name->{"v"} length $name->{"v"}
Truth table33%1/3
A and B
A= defined $name->{"v"}B= length $name->{"v"}
ABresult
0X0
100
111
237 592 $push->({ k => 'NAME', v => $name->{v} });
238 592 $i = $name->{i};
239 592 next;
240 }
241  
242 0 croak "Unexpected character '$ch' at position $i";
243 }
244  
245 432 push @t, { k => 'EOF', v => '' };
246 432 return \@t;
247 }
248  
249 0 ▶sub _unescape_char {
Subroutine _unescape_char: not called CC=4 SCAR=30.0
250 0 my ( $c ) = @_;
251 0 ▶ return "\n" if $c eq 'n';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "n" 0 0 0
252 0 ▶ return "\r" if $c eq 'r';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "r" 0 0 0
253 0 ▶ return "\t" if $c eq 't';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "t" 0 0 0
254 0 return $c;
255 }
256  
257 592 ▶sub _read_name {
Subroutine _read_name: called CC=7 SCAR=21.3
258 592 my ( $chars, $i ) = @_;
259 592 my $n = @$chars;
260  
261 592 my %delim = map { $_ => 1 } split //, "\n\r\t()[]/,=&|!<># ";
262 592 my $buf = '';
263 592 my $esc = 0;
264  
265 592 my $start = $i;
266 592 ▶ while ( $i < $n ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $n) 3481 124 3605
267 3481 my $c = $chars->[$i];
268  
269 3481 ▶ if ( $esc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($esc) 0 3481 3481
270 0 $buf .= $c;
271 0 $esc = 0;
272 0 $i++;
273 0 next;
274 }
275  
276 3481 ▶ if ( $c eq '\\' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\\") 0 3481 3481
277 0 $esc = 1;
278 0 $i++;
279 0 next;
280 }
281  
282 3481 ▶ last if $delim{$c};
Branch: 1 branch
BranchTrueFalseTotal
if $delim{$c} 468 3013 3481
283 3013 ▶ last if $c =~ /\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\s/ 0 3013 3013
284 3013 $buf .= $c;
285 3013 $i++;
286 }
287  
288 592 ▶ return { v => '', i => $start } unless length $buf;
Branch: 1 branch
BranchTrueFalseTotal
unless length $buf 0 592 592
289 592 return { v => $buf, i => $i };
290 }
291  
292 9 1;
« Data/ZPath/_Evaluate.pm ↑ Summary Data/ZPath/_Parser.pm »