blib/lib/Zuzu/Parser/_Impl.pm

filter: Statementstmt 92.5% 1419 / 1533 Branchbran 83.2% 619 / 744 Conditioncond 75.5% 616 / 815 MC/DCmcdc 42.9% 165 / 384 Subroutinesub 99.2% 135 / 136 Podpod 75.8% 22 / 29 totaltotal 81.7% 2976 / 3641 CC 666 SCAR 38.2
CC
666
Cov
86%
_split_template_parts
342.0
_prec
136.8
parse_primary
102.9
CRAP 45.6
« blib/lib/Zuzu/Module/DNS.pm ↑ Summary blib/lib/Zuzu/Lexer.pm »
1 package Zuzu::Parser::_Impl;
2  
3 78 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 78 our $VERSION = '0.007002';
6  
7 78 ▶use Zuzu::AST::Block;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 78 ▶use Zuzu::AST::Expr::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 78 ▶use Zuzu::AST::Expr::Await;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 78 ▶use Zuzu::AST::Expr::Binary;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 78 ▶use Zuzu::AST::Expr::Bag;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 78 ▶use Zuzu::AST::Expr::Call;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 78 ▶use Zuzu::AST::Expr::Dict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 78 ▶use Zuzu::AST::Expr::DictGet;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 78 ▶use Zuzu::AST::Expr::DynamicMemberCall;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 78 ▶use Zuzu::AST::Expr::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 78 ▶use Zuzu::AST::Expr::Index;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 78 ▶use Zuzu::AST::Expr::IncDec;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 78 ▶use Zuzu::AST::Expr::Literal;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 78 ▶use Zuzu::AST::Expr::MemberCall;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 78 ▶use Zuzu::AST::Expr::New;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 78 ▶use Zuzu::AST::Expr::PairList;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 78 ▶use Zuzu::AST::Expr::Range;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 78 ▶use Zuzu::AST::Expr::Regexp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 78 ▶use Zuzu::AST::Expr::Set;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 78 ▶use Zuzu::AST::Expr::Slice;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 78 ▶use Zuzu::AST::Expr::Spawn;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 78 ▶use Zuzu::AST::Expr::Spread;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 78 ▶use Zuzu::AST::Expr::Ternary;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 78 ▶use Zuzu::AST::Expr::TypeRef;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 78 ▶use Zuzu::AST::Expr::Unary;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 78 ▶use Zuzu::AST::Expr::Var;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 78 ▶use Zuzu::AST::Program;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 78 ▶use Zuzu::AST::Stmt::Assign;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 78 ▶use Zuzu::AST::Stmt::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 78 ▶use Zuzu::AST::Stmt::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 78 ▶use Zuzu::AST::Stmt::Continue;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 78 ▶use Zuzu::AST::Stmt::Expr;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 78 ▶use Zuzu::AST::Stmt::For;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 78 ▶use Zuzu::AST::Stmt::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 78 ▶use Zuzu::AST::Stmt::If;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 78 ▶use Zuzu::AST::Stmt::Import;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 78 ▶use Zuzu::AST::Stmt::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 78 ▶use Zuzu::AST::Stmt::Catch;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 78 ▶use Zuzu::AST::Stmt::Die;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 78 ▶use Zuzu::AST::Stmt::Last;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 78 ▶use Zuzu::AST::Stmt::Let;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 78 ▶use Zuzu::AST::Stmt::LetUnpack;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 78 ▶use Zuzu::AST::Stmt::Method;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 78 ▶use Zuzu::AST::Stmt::Next;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 78 ▶use Zuzu::AST::Stmt::PostfixIf;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 78 ▶use Zuzu::AST::Stmt::Return;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 78 ▶use Zuzu::AST::Stmt::Switch;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 78 ▶use Zuzu::AST::Stmt::Throw;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 78 ▶use Zuzu::AST::Stmt::Trait;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 78 ▶use Zuzu::AST::Stmt::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 78 ▶use Zuzu::AST::Stmt::While;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 78 ▶use Zuzu::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 78 ▶use Zuzu::Lexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 78 ▶use Zuzu::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
61 78 ▶use Zuzu::Value::Regexp;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 78 ▶use Zuzu::Value::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 78 ▶use Zuzu::Value::BinaryString;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 78 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
66 78 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68 78 has 'lexer' => ( is => 'rw' );
69 78 has 'filename' => ( is => 'rw' );
70 78 has 'tok' => ( is => 'rw' );
71 has 'scopes' => (
72 is => 'rw',
73 934 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
74 my %root = map {
75 934 $_ => { kind => 'builtin', mutable => 0 }
76 } qw(
77 Exception
78 Any
79 Null
80 Boolean
81 Number
82 AssertionException
83 TypeException
84 CancelledException
85 TimeoutException
86 ChannelClosedException
87 Object
88 Collection
89 Array
90 Dict
91 PairList
92 Set
93 Bag
94 Pair
95 String
96 BinaryString
97 Task
98 Regexp
99 Function
100 Trait
101 Class
102 say
103 print
104 warn
105 typeof
106 to_binary
107 to_string
108 __file__
109 __system__
110 __global__
111 );
112  
113 934 return [ \%root ];
114 },
115 78 );
116  
117 1411 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
118 1411 my ($self, $args) = @_;
119  
120 1411 $self->{tok} = $self->{lexer}->next_token;
121  
122 1400 return;
123 }
124  
125 164 ▶sub _err {
Subroutine _err: called CC=2 SCAR=7.6
126 164 my ($self, $msg, $tok) = @_;
127  
128 164 ▶ $tok //= $self->{tok};
Condition33%1/3
$tok //= $self->{"tok"}
l!l&&r!l&&!r
16400
MC/DC0%0/2
$tok //= $self->{"tok"}
$tok $self->{"tok"}
Truth table33%1/3
A //= B
A= $tokB= $self->{"tok"}
ABresult
1X1
011
000
129 164 die Zuzu::Error->new_compile(code => 'E_COMPILE_SYNTAX', message => $msg, file => $tok->file, line => $tok->line);
130 }
131  
132 203060 ▶sub _eat {
Subroutine _eat: called CC=5 SCAR=16.1
133 203060 my ($self, $type, $value) = @_;
134  
135 203060 my $t = $self->{tok};
136 203060 ▶ $self->_err("Expected $type", $t) if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 41 203019 203060
137 203019 ▶ $self->_err("Expected '$value'", $t) if defined($value) && (($t->value // '') ne $value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and ($t->value // "") ne $value 12 203007 203019
Condition80%4/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
8376211924512
$t->value // ""
l!l
1192570
MC/DC50%1/2
defined $value and ($t->value // "") ne $value
defined $value $t->value
Truth table66%2/3
A and B
A= defined $valueB= $t->value
ABresult
0X0
100
111
138 203007 $self->{tok} = $self->{lexer}->next_token;
139  
140 203006 return $t;
141 }
142  
143 926619 ▶sub _maybe {
Subroutine _maybe: called CC=5 SCAR=16.2
144 926619 my ($self, $type, $value) = @_;
145  
146 926619 my $t = $self->{tok};
147  
148 926619 ▶ return 0 if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 86678 839941 926619
149  
150 839941 ▶ return 0 if defined($value) && (($t->value // '') ne $value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and ($t->value // "") ne $value 791327 48614 839941
Condition60%3/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
048614791327
$t->value // ""
l!l
8399410
MC/DC0%0/2
defined $value and ($t->value // "") ne $value
defined $value $t->value
Truth table33%1/3
A and B
A= defined $valueB= $t->value
ABresult
0X0
100
111
151 48614 $self->{tok} = $self->{lexer}->next_token;
152  
153 48612 return $t;
154 }
155  
156 16555 ▶sub _peek_token {
Subroutine _peek_token: called CC=1 SCAR=0.0
157 16555 my ($self) = @_;
158  
159 16555 my $lexer = $self->{lexer};
160 16555 my ( $pos, $line, $col, $last ) = (
161 $lexer->pos,
162 $lexer->line,
163 $lexer->col,
164 $lexer->last_token,
165 );
166 16555 my $tok = $lexer->next_token;
167 16555 $lexer->pos($pos);
168 16555 $lexer->line($line);
169 16555 $lexer->col($col);
170 16555 $lexer->last_token($last);
171  
172 16555 return $tok;
173 }
174  
175 9814 ▶sub _eat_member_name {
Subroutine _eat_member_name: called CC=3 SCAR=11.2
176 9814 my ( $self ) = @_;
177  
178 9814 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 9036 778 9814
179 9036 return $self->_eat('IDENT')->value;
180 }
181 778 ▶ if ( $self->{tok}->is_KW ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW) 778 0 778
182 778 return $self->_eat('KW')->value;
183 }
184 0 $self->_err("Expected method name", $self->{tok});
185 }
186  
187 13519 ▶sub _push_scope { push @{$_[0]->{scopes}}, {} }
Subroutine _push_scope: called CC=1 SCAR=0.0
188  
189 13495 ▶sub _pop_scope { pop @{$_[0]->{scopes}} }
Subroutine _pop_scope: called CC=1 SCAR=0.0
190  
191 3272 ▶sub _parse_block_in_async_context {
Subroutine _parse_block_in_async_context: called CC=3 SCAR=11.0
192 3272 my ( $self, $is_async, $decls, $imports ) = @_;
193  
194 3272 ▶ if ( $is_async ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_async) 47 3225 3272
195 local $self->{_async_context_depth} =
196 47 ▶ ( $self->{_async_context_depth} // 0 ) + 1;
Condition50%1/2
$self->{"_async_context_depth"} // 0
l!l
470
MC/DC0%0/1
$self->{"_async_context_depth"} // 0
$self->{"_async_context_depth"}
Truth table50%1/2
A
A= $self->{"_async_context_depth"}
Aresult
11
00
197 47 return $self->_parse_block_with_decls( $decls, $imports );
198 }
199  
200 3225 local $self->{_async_context_depth} = 0;
201 3225 return $self->_parse_block_with_decls( $decls, $imports );
202 }
203  
204 206 ▶sub _mark_wildcard_import_in_scope {
Subroutine _mark_wildcard_import_in_scope: called CC=1 SCAR=0.0
205 206 my ( $self ) = @_;
206  
207 206 $self->{scopes}[-1]{'__wildcard_import__'} = 1;
208  
209 206 return;
210 }
211  
212 236 ▶sub _has_wildcard_import_in_scope {
Subroutine _has_wildcard_import_in_scope: called CC=3 SCAR=11.0
213 236 my ( $self ) = @_;
214  
215 236 ▶ for ( my $i = $#{$self->{scopes}}; $i >= 0; $i-- ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 266 50 316
216 266 ▶ return 1 if $self->{scopes}[$i]{'__wildcard_import__'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"scopes"}[$i]{"__wildcard_import__"} 186 80 266
217 }
218  
219 50 return 0;
220 }
221  
222 13325 ▶sub _declare {
Subroutine _declare: called CC=8 SCAR=21.6
223 13325 my ($self, $name, $info, $tok, $opts) = @_;
224  
225 13325 ▶ $tok //= $self->{tok};
Condition33%1/3
$tok //= $self->{"tok"}
l!l&&r!l&&!r
1332500
MC/DC0%0/2
$tok //= $self->{"tok"}
$tok $self->{"tok"}
Truth table33%1/3
A //= B
A= $tokB= $self->{"tok"}
ABresult
1X1
011
000
226 13325 ▶ $opts //= {};
Condition100%2/2
$opts //= {}
l!l
102612299
MC/DC100%1/1
$opts //= {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
227 13325 ▶ $self->_err("Keyword '$name' cannot be used as an identifier", $tok) if Zuzu::Util::is_keyword($name);
Branch: 1 branch
BranchTrueFalseTotal
if Zuzu::Util::is_keyword($name) 0 13325 13325
228 13325 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 1 13324 13325
229 13324 my $scope = $self->{scopes}[-1];
230 13324 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 2 13322 13324
231 2 my $existing = $scope->{$name};
232 2 ▶ if ( !$opts->{allow_builtin_shadow} or $existing->{kind} ne 'builtin' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"allow_builtin_shadow"} or $existing->{"kind"} ne "builtin") 2 0 2
Condition33%1/3
not $opts->{"allow_builtin_shadow"} or $existing->{"kind"} ne "builtin"
l!l&&r!l&&!r
200
MC/DC0%0/2
not $opts->{"allow_builtin_shadow"} or $existing->{"kind"} ne "builtin"
not $opts->{"allow_builtin_shadow"} $existing->{"kind"} ne "builtin"
Truth table33%1/3
not(A) or B
A= not $opts->{"allow_builtin_shadow"}B= $existing->{"kind"} ne "builtin"
ABresult
1X1
011
000
233 2 $self->_err("Redeclaration of '$name' in the same scope", $tok);
234 }
235 }
236 13322 $scope->{$name} = $info;
237 }
238  
239 1525 ▶sub _declare_function_name {
Subroutine _declare_function_name: called CC=7 SCAR=20.5
240 1525 my ( $self, $name, $tok, $is_predeclared ) = @_;
241  
242 1525 ▶ $self->_err("Keyword '$name' cannot be used as an identifier", $tok) if Zuzu::Util::is_keyword($name);
Branch: 1 branch
BranchTrueFalseTotal
if Zuzu::Util::is_keyword($name) 0 1525 1525
243 1525 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 0 1525 1525
244 1525 my $scope = $self->{scopes}[-1];
245 1525 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 32 1493 1525
246 32 my $existing = $scope->{$name};
247 32 ▶ if ( $is_predeclared or $existing->{kind} ne 'func_predecl' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_predeclared or $existing->{"kind"} ne "func_predecl") 0 32 32
Condition33%1/3
$is_predeclared or $existing->{"kind"} ne "func_predecl"
l!l&&r!l&&!r
0032
MC/DC0%0/2
$is_predeclared or $existing->{"kind"} ne "func_predecl"
$is_predeclared $existing->{"kind"} ne "func_predecl"
Truth table33%1/3
A or B
A= $is_predeclaredB= $existing->{"kind"} ne "func_predecl"
ABresult
1X1
011
000
248 0 $self->_err("Redeclaration of '$name' in the same scope", $tok);
249 }
250 32 $scope->{$name} = { kind => 'func', mutable => 0 };
251 32 return;
252 }
253  
254 1493 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$is_predeclared ? : 32 1461 1493
255 kind => $is_predeclared ? 'func_predecl' : 'func',
256 mutable => 0,
257 };
258 }
259  
260 47821 ▶sub _lookup {
Subroutine _lookup: called CC=3 SCAR=11.0
261 47821 my ($self, $name) = @_;
262  
263 47821 ▶ for (my $i = $#{$self->{scopes}}; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 93578 279 93857
264  
265 93578 ▶ return $self->{scopes}[$i]{$name} if exists $self->{scopes}[$i]{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"scopes"}[$i]{$name} 47542 46036 93578
266 }
267  
268 279 return undef;
269 }
270  
271 923 ▶sub parse_program {
Subroutine parse_program: called CC=4 SCAR=13.9
Pod documented
272 923 my ($self) = @_;
273  
274 923 my @stmts;
275 {
276 923 local $self->{_async_context_depth} =
277 923 ▶ ( $self->{_async_context_depth} // 0 ) + 1;
Condition50%1/2
$self->{"_async_context_depth"} // 0
l!l
0923
MC/DC0%0/1
$self->{"_async_context_depth"} // 0
$self->{"_async_context_depth"}
Truth table50%1/2
A
A= $self->{"_async_context_depth"}
Aresult
11
00
278 923 ▶ while ( ! $self->{tok}->is_EOF ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_EOF) 4193 753 4946
279 4193 $self->_eat_optional_statement_separators;
280 4193 ▶ last if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 4191 4193
281 4191 push @stmts, $self->parse_statement;
282 }
283 }
284  
285 755 return Zuzu::AST::Program->new(file => $self->{filename}, line => 1, statements => \@stmts);
286 }
287  
288 26334 ▶sub _eat_optional_statement_separators {
Subroutine _eat_optional_statement_separators: called CC=2 SCAR=6.9
289 26334 my ( $self ) = @_;
290  
291 26334 ▶ while ( $self->_maybe( 'OP', ';' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 5 26334 26339
292 # Consume no-op statement separators.
293 }
294  
295 26334 return;
296 }
297  
298 26332 ▶sub parse_statement {
Subroutine parse_statement: called CC=27 SCAR=33.0
Pod documented
299 26332 my ($self) = @_;
300  
301 26332 my $t = $self->{tok};
302  
303 26332 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 5860 20472 26332
Condition100%3/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
548737320472
MC/DC100%2/2
$t->is_KW("let") or $t->is_KW("const")
$t->is_KW("let") $t->is_KW("const")
Truth table100%3/3
A or B
A= $t->is_KW("let")B= $t->is_KW("const")
ABresult
1X1
011
000
304  
305 5860 return $self->parse_let;
306 }
307 20472 ▶ if ( $t->is_KW('function') or $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("function") or $t->is_KW("async")) 1541 18931 20472
Condition100%3/3
$t->is_KW("function") or $t->is_KW("async")
l!l&&r!l&&!r
14984318931
MC/DC100%2/2
$t->is_KW("function") or $t->is_KW("async")
$t->is_KW("function") $t->is_KW("async")
Truth table100%3/3
A or B
A= $t->is_KW("function")B= $t->is_KW("async")
ABresult
1X1
011
000
308  
309 1541 return $self->parse_function_def;
310 }
311 18931 ▶ if ( $t->is_KW('class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("class")) 309 18622 18931
312  
313 309 return $self->parse_class_def;
314 }
315 18622 ▶ if ( $t->is_KW('trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("trait")) 14 18608 18622
316  
317 14 return $self->parse_trait_def;
318 }
319 18608 ▶ if ( $t->is_KW('if') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("if")) 3528 15080 18608
320  
321 3528 return $self->parse_if;
322 }
323 15080 ▶ if ( $t->is_KW('while') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("while")) 498 14582 15080
324  
325 498 return $self->parse_while;
326 }
327 14582 ▶ if ( $t->is_KW('for') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("for")) 748 13834 14582
328  
329 748 return $self->parse_for;
330 }
331 13834 ▶ if ( $t->is_KW('switch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("switch")) 31 13803 13834
332  
333 31 return $self->parse_switch;
334 }
335 13803 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 131 13672 13803
336  
337 131 return $self->parse_try;
338 }
339 13672 ▶ if ( $t->is_KW('return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("return")) 5299 8373 13672
340  
341 5299 return $self->parse_return;
342 }
343 8373 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug") or $t->is_KW("assert")) 179 8194 8373
Condition100%12/12
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug") or $t->is_KW("assert")
l!l&&r!l&&!r
167128194
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug")
l!l&&r!l&&!r
16528206
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn")
l!l&&r!l&&!r
15968208
$t->is_KW("say") or $t->is_KW("print")
l!l&&r!l&&!r
351248214
MC/DC100%5/5
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug") or $t->is_KW("assert")
$t->is_KW("say") $t->is_KW("print") $t->is_KW("warn") $t->is_KW("debug") $t->is_KW("assert")
Truth table100%6/6
A or B or C or D or E
A= $t->is_KW("say")B= $t->is_KW("print")C= $t->is_KW("warn")D= $t->is_KW("debug")E= $t->is_KW("assert")
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
344 $t->is_KW('say')
345 or $t->is_KW('print')
346 or $t->is_KW('warn')
347 or $t->is_KW('debug')
348 or $t->is_KW('assert')
349 ) {
350 179 return $self->parse_builtin_statement;
351 }
352 8194 ▶ if ( $t->is_KW('throw') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("throw")) 35 8159 8194
353 35 my $kw = $self->_eat('KW', 'throw');
354 35 my $expr = $self->parse_expression;
355 35 my $stmt = Zuzu::AST::Stmt::Throw->new(
356 file => $kw->file,
357 line => $kw->line,
358 expr => $expr,
359 );
360  
361 35 return $self->_finish_with_postfix_condition($stmt);
362 }
363 8159 ▶ if ( $t->is_KW('die') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("die")) 817 7342 8159
364 817 my $kw = $self->_eat('KW', 'die');
365 817 my $expr = $self->parse_expression;
366 817 my $stmt = Zuzu::AST::Stmt::Die->new(
367 file => $kw->file,
368 line => $kw->line,
369 expr => $expr,
370 );
371  
372 817 return $self->_finish_with_postfix_condition($stmt);
373 }
374 7342 ▶ if ( $t->is_KW('next') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("next")) 277 7065 7342
375 277 my $kw = $self->_eat('KW', 'next');
376 277 my $stmt = Zuzu::AST::Stmt::Next->new(file => $kw->file, line => $kw->line);
377  
378 277 return $self->_finish_with_postfix_condition($stmt);
379 }
380 7065 ▶ if ( $t->is_KW('continue') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("continue")) 20 7045 7065
381 20 my $kw = $self->_eat('KW', 'continue');
382 20 my $stmt = Zuzu::AST::Stmt::Continue->new(file => $kw->file, line => $kw->line);
383  
384 20 return $self->_finish_with_postfix_condition($stmt);
385 }
386 7045 ▶ if ( $t->is_KW('last') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("last")) 85 6960 7045
387 85 my $kw = $self->_eat('KW', 'last');
388 85 my $stmt = Zuzu::AST::Stmt::Last->new(file => $kw->file, line => $kw->line);
389  
390 85 return $self->_finish_with_postfix_condition($stmt);
391 }
392 6960 ▶ if ( $t->is_KW('from') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("from")) 711 6249 6960
393  
394 711 return $self->parse_import;
395 }
396 6249 ▶ if ( $t->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("{")) 19 6230 6249
397  
398 19 return $self->parse_block;
399 }
400  
401 # assignment or expr stmt
402 6230 my $expr = $self->parse_expression;
403  
404 6164 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Stmt::Assign') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa("Zuzu::AST::Stmt::Assign")) 2219 3945 6164
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Stmt::Assign")
!ll&&!rl&&r
039452219
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Stmt::Assign")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Stmt::Assign")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Stmt::Assign")
ABresult
0X0
100
111
405 2219 return $self->_finish_with_postfix_condition($expr);
406 }
407  
408 3945 my $stmt = Zuzu::AST::Stmt::Expr->new(file => $t->file, line => $t->line, expr => $expr);
409  
410 3945 return $self->_finish_with_postfix_condition($stmt);
411 }
412  
413 179 ▶sub parse_builtin_statement {
Subroutine parse_builtin_statement: called CC=4 SCAR=13.9
Pod undocumented
414 179 my ($self) = @_;
415  
416 179 my $kw = $self->_eat('KW');
417 179 ▶ if ( $kw->value eq 'assert' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kw->value eq "assert") 12 167 179
418 12 my $expr = $self->parse_expression;
419 2 my $stmt = Zuzu::AST::Stmt::Assert->new(
420 file => $kw->file,
421 line => $kw->line,
422 expr => $expr,
423 );
424  
425 2 return $self->_finish_with_postfix_condition($stmt);
426 }
427 167 ▶ if ( $kw->value eq 'debug' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kw->value eq "debug") 2 165 167
428 2 my $level = $self->parse_expression;
429 2 $self->_eat('OP', ',');
430 2 my $message = $self->parse_expression;
431 2 my $stmt = Zuzu::AST::Stmt::Debug->new(
432 file => $kw->file,
433 line => $kw->line,
434 level_expr => $level,
435 message_expr => $message,
436 );
437  
438 2 return $self->_finish_with_postfix_condition($stmt);
439 }
440 165 my @args;
441 165 push @args, $self->parse_expression;
442 165 ▶ while ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 165 165
443 0 push @args, $self->parse_expression;
444 }
445  
446 165 my $callee = Zuzu::AST::Expr::Var->new(
447 file => $kw->file,
448 line => $kw->line,
449 name => $kw->value,
450 );
451 165 my $call = Zuzu::AST::Expr::Call->new(
452 file => $kw->file,
453 line => $kw->line,
454 callee => $callee,
455 args => \@args,
456 );
457 165 my $stmt = Zuzu::AST::Stmt::Expr->new(
458 file => $kw->file,
459 line => $kw->line,
460 expr => $call,
461 );
462  
463 165 return $self->_finish_with_postfix_condition($stmt);
464 }
465  
466 12866 ▶sub _finish_with_postfix_condition {
Subroutine _finish_with_postfix_condition: called CC=5 SCAR=16.1
467 12866 my ($self, $stmt) = @_;
468  
469 12866 my $has_postfix = 0;
470 12866 my $negate = 0;
471 12866 ▶ if ( $self->{tok}->is_KW('if') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_KW('if')) { } 1116 11750 12866
elsif ($self->{'tok'}->is_KW('unless')) { } 94 11656 11750
472 1116 $self->_eat('KW', 'if');
473 1116 $has_postfix = 1;
474 } elsif ( $self->{tok}->is_KW('unless') ) {
475 94 $self->_eat('KW', 'unless');
476 94 $negate = 1;
477 94 $has_postfix = 1;
478 }
479  
480 12866 ▶ if ( $has_postfix ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_postfix) { } 1210 11656 12866
elsif ($self->{'tok'}->is_KW('for')) { } 9 11647 11656
481 1210 my $cond = $self->parse_expression;
482 1210 $stmt = Zuzu::AST::Stmt::PostfixIf->new(
483 file => $stmt->file,
484 line => $stmt->line,
485 statement => $stmt,
486 cond => $cond,
487 negate => $negate,
488 );
489 }
490 elsif ( $self->{tok}->is_KW('for') ) {
491 9 $self->_eat('KW', 'for');
492 9 my $collection = $self->parse_expression;
493 9 $stmt = Zuzu::AST::Stmt::For->new(
494 file => $stmt->file,
495 line => $stmt->line,
496 var => '^^',
497 declare_loop_var => 1,
498 loop_var_kind => 'const',
499 collection => $collection,
500 body => Zuzu::AST::Block->new(
501 file => $stmt->file,
502 line => $stmt->line,
503 statements => [ $stmt ],
504 ),
505 else_block => undef,
506 );
507 }
508  
509 12866 $self->_eat_statement_separator;
510  
511 12860 return $stmt;
512 }
513  
514 19396 ▶sub _eat_statement_separator {
Subroutine _eat_statement_separator: called CC=4 SCAR=13.9
515 19396 my ($self) = @_;
516  
517 19396 ▶ return if $self->_maybe('OP', ';');
Branch: 1 branch
BranchTrueFalseTotal
if $self->_maybe("OP", ";") 19376 18 19394
518 18 ▶ return if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 8 10 18
519 10 ▶ return if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 4 6 10
520  
521 6 $self->_eat('OP', ';');
522 }
523  
524 5844 ▶sub parse_block {
Subroutine parse_block: called CC=4 SCAR=13.9
Pod documented
525 5844 my ($self) = @_;
526  
527 5844 my $lb = $self->_eat('OP', '{');
528 5844 $self->_push_scope;
529 5844 my @stmts;
530 5844 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 11042 5833 16875
531 11042 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 6 11036 11042
532 11036 $self->_eat_optional_statement_separators;
533 11036 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 11036 11036
534 11036 push @stmts, $self->parse_statement;
535 }
536 5833 $self->_eat('OP', '}');
537 5833 $self->_pop_scope;
538  
539 5833 return Zuzu::AST::Block->new(file => $lb->file, line => $lb->line, statements => \@stmts);
540 }
541  
542 5861 ▶sub _parse_let_decl {
Subroutine _parse_let_decl: called CC=11 SCAR=24.2
543 5861 my ( $self, $expect_semicolon ) = @_;
544  
545 5861 my $kw = $self->_eat('KW');
546 5861 ▶ my $is_const = ($kw->value eq 'const') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$kw->value eq 'const' ? : 373 5488 5861
547  
548 5861 ▶ if ( $self->{tok}->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("{")) 22 5839 5861
549 22 return $self->_parse_let_unpack_decl( $kw, $is_const, $expect_semicolon );
550 }
551  
552 5839 my ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
553 5824 my $is_weak_storage = $self->_parse_optional_weak_modifier('declaration');
554  
555 # Detect forbidden "let x = 1"
556 5824 ▶ if ($self->{tok}->is_OP && $self->{tok}->value eq '=') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "=") 0 5824 5824
Condition33%1/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "="
!ll&&!rl&&r
058240
MC/DC0%0/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "="
$self->{"tok"}->is_OP $self->{"tok"}->value eq "="
Truth table33%1/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "="
ABresult
0X0
100
111
557 0 $self->_err("Invalid assignment '=' in declaration. Use ':=' (did you mean: let $name := ... ?)", $self->{tok});
558 }
559  
560 5824 my $init;
561 5824 ▶ if ($self->_maybe('OP', ':=')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':=')) { } 5772 52 5824
562 5772 $init = $self->parse_expression;
563 5752 ▶ $is_weak_storage ||= $self->_parse_optional_weak_modifier('declaration');
Condition66%2/3
$is_weak_storage ||= $self->_parse_optional_weak_modifier("declaration")
l!l&&r!l&&!r
045748
MC/DC50%1/2
$is_weak_storage ||= $self->_parse_optional_weak_modifier("declaration")
$is_weak_storage $self->_parse_optional_weak_modifier("declaration")
Truth table66%2/3
A ||= B
A= $is_weak_storageB= $self->_parse_optional_weak_modifier("declaration")
ABresult
1X1
011
000
564 } else {
565 52 $init = undef;
566 }
567 5804 ▶ $self->_eat_statement_separator if $expect_semicolon;
Branch: 1 branch
BranchTrueFalseTotal
if $expect_semicolon 5803 1 5804
568  
569 5803 ▶ $self->_declare(
Branch: 2 branches
BranchTrueFalseTotal
$is_const ? : 371 5432 5803
$is_const ? : 371 5432 5803
570 $name,
571 {
572 kind => $is_const ? 'const' : 'let',
573 mutable => $is_const ? 0 : 1,
574 declared_type => $declared_type,
575 },
576 $name_tok,
577 );
578  
579 5801 ▶ return Zuzu::AST::Stmt::Let->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_storage ? : 8 5793 5801
580 file => $kw->file, line => $kw->line,
581 name => $name, init => $init, is_const => $is_const, declared_type => $declared_type,
582 is_weak_storage => $is_weak_storage ? 1 : 0,
583 );
584 }
585  
586 22 ▶sub _parse_let_unpack_decl {
Subroutine _parse_let_unpack_decl: called CC=8 SCAR=20.9
587 22 my ( $self, $kw, $is_const, $expect_semicolon ) = @_;
588  
589 22 $self->_eat('OP', '{');
590 22 my @bindings;
591 my %names;
592 22 ▶ while ( !$self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 36 19 55
593 36 ▶ if ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 36 36
594 0 next;
595 }
596 36 my $binding = $self->_parse_unpack_binding;
597 34 ▶ if ( $names{ $binding->{name} }++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($names{$binding->{"name"}}++) 1 33 34
598 $self->_err(
599 "Duplicate unpacked binding '".$binding->{name}."' in declaration",
600 $binding->{name_tok},
601 1 );
602 }
603 33 push @bindings, $binding;
604 33 $self->_maybe('OP', ',');
605 }
606 19 $self->_eat('OP', '}');
607 19 $self->_eat('OP', ':=');
608 19 my $init = $self->parse_expression;
609 19 ▶ $self->_eat_statement_separator if $expect_semicolon;
Branch: 1 branch
BranchTrueFalseTotal
if $expect_semicolon 19 0 19
610  
611 19 for my $binding ( @bindings ) {
612 $self->_declare(
613 $binding->{name},
614 {
615 kind => $is_const ? 'const' : 'let',
616 mutable => $is_const ? 0 : 1,
617 declared_type => $binding->{declared_type},
618 },
619 $binding->{name_tok},
620 28 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$is_const ? : 2 26 28
$is_const ? : 2 26 28
621 }
622  
623 19 return Zuzu::AST::Stmt::LetUnpack->new(
624 file => $kw->file,
625 line => $kw->line,
626 bindings => \@bindings,
627 init => $init,
628 is_const => $is_const,
629 );
630 }
631  
632 36 ▶sub _parse_unpack_binding {
Subroutine _parse_unpack_binding: called CC=10 SCAR=23.2
633 36 my ( $self ) = @_;
634  
635 36 my ( $key_expr, $declared_type, $name, $name_tok );
636 36 my $binding_file = $self->{tok}->file;
637 36 my $binding_line = $self->{tok}->line;
638  
639 36 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_IDENT) { } 30 6 36
elsif ($self->{'tok'}->is_KW) { } 0 6 6
elsif ($self->{'tok'}->is_STRING or $self->{'tok'}->is_type('TEMPLATE')) { } 4 2 6
elsif ($self->{'tok'}->is_OP('(')) { } 2 0 2
640 30 my $first = $self->_eat('IDENT');
641 30 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_maybe('OP', ':')) { } 8 22 30
elsif ($self->{'tok'}->is_IDENT) { } 4 18 22
642 8 $key_expr = Zuzu::AST::Expr::Literal->new(
643 file => $first->file,
644 line => $first->line,
645 value => $first->value,
646 );
647 8 ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
648 }
649 elsif ( $self->{tok}->is_IDENT ) {
650 4 my $local_tok = $self->_eat('IDENT');
651 4 $declared_type = $first->value;
652 4 $name = $local_tok->value;
653 4 $name_tok = $local_tok;
654 4 $key_expr = Zuzu::AST::Expr::Literal->new(
655 file => $local_tok->file,
656 line => $local_tok->line,
657 value => $local_tok->value,
658 );
659 }
660 else {
661 18 $declared_type = 'Any';
662 18 $name = $first->value;
663 18 $name_tok = $first;
664 18 $key_expr = Zuzu::AST::Expr::Literal->new(
665 file => $first->file,
666 line => $first->line,
667 value => $first->value,
668 );
669 }
670 }
671 elsif ( $self->{tok}->is_KW ) {
672 0 my $key_tok = $self->_eat('KW');
673 0 $key_expr = Zuzu::AST::Expr::Literal->new(
674 file => $key_tok->file,
675 line => $key_tok->line,
676 value => $key_tok->value,
677 );
678 0 $self->_eat('OP', ':');
679 0 ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
680 }
681 ▶ elsif ( $self->{tok}->is_STRING or $self->{tok}->is_type('TEMPLATE') ) {
Condition100%3/3
$self->{"tok"}->is_STRING or $self->{"tok"}->is_type("TEMPLATE")
l!l&&r!l&&!r
222
MC/DC100%2/2
$self->{"tok"}->is_STRING or $self->{"tok"}->is_type("TEMPLATE")
$self->{"tok"}->is_STRING $self->{"tok"}->is_type("TEMPLATE")
Truth table100%3/3
A or B
A= $self->{"tok"}->is_STRINGB= $self->{"tok"}->is_type("TEMPLATE")
ABresult
1X1
011
000
682 4 $key_expr = $self->parse_primary;
683 3 $self->_eat('OP', ':');
684 3 ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
685 }
686 elsif ( $self->{tok}->is_OP('(') ) {
687 2 $key_expr = $self->parse_primary;
688 2 $self->_eat('OP', ':');
689 2 ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
690 }
691 else {
692 0 $self->_err("Expected unpacked binding in declaration", $self->{tok});
693 }
694  
695 35 my $default_expr;
696 35 my $has_default = 0;
697 35 ▶ if ( $self->_maybe('OP', ':=') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ":=")) 7 28 35
698 7 $default_expr = $self->parse_expression;
699 6 $has_default = 1;
700 }
701 34 my $is_weak_storage = $self->_parse_optional_weak_modifier('declaration');
702  
703 return {
704 34 ▶ file => $binding_file,
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_storage ? : 4 30 34
705 line => $binding_line,
706 key_expr => $key_expr,
707 name => $name,
708 name_tok => $name_tok,
709 declared_type => $declared_type,
710 default_expr => $default_expr,
711 has_default => $has_default,
712 is_weak_storage => $is_weak_storage ? 1 : 0,
713 };
714 }
715  
716 5860 ▶sub parse_let {
Subroutine parse_let: called CC=1 SCAR=0.0
Pod documented
717 5860 my ($self) = @_;
718  
719 5860 return $self->_parse_let_decl(1);
720 }
721  
722 1541 ▶sub parse_function_def {
Subroutine parse_function_def: called CC=15 SCAR=28.2
Pod documented
723 1541 my ($self) = @_;
724  
725 1541 my $async_tok;
726 1541 ▶ if ( $self->{tok}->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("async")) 43 1498 1541
727 43 $async_tok = $self->_eat('KW', 'async');
728 }
729 1541 my $kw = $self->_eat('KW', 'function');
730 1541 my $name_tok = $self->_eat('IDENT');
731 1525 my $name = $name_tok->value;
732  
733 1525 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 32 1493 1525
734 32 $self->_declare_function_name( $name, $name_tok, 1 );
735 32 ▶ return Zuzu::AST::Stmt::Function->new(
Branch: 1 branch
BranchTrueFalseTotal
$async_tok ? : 0 32 32
Condition33%2/6
$async_tok // $kw
l!l&&r!l&&!r
0320
$async_tok // $kw
l!l&&r!l&&!r
0320
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
Truth table33%1/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
736 file => ( $async_tok // $kw )->file,
737 line => ( $async_tok // $kw )->line,
738 name => $name,
739 params => [],
740 is_async => $async_tok ? 1 : 0,
741 is_predeclared => 1,
742 );
743 }
744  
745 1493 $self->_declare_function_name( $name, $name_tok, 0 );
746  
747 1493 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
748 1492 my $return_type = $self->_parse_optional_return_type;
749  
750 my @arg_decls = map {
751 {
752 name => $_,
753 mutable => 0,
754 2264 ▶ declared_type => $param_types->{$_} // 'Any',
Condition50%1/2
$param_types->{$_} // "Any"
l!l
22640
MC/DC0%0/1
$param_types->{$_} // "Any"
$param_types->{$_}
Truth table50%1/2
A
A= $param_types->{$_}
Aresult
11
00
755 }
756 1492 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
14920
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
757 1492 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 28 1464 1492
758 28 ▶ push @arg_decls, {
Condition50%1/2
$vararg_type // "Any"
l!l
280
MC/DC0%0/1
$vararg_type // "Any"
$vararg_type
Truth table50%1/2
A
A= $vararg_type
Aresult
11
00
759 name => $vararg,
760 mutable => 0,
761 declared_type => $vararg_type // 'Any',
762 };
763 }
764 1492 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 64 1428 1492
765 64 ▶ push @arg_decls, {
Condition50%1/2
$named_vararg_type // "PairList"
l!l
640
MC/DC0%0/1
$named_vararg_type // "PairList"
$named_vararg_type
Truth table50%1/2
A
A= $named_vararg_type
Aresult
11
00
766 name => $named_vararg,
767 mutable => 0,
768 declared_type => $named_vararg_type // 'PairList',
769 };
770 }
771 1492 ▶ my $is_async = $async_tok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$async_tok ? : 43 1449 1492
772 1492 my $body = $self->_parse_block_in_async_context(
773 $is_async,
774 \@arg_decls,
775 [],
776 );
777  
778 1485 ▶ return Zuzu::AST::Stmt::Function->new(
Condition66%4/6
$async_tok // $kw
l!l&&r!l&&!r
4214430
$async_tok // $kw
l!l&&r!l&&!r
4214430
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
Truth table66%2/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
779 file => ( $async_tok // $kw )->file,
780 line => ( $async_tok // $kw )->line,
781 name => $name,
782 params => $params,
783 vararg => $vararg,
784 body => $body,
785 param_types => $param_types,
786 vararg_type => $vararg_type,
787 named_vararg => $named_vararg,
788 named_vararg_type => $named_vararg_type,
789 param_optional => $param_optional,
790 param_defaults => $param_defaults,
791 return_type => $return_type,
792 is_async => $is_async,
793 );
794 }
795  
796 309 ▶sub parse_class_def {
Subroutine parse_class_def: called CC=20 SCAR=30.8
Pod documented
797 309 my ($self) = @_;
798  
799 309 my $kw = $self->_eat('KW', 'class');
800 309 my $name_tok = $self->_eat('IDENT');
801 309 my $name = $name_tok->value;
802 309 my $parent;
803 my @traits;
804 309 ▶ if ( $self->_maybe('KW', 'extends') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("KW", "extends")) 133 176 309
805 133 $parent = $self->parse_type_ref;
806 }
807 309 ▶ if ( $self->{tok}->is_KW('with') or $self->{tok}->is_KW('but') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")) 21 288 309
Condition100%3/3
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
l!l&&r!l&&!r
174288
MC/DC100%2/2
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
$self->{"tok"}->is_KW("with") $self->{"tok"}->is_KW("but")
Truth table100%3/3
A or B
A= $self->{"tok"}->is_KW("with")B= $self->{"tok"}->is_KW("but")
ABresult
1X1
011
000
808 21 $self->_eat('KW');
809 21 push @traits, $self->parse_type_ref;
810 20 ▶ while ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 20 20
811 0 push @traits, $self->parse_type_ref;
812 }
813 }
814  
815 308 $self->_declare($name, { kind => 'class', mutable => 0 }, $name_tok);
816  
817 308 my @fields;
818 my @methods;
819 308 my @static_methods;
820 308 my @classes;
821  
822 308 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 96 212 308
823 96 return Zuzu::AST::Stmt::Class->new(
824 file => $kw->file,
825 line => $kw->line,
826 name => $name,
827 parent => $parent,
828 traits => \@traits,
829 fields => \@fields,
830 methods => \@methods,
831 static_methods => \@static_methods,
832 classes => \@classes,
833 );
834 }
835  
836 212 $self->_eat('OP', '{');
837 212 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 1954 211 2165
838 1954 my $t = $self->{tok};
839 1954 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 468 1486 1954
Condition66%2/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
46801486
MC/DC50%1/2
$t->is_KW("let") or $t->is_KW("const")
$t->is_KW("let") $t->is_KW("const")
Truth table66%2/3
A or B
A= $t->is_KW("let")B= $t->is_KW("const")
ABresult
1X1
011
000
840 468 my $decl = $self->_eat('KW');
841 468 my ( $declared_type, $name ) = $self->_parse_typed_identifier;
842 468 my $accessors = $self->_parse_field_accessor_list;
843 468 my $is_weak_storage = $self->_parse_optional_weak_modifier('field declaration');
844 468 my $init;
845 468 ▶ if ( $self->{tok}->is_OP('=') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("=")) 0 468 468
846 0 $self->_err("Invalid assignment '=' in declaration. Use ':='", $self->{tok});
847 }
848 468 ▶ if ( $self->_maybe('OP', ':=') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ":=")) 376 92 468
849 376 $init = $self->parse_expression;
850 376 ▶ $is_weak_storage ||= $self->_parse_optional_weak_modifier('field declaration');
Condition100%3/3
$is_weak_storage ||= $self->_parse_optional_weak_modifier("field declaration")
l!l&&r!l&&!r
11374
MC/DC100%2/2
$is_weak_storage ||= $self->_parse_optional_weak_modifier("field declaration")
$is_weak_storage $self->_parse_optional_weak_modifier("field declaration")
Truth table100%3/3
A ||= B
A= $is_weak_storageB= $self->_parse_optional_weak_modifier("field declaration")
ABresult
1X1
011
000
851 }
852 468 $self->_eat('OP', ';');
853 push @fields, {
854 name => $name,
855 is_const => $decl->value eq 'const' ? 1 : 0,
856 init => $init,
857 declared_type => $declared_type,
858 is_weak_storage => $is_weak_storage ? 1 : 0,
859 468 ▶ accessors => [ @{ $accessors // [] } ],
Branch: 2 branches
BranchTrueFalseTotal
$decl->value eq 'const' ? : 0 468 468
$is_weak_storage ? : 24 444 468
Condition50%1/2
$accessors // []
l!l
4680
MC/DC0%0/1
$accessors // []
$accessors
Truth table50%1/2
A
A= $accessors
Aresult
11
00
860 };
861 468 push @methods, @{ $self->_build_field_accessor_methods(
862 name => $name,
863 declared_type => $declared_type,
864 accessors => $accessors,
865 is_weak_storage => $is_weak_storage,
866 file => $decl->file,
867 line => $decl->line,
868 ) };
869 468 next;
870 }
871 1486 ▶ if ( $t->is_KW('static') or $t->is_KW('async') or $t->is_KW('method') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("static") or $t->is_KW("async") or $t->is_KW("method")) 1486 0 1486
Condition83%5/6
$t->is_KW("static") or $t->is_KW("async") or $t->is_KW("method")
l!l&&r!l&&!r
7514110
$t->is_KW("static") or $t->is_KW("async")
l!l&&r!l&&!r
7231411
MC/DC0%0/3
$t->is_KW("static") or $t->is_KW("async") or $t->is_KW("method")
$t->is_KW("static") $t->is_KW("async") $t->is_KW("method")
Truth table75%3/4
A or B or C
A= $t->is_KW("static")B= $t->is_KW("async")C= $t->is_KW("method")
ABCresult
1XX1
01X1
0011
0000
872 1486 my $m = $self->parse_method_def( \@fields );
873 1485 ▶ if ( $m->is_static ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m->is_static) { } 73 1412 1485
874 73 push @static_methods, $m;
875 }
876 else {
877 1412 push @methods, $m;
878 }
879 1485 next;
880 }
881 0 ▶ if ( $t->is_KW('class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("class")) 0 0 0
882 0 push @classes, $self->parse_class_def;
883 0 next;
884 }
885 0 $self->_err("Only fields, methods, and nested classes are allowed in class bodies", $t);
886 }
887 211 $self->_eat('OP', '}');
888  
889 211 return Zuzu::AST::Stmt::Class->new(
890 file => $kw->file,
891 line => $kw->line,
892 name => $name,
893 parent => $parent,
894 traits => \@traits,
895 fields => \@fields,
896 methods => \@methods,
897 static_methods => \@static_methods,
898 classes => \@classes,
899 );
900 }
901  
902 468 ▶sub _parse_field_accessor_list {
Subroutine _parse_field_accessor_list: called CC=5 SCAR=16.2
903 468 my ( $self ) = @_;
904  
905 468 ▶ return [] if not $self->_maybe( 'KW', 'with' );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("KW", "with") 426 42 468
906  
907 42 my %valid = map { $_ => 1 } qw( get set clear has );
908 42 my @ops;
909 42 while (1) {
910 86 my $tok = $self->_eat('IDENT');
911 86 my $kind = $tok->value;
912 86 ▶ if ( not $valid{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($valid{$kind}) 0 86 86
913 0 $self->_err(
914 "Unknown field accessor '$kind'. Expected one of: get, set, clear, has",
915 $tok,
916 );
917 }
918 86 ▶ push @ops, $kind if not grep { $_ eq $kind } @ops;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $kind;} @ops 86 0 86
919 86 ▶ last if not $self->_maybe('OP', ',');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", ",") 42 44 86
920 }
921  
922 42 return \@ops;
923 }
924  
925 14681 ▶sub _parse_optional_weak_modifier {
Subroutine _parse_optional_weak_modifier: called CC=6 SCAR=21.8
926 14681 my ( $self, $context ) = @_;
927  
928 14681 ▶ return 0 if not $self->{tok}->is_KW('but');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tok"}->is_KW("but") 14623 58 14681
929  
930 58 my $but = $self->_eat('KW', 'but');
931 58 my $tok = $self->{tok};
932 58 ▶ if ( !( $tok->is_IDENT || $tok->is_KW ) || $tok->value ne 'weak' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $tok->is_IDENT || $tok->is_KW or $tok->value ne "weak") 0 58 58
Condition33%2/6
not $tok->is_IDENT || $tok->is_KW or $tok->value ne "weak"
l!l&&r!l&&!r
0058
$tok->is_IDENT || $tok->is_KW
l!l&&r!l&&!r
5800
MC/DC0%0/3
not $tok->is_IDENT || $tok->is_KW or $tok->value ne "weak"
$tok->is_IDENT $tok->is_KW $tok->value ne "weak"
Truth table20%1/5
not(A || B) or C
A= $tok->is_IDENTB= $tok->is_KWC= $tok->value ne "weak"
ABCresult
00X1
1X11
0111
1X00
0100
933 0 ▶ my $modifier = $tok->value // '';
Condition0%0/2
$tok->value // ""
l!l
00
MC/DC0%0/1
$tok->value // ""
$tok->value
Truth table0%0/2
A
A= $tok->value
Aresult
11
00
934 0 $self->_err(
935 "Unknown but modifier '$modifier' in $context; expected 'but weak'",
936 $tok,
937 );
938 }
939 58 $self->{tok} = $self->{lexer}->next_token;
940  
941 58 return 1;
942 }
943  
944 468 ▶sub _build_field_accessor_methods {
Subroutine _build_field_accessor_methods: called CC=9 SCAR=22.0
945 468 my ( $self, %args ) = @_;
946  
947 468 my $name = $args{name};
948 468 ▶ my $declared_type = $args{declared_type} // 'Any';
Condition50%1/2
$args{"declared_type"} // "Any"
l!l
4680
MC/DC0%0/1
$args{"declared_type"} // "Any"
$args{"declared_type"}
Truth table50%1/2
A
A= $args{"declared_type"}
Aresult
11
00
949 468 ▶ my $accessors = $args{accessors} // [];
Condition50%1/2
$args{"accessors"} // []
l!l
4680
MC/DC0%0/1
$args{"accessors"} // []
$args{"accessors"}
Truth table50%1/2
A
A= $args{"accessors"}
Aresult
11
00
950 468 ▶ my $is_weak_storage = $args{is_weak_storage} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_weak_storage'} ? : 24 444 468
951 468 my $file = $args{file};
952 468 my $line = $args{line};
953 468 my @methods;
954  
955 468 for my $kind ( @{ $accessors } ) {
956 86 ▶ if ( $kind eq 'get' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($kind eq 'get') { } 40 46 86
elsif ($kind eq 'set') { } 20 26 46
elsif ($kind eq 'clear') { } 10 16 26
elsif ($kind eq 'has') { } 16 0 16
957 40 push @methods, Zuzu::AST::Stmt::Method->new(
958 file => $file,
959 line => $line,
960 name => 'get_' . $name,
961 params => [],
962 vararg => undef,
963 named_vararg => undef,
964 is_static => 0,
965 param_types => {},
966 vararg_type => 'Any',
967 named_vararg_type => 'PairList',
968 param_optional => {},
969 param_defaults => {},
970 return_type => $declared_type,
971 body => Zuzu::AST::Block->new(
972 file => $file,
973 line => $line,
974 statements => [
975 Zuzu::AST::Stmt::Return->new(
976 file => $file,
977 line => $line,
978 expr => Zuzu::AST::Expr::Var->new(
979 file => $file,
980 line => $line,
981 name => $name,
982 ),
983 ),
984 ],
985 ),
986 );
987 40 $methods[-1]{_generated_field_accessor} = 1;
988 }
989 elsif ( $kind eq 'set' ) {
990 20 my $param_name = '__value';
991 20 push @methods, Zuzu::AST::Stmt::Method->new(
992 file => $file,
993 line => $line,
994 name => 'set_' . $name,
995 params => [ $param_name ],
996 vararg => undef,
997 named_vararg => undef,
998 is_static => 0,
999 param_types => { $param_name => $declared_type },
1000 vararg_type => 'Any',
1001 named_vararg_type => 'PairList',
1002 param_optional => {},
1003 param_defaults => {},
1004 return_type => 'Any',
1005 body => Zuzu::AST::Block->new(
1006 file => $file,
1007 line => $line,
1008 statements => [
1009 Zuzu::AST::Stmt::Assign->new(
1010 file => $file,
1011 line => $line,
1012 target => Zuzu::AST::Expr::Var->new(
1013 file => $file,
1014 line => $line,
1015 name => $name,
1016 ),
1017 op => ':=',
1018 is_weak_write => $is_weak_storage,
1019 expr => Zuzu::AST::Expr::Var->new(
1020 file => $file,
1021 line => $line,
1022 name => $param_name,
1023 ),
1024 ),
1025 Zuzu::AST::Stmt::Return->new(
1026 file => $file,
1027 line => $line,
1028 expr => Zuzu::AST::Expr::Var->new(
1029 file => $file,
1030 line => $line,
1031 name => 'self',
1032 ),
1033 ),
1034 ],
1035 ),
1036 );
1037 20 $methods[-1]{_generated_field_accessor} = 1;
1038 }
1039 elsif ( $kind eq 'clear' ) {
1040 10 my $assign = Zuzu::AST::Stmt::Assign->new(
1041 file => $file,
1042 line => $line,
1043 target => Zuzu::AST::Expr::Var->new(
1044 file => $file,
1045 line => $line,
1046 name => $name,
1047 ),
1048 op => ':=',
1049 expr => Zuzu::AST::Expr::Literal->new(
1050 file => $file,
1051 line => $line,
1052 value => undef,
1053 ),
1054 );
1055 10 $assign->{_skip_type_check} = 1;
1056  
1057 10 push @methods, Zuzu::AST::Stmt::Method->new(
1058 file => $file,
1059 line => $line,
1060 name => 'clear_' . $name,
1061 params => [],
1062 vararg => undef,
1063 named_vararg => undef,
1064 is_static => 0,
1065 param_types => {},
1066 vararg_type => 'Any',
1067 named_vararg_type => 'PairList',
1068 param_optional => {},
1069 param_defaults => {},
1070 return_type => 'Any',
1071 body => Zuzu::AST::Block->new(
1072 file => $file,
1073 line => $line,
1074 statements => [
1075 $assign,
1076 Zuzu::AST::Stmt::Return->new(
1077 file => $file,
1078 line => $line,
1079 expr => Zuzu::AST::Expr::Var->new(
1080 file => $file,
1081 line => $line,
1082 name => 'self',
1083 ),
1084 ),
1085 ],
1086 ),
1087 );
1088 10 $methods[-1]{_generated_field_accessor} = 1;
1089 }
1090 elsif ( $kind eq 'has' ) {
1091 16 push @methods, Zuzu::AST::Stmt::Method->new(
1092 file => $file,
1093 line => $line,
1094 name => 'has_' . $name,
1095 params => [],
1096 vararg => undef,
1097 named_vararg => undef,
1098 is_static => 0,
1099 param_types => {},
1100 vararg_type => 'Any',
1101 named_vararg_type => 'PairList',
1102 param_optional => {},
1103 param_defaults => {},
1104 return_type => 'Boolean',
1105 body => Zuzu::AST::Block->new(
1106 file => $file,
1107 line => $line,
1108 statements => [
1109 Zuzu::AST::Stmt::Return->new(
1110 file => $file,
1111 line => $line,
1112 expr => Zuzu::AST::Expr::Binary->new(
1113 file => $file,
1114 line => $line,
1115 op => '≢',
1116 left => Zuzu::AST::Expr::Var->new(
1117 file => $file,
1118 line => $line,
1119 name => $name,
1120 ),
1121 right => Zuzu::AST::Expr::Literal->new(
1122 file => $file,
1123 line => $line,
1124 value => undef,
1125 ),
1126 ),
1127 ),
1128 ],
1129 ),
1130 );
1131 16 $methods[-1]{_generated_field_accessor} = 1;
1132 }
1133 }
1134  
1135 468 return \@methods;
1136 }
1137  
1138 14 ▶sub parse_trait_def {
Subroutine parse_trait_def: called CC=5 SCAR=16.7
Pod documented
1139 14 my ( $self ) = @_;
1140  
1141 14 my $kw = $self->_eat('KW', 'trait');
1142 14 my $name_tok = $self->_eat('IDENT');
1143 14 my $name = $name_tok->value;
1144  
1145 14 $self->_declare($name, { kind => 'trait', mutable => 0 }, $name_tok);
1146  
1147 14 my @methods;
1148 14 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 0 14 14
1149 0 return Zuzu::AST::Stmt::Trait->new(
1150 file => $kw->file,
1151 line => $kw->line,
1152 name => $name,
1153 methods => \@methods,
1154 );
1155 }
1156  
1157 14 $self->_eat('OP', '{');
1158 14 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 32 14 46
1159 32 my $t = $self->{tok};
1160 32 ▶ if ( $t->is_KW('async') or $t->is_KW('method') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("async") or $t->is_KW("method")) 32 0 32
Condition33%1/3
$t->is_KW("async") or $t->is_KW("method")
l!l&&r!l&&!r
0320
MC/DC0%0/2
$t->is_KW("async") or $t->is_KW("method")
$t->is_KW("async") $t->is_KW("method")
Truth table33%1/3
A or B
A= $t->is_KW("async")B= $t->is_KW("method")
ABresult
1X1
011
000
1161 32 push @methods, $self->parse_method_def( [] );
1162 32 next;
1163 }
1164 0 $self->_err("Only methods are allowed in trait bodies", $t);
1165 }
1166 14 $self->_eat('OP', '}');
1167  
1168 14 return Zuzu::AST::Stmt::Trait->new(
1169 file => $kw->file,
1170 line => $kw->line,
1171 name => $name,
1172 methods => \@methods,
1173 );
1174 }
1175  
1176 157 ▶sub parse_type_ref {
Subroutine parse_type_ref: called CC=3 SCAR=11.0
Pod documented
1177 157 my ( $self ) = @_;
1178  
1179 157 my $root_tok = $self->_eat('IDENT');
1180 157 my $info = $self->_lookup( $root_tok->value );
1181 157 ▶ if ( !$info and !$self->_has_wildcard_import_in_scope ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info or $self->_has_wildcard_import_in_scope) 1 156 157
Condition66%2/3
$info or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
15601
MC/DC50%1/2
$info or $self->_has_wildcard_import_in_scope
$info $self->_has_wildcard_import_in_scope
Truth table66%2/3
A or B
A= $infoB= $self->_has_wildcard_import_in_scope
ABresult
1X1
011
000
1182 1 $self->_err("Use of undeclared identifier '".$root_tok->value."' (compile-time)", $root_tok);
1183 }
1184  
1185 156 return Zuzu::AST::Expr::TypeRef->new(
1186 file => $root_tok->file,
1187 line => $root_tok->line,
1188 root => $root_tok->value,
1189 member => undef,
1190 );
1191 }
1192  
1193 1518 ▶sub parse_method_def {
Subroutine parse_method_def: called CC=23 SCAR=32.2
Pod documented
1194 1518 my ( $self, $fields ) = @_;
1195  
1196 1518 my $is_static = 0;
1197 1518 my $is_async = 0;
1198 1518 my $saw_static_before_async = 0;
1199 1518 my $start_tok;
1200 1518 ▶ while ( $self->{tok}->is_KW('static') or $self->{tok}->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("static") or $self->{"tok"}->is_KW("async")) 77 1518 1595
Condition100%3/3
$self->{"tok"}->is_KW("static") or $self->{"tok"}->is_KW("async")
l!l&&r!l&&!r
7341518
MC/DC100%2/2
$self->{"tok"}->is_KW("static") or $self->{"tok"}->is_KW("async")
$self->{"tok"}->is_KW("static") $self->{"tok"}->is_KW("async")
Truth table100%3/3
A or B
A= $self->{"tok"}->is_KW("static")B= $self->{"tok"}->is_KW("async")
ABresult
1X1
011
000
1201 77 my $modifier = $self->_eat('KW');
1202 77 ▶ $start_tok //= $modifier;
Condition66%2/3
$start_tok //= $modifier
l!l&&r!l&&!r
2750
MC/DC0%0/2
$start_tok //= $modifier
$start_tok $modifier
Truth table66%2/3
A //= B
A= $start_tokB= $modifier
ABresult
1X1
011
000
1203 77 ▶ if ( $modifier->value eq 'static' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier->value eq 'static') { } 73 4 77
1204 73 ▶ $self->_err("Duplicate static method modifier", $modifier)
Branch: 1 branch
BranchTrueFalseTotal
if $is_static 0 73 73
1205 if $is_static;
1206 73 $is_static = 1;
1207 73 ▶ $saw_static_before_async = 1 if !$is_async;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_async 72 1 73
1208 }
1209 else {
1210 4 ▶ $self->_err("Duplicate async method modifier", $modifier)
Branch: 1 branch
BranchTrueFalseTotal
if $is_async 0 4 4
1211 if $is_async;
1212 4 ▶ warn sprintf(
Branch: 1 branch
BranchTrueFalseTotal
if $saw_static_before_async 1 3 4
Condition50%2/4
$modifier->file // "<input>"
l!l
10
$modifier->line // 0
l!l
10
MC/DC0%0/1
$modifier->file // "<input>"
$modifier->file
MC/DC0%0/1
$modifier->line // 0
$modifier->line
Truth table50%1/2
A
A= $modifier->file
Aresult
11
00
Truth table50%1/2
A
A= $modifier->line
Aresult
11
00
1213 "static async method is deprecated; use async static method at %s line %s\n",
1214 $modifier->file // '<input>',
1215 $modifier->line // 0,
1216 ) if $saw_static_before_async;
1217 4 $is_async = 1;
1218 }
1219 }
1220 1518 my $kw = $self->_eat('KW', 'method');
1221 1518 ▶ $start_tok //= $kw;
Condition66%2/3
$start_tok //= $kw
l!l&&r!l&&!r
7514430
MC/DC0%0/2
$start_tok //= $kw
$start_tok $kw
Truth table66%2/3
A //= B
A= $start_tokB= $kw
ABresult
1X1
011
000
1222 1518 my $name = $self->_eat_member_name;
1223  
1224 1518 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 9 1509 1518
1225 9 return Zuzu::AST::Stmt::Method->new(
1226 file => $start_tok->file,
1227 line => $start_tok->line,
1228 name => $name,
1229 params => [],
1230 body => undef,
1231 is_static => $is_static,
1232 is_async => $is_async,
1233 is_predeclared => 1,
1234 );
1235 }
1236  
1237 1509 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
1238 1509 my $return_type = $self->_parse_optional_return_type;
1239  
1240 my @locals = map {
1241 {
1242 name => $_,
1243 mutable => 0,
1244 1416 ▶ declared_type => $param_types->{$_} // 'Any',
Condition50%1/2
$param_types->{$_} // "Any"
l!l
14160
MC/DC0%0/1
$param_types->{$_} // "Any"
$param_types->{$_}
Truth table50%1/2
A
A= $param_types->{$_}
Aresult
11
00
1245 }
1246 1509 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
15090
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
1247 1509 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 32 1477 1509
1248 32 ▶ push @locals, {
Condition50%1/2
$vararg_type // "Any"
l!l
320
MC/DC0%0/1
$vararg_type // "Any"
$vararg_type
Truth table50%1/2
A
A= $vararg_type
Aresult
11
00
1249 name => $vararg,
1250 mutable => 0,
1251 declared_type => $vararg_type // 'Any',
1252 };
1253 }
1254 1509 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 47 1462 1509
1255 47 ▶ push @locals, {
Condition50%1/2
$named_vararg_type // "PairList"
l!l
470
MC/DC0%0/1
$named_vararg_type // "PairList"
$named_vararg_type
Truth table50%1/2
A
A= $named_vararg_type
Aresult
11
00
1256 name => $named_vararg,
1257 mutable => 0,
1258 declared_type => $named_vararg_type // 'PairList',
1259 };
1260 }
1261 1509 push @locals, 'self';
1262 1509 ▶ if ( ! $is_static ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_static) 1439 70 1509
1263 push @locals, map {
1264 {
1265 name => $_->{name},
1266 mutable => $_->{is_const} ? 0 : 1,
1267 7633 ▶ declared_type => $_->{declared_type} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$_->{'is_const'} ? : 0 7633 7633
Condition50%1/2
$_->{"declared_type"} // "Any"
l!l
76330
MC/DC0%0/1
$_->{"declared_type"} // "Any"
$_->{"declared_type"}
Truth table50%1/2
A
A= $_->{"declared_type"}
Aresult
11
00
1268 }
1269 1439 ▶ } @{ $fields // [] };
Condition50%1/2
$fields // []
l!l
14390
MC/DC0%0/1
$fields // []
$fields
Truth table50%1/2
A
A= $fields
Aresult
11
00
1270 }
1271 1509 push @locals, 'super';
1272 1509 my $body = $self->_parse_block_in_async_context(
1273 $is_async,
1274 \@locals,
1275 [],
1276 );
1277  
1278 1508 return Zuzu::AST::Stmt::Method->new(
1279 file => $start_tok->file,
1280 line => $start_tok->line,
1281 name => $name,
1282 params => $params,
1283 vararg => $vararg,
1284 body => $body,
1285 is_static => $is_static,
1286 param_types => $param_types,
1287 vararg_type => $vararg_type,
1288 named_vararg => $named_vararg,
1289 named_vararg_type => $named_vararg_type,
1290 param_optional => $param_optional,
1291 param_defaults => $param_defaults,
1292 return_type => $return_type,
1293 is_async => $is_async,
1294 );
1295 }
1296  
1297 3272 ▶sub _parse_optional_return_type {
Subroutine _parse_optional_return_type: called CC=3 SCAR=11.0
1298 3272 my ( $self ) = @_;
1299  
1300 3272 ▶ return 'Any' if ! $self->_maybe('OP', '->') and ! $self->_maybe('OP', '→');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}") 3253 19 3272
Condition100%3/3
$self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}")
l!l&&r!l&&!r
1093253
MC/DC100%2/2
$self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}")
$self->_maybe("OP", "->") $self->_maybe("OP", "\x{2192}")
Truth table100%3/3
A or B
A= $self->_maybe("OP", "->")B= $self->_maybe("OP", "\x{2192}")
ABresult
1X1
011
000
1301 19 my $type = $self->_eat('IDENT');
1302  
1303 19 return $type->value;
1304 }
1305  
1306 3317 ▶sub _parse_param_list {
Subroutine _parse_param_list: called CC=18 SCAR=29.0
1307 3317 my ($self) = @_;
1308  
1309 3317 $self->_eat('OP', '(');
1310 3317 my @params;
1311 my $vararg;
1312 3317 my $named_vararg;
1313 3317 my %param_types;
1314 3317 my %param_optional;
1315 3317 my %param_defaults;
1316 3317 my $vararg_type = 'Any';
1317 3317 my $named_vararg_type = 'PairList';
1318 3317 my $seen_optional = 0;
1319 3317 $self->_push_scope;
1320 3317 ▶ if ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 2459 858 3317
1321 2459 while (1) {
1322 4990 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 130 4860 4990
1323 130 $self->_eat('OP', '...');
1324 130 while (1) {
1325 177 my ( $collector_type, $collector_name ) = $self->_parse_param_name;
1326 177 ▶ if ( $collector_type eq 'PairList' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($collector_type eq 'PairList') { } 115 62 177
1327 $self->_err("Only one PairList collector can follow '...'", $self->{tok})
1328 115 ▶ if defined $named_vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $named_vararg 0 115 115
1329 115 $named_vararg = $collector_name;
1330 115 $named_vararg_type = $collector_type;
1331 }
1332 else {
1333 $self->_err("Only one positional collector can follow '...'", $self->{tok})
1334 62 ▶ if defined $vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $vararg 0 62 62
1335 62 $vararg = $collector_name;
1336 62 ▶ $vararg_type = $collector_type eq 'Any' ? 'Array' : $collector_type;
Branch: 1 branch
BranchTrueFalseTotal
$collector_type eq 'Any' ? : 13 49 62
1337 }
1338 177 ▶ my $declared = $collector_type eq 'Any'
Branch: 2 branches
BranchTrueFalseTotal
$collector_type eq 'Any' ? : 13 164 177
$named_vararg eq $collector_name ? : 0 0 0
Condition33%1/3
defined $named_vararg and $named_vararg eq $collector_name ? "PairList" : "Array"
!ll&&!rl&&r
1300
MC/DC0%0/2
defined $named_vararg and $named_vararg eq $collector_name ? "PairList" : "Array"
defined $named_vararg $named_vararg eq $collector_name ? "PairList" : "Array"
Truth table33%1/3
A and B
A= defined $named_varargB= $named_vararg eq $collector_name ? "PairList" : "Array"
ABresult
0X0
100
111
1339 ? ( defined $named_vararg and $named_vararg eq $collector_name ? 'PairList' : 'Array' )
1340 : $collector_type;
1341 $self->_declare(
1342 $collector_name,
1343 {
1344 kind => 'local',
1345 mutable => 0,
1346 declared_type => $declared,
1347 },
1348 $self->{tok},
1349 177 );
1350 177 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 130 47 177
1351 47 $self->_eat('OP', ',');
1352 }
1353 130 last;
1354 }
1355  
1356 4860 my ( $type_name, $param_name ) = $self->_parse_param_name;
1357 4857 push @params, $param_name;
1358 4857 $param_types{$param_name} = $type_name;
1359 $self->_declare(
1360 $param_name,
1361 {
1362 kind => 'local',
1363 mutable => 0,
1364 declared_type => $type_name,
1365 },
1366 $self->{tok},
1367 4857 );
1368 4857 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_maybe('OP', '?')) { } 214 4643 4857
elsif ($self->_maybe('OP', ':=')) { } 174 4469 4643
elsif ($seen_optional) { } 1 4468 4469
1369 $self->_err("Optional parameter '$param_name' cannot also define a default value", $self->{tok})
1370 214 ▶ if $self->{tok}->is_OP(':=');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(":=") 0 214 214
1371 214 $param_optional{$param_name} = 1;
1372 214 $seen_optional = 1;
1373 }
1374 elsif ( $self->_maybe('OP', ':=') ) {
1375 174 $param_defaults{$param_name} = $self->parse_expression;
1376 174 $seen_optional = 1;
1377 }
1378 elsif ( $seen_optional ) {
1379 1 $self->_err("Required parameter '$param_name' cannot follow optional/default parameters", $self->{tok});
1380 }
1381  
1382 4856 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 2296 2560 4856
1383 2560 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 7 2553 2560
1384 7 next;
1385 }
1386 2553 $self->_eat('OP', ',');
1387 2553 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 29 2524 2553
1388 }
1389 }
1390 3313 $self->_eat('OP', ')');
1391 3313 $self->_pop_scope;
1392  
1393 3313 return ( \@params, $vararg, \%param_types, $vararg_type, \%param_optional, \%param_defaults, $named_vararg, $named_vararg_type );
1394 }
1395  
1396 5187 ▶sub _parse_param_name {
Subroutine _parse_param_name: called CC=2 SCAR=6.9
1397 5187 my ( $self ) = @_;
1398  
1399 5187 my $first = $self->_eat('IDENT');
1400  
1401 5184 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 1563 3621 5184
1402 1563 my $name_tok = $self->_eat('IDENT');
1403 1563 return ( $first->value, $name_tok->value );
1404 }
1405  
1406 3621 return ( 'Any', $first->value );
1407 }
1408  
1409 6320 ▶sub _parse_typed_identifier {
Subroutine _parse_typed_identifier: called CC=2 SCAR=6.9
1410 6320 my ( $self ) = @_;
1411  
1412 6320 my $first = $self->_eat('IDENT');
1413 6305 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 207 6098 6305
1414 207 my $name_tok = $self->_eat('IDENT');
1415 207 return ( $first->value, $name_tok->value, $name_tok );
1416 }
1417  
1418 6098 return ( 'Any', $first->value, $first );
1419 }
1420  
1421 3272 ▶sub _parse_block_with_decls {
Subroutine _parse_block_with_decls: called CC=15 SCAR=27.7
1422 3272 my ( $self, $decls, $extras ) = @_;
1423  
1424 3272 my $lb = $self->_eat('OP', '{');
1425 3272 $self->_push_scope;
1426 3272 ▶ for my $n ( @{ $decls // [] }, @{ $extras // [] } ) {
Condition50%2/4
$decls // []
l!l
32720
$extras // []
l!l
32720
MC/DC0%0/1
$decls // []
$decls
MC/DC0%0/1
$extras // []
$extras
Truth table50%1/2
A
A= $decls
Aresult
11
00
Truth table50%1/2
A
A= $extras
Aresult
11
00
1427 15616 ▶ next if ! defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 15616 15616
1428 15616 my ( $name, $mutable, $declared_type );
1429 15616 ▶ if ( ref($n) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n eq 'HASH') { } 12598 3018 15616
1430 12598 $name = $n->{name};
1431 12598 ▶ $mutable = defined $n->{mutable} ? $n->{mutable} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $n->{'mutable'} ? : 12598 0 12598
1432 12598 ▶ $declared_type = $n->{declared_type} // 'Any';
Condition50%1/2
$n->{"declared_type"} // "Any"
l!l
125980
MC/DC0%0/1
$n->{"declared_type"} // "Any"
$n->{"declared_type"}
Truth table50%1/2
A
A= $n->{"declared_type"}
Aresult
11
00
1433 }
1434 else {
1435 3018 $name = $n;
1436 3018 $mutable = 1;
1437 3018 $declared_type = 'Any';
1438 }
1439 15616 ▶ next if ! defined $name || $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 15616 15616
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
0015616
MC/DC0%0/2
not defined $name or $name eq ""
not defined $name $name eq ""
Truth table33%1/3
not(A) or B
A= not defined $nameB= $name eq ""
ABresult
1X1
011
000
1440 15616 my $scope = $self->{scopes}[-1];
1441 15616 ▶ next if exists $scope->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $scope->{$name} 2 15614 15616
1442 15614 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$mutable ? : 10649 4965 15614
1443 kind => 'local',
1444 mutable => $mutable ? 1 : 0,
1445 declared_type => $declared_type,
1446 };
1447 }
1448 3272 my @stmts;
1449 3272 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 10813 3265 14078
1450 10813 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 10811 10813
1451 10811 $self->_eat_optional_statement_separators;
1452 10811 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 10811 10811
1453 10811 push @stmts, $self->parse_statement;
1454 }
1455 3265 $self->_eat('OP', '}');
1456 3264 $self->_pop_scope;
1457  
1458 3264 return Zuzu::AST::Block->new(file => $lb->file, line => $lb->line, statements => \@stmts);
1459 }
1460  
1461 3868 ▶sub parse_if {
Subroutine parse_if: called CC=4 SCAR=13.9
Pod documented
1462 3868 my ($self) = @_;
1463  
1464 3868 my $kw = $self->_eat('KW', 'if');
1465 3868 $self->_eat('OP', '(');
1466 3868 my $cond = $self->parse_expression;
1467 3868 $self->_eat('OP', ')');
1468 3868 my $then = $self->parse_block;
1469  
1470 3868 my $else_branch;
1471 3868 ▶ if ($self->_maybe('KW', 'else')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("KW", "else")) 604 3264 3868
1472 604 ▶ if ($self->{tok}->is_KW && $self->{tok}->value eq 'if') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'tok'}->is_KW and $self->{'tok'}->value eq 'if') { } 340 264 604
Condition66%2/3
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "if"
!ll&&!rl&&r
2640340
MC/DC50%1/2
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "if"
$self->{"tok"}->is_KW $self->{"tok"}->value eq "if"
Truth table66%2/3
A and B
A= $self->{"tok"}->is_KWB= $self->{"tok"}->value eq "if"
ABresult
0X0
100
111
1473 340 $else_branch = $self->parse_if;
1474 } else {
1475 264 $else_branch = $self->parse_block;
1476 }
1477 }
1478  
1479 3868 return Zuzu::AST::Stmt::If->new(
1480 file => $kw->file, line => $kw->line,
1481 cond => $cond, then_block => $then, else_branch => $else_branch
1482 );
1483 }
1484  
1485 498 ▶sub parse_while {
Subroutine parse_while: called CC=1 SCAR=0.0
Pod documented
1486 498 my ($self) = @_;
1487  
1488 498 my $kw = $self->_eat('KW', 'while');
1489 498 $self->_eat('OP', '(');
1490 498 my $cond = $self->parse_expression;
1491 497 $self->_eat('OP', ')');
1492 497 my $body = $self->parse_block;
1493  
1494 497 return Zuzu::AST::Stmt::While->new(file => $kw->file, line => $kw->line, cond => $cond, body => $body);
1495 }
1496  
1497 748 ▶sub parse_for {
Subroutine parse_for: called CC=14 SCAR=26.8
Pod documented
1498 748 my ($self) = @_;
1499  
1500 748 my $kw = $self->_eat('KW', 'for');
1501 748 $self->_eat('OP', '(');
1502 748 my $loop_var_kind;
1503 748 ▶ if ( $self->_maybe('KW', 'let') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_maybe('KW', 'let')) { } 731 17 748
elsif ($self->_maybe('KW', 'const')) { } 2 15 17
1504 731 $loop_var_kind = 'let';
1505 }
1506 elsif ( $self->_maybe('KW', 'const') ) {
1507 2 $loop_var_kind = 'const';
1508 }
1509 748 ▶ my $declares_loop_var = defined $loop_var_kind ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $loop_var_kind ? : 733 15 748
1510 748 my ( $id, $var, $col );
1511 748 ▶ if ($declares_loop_var) {
Branch: 2 branches
BranchTrueFalseTotal
if ($declares_loop_var) { } 733 15 748
elsif ($self->{'tok'}->is_IDENT and $self->_peek_token->is_KW('in')) { } 15 0 15
1512 733 $id = $self->_eat('IDENT');
1513 733 $var = $id->value;
1514 733 $self->_eat('KW', 'in');
1515 733 $col = $self->parse_expression;
1516 }
1517 ▶ elsif ( $self->{tok}->is_IDENT and $self->_peek_token->is_KW('in') ) {
Condition33%1/3
$self->{"tok"}->is_IDENT and $self->_peek_token->is_KW("in")
!ll&&!rl&&r
0015
MC/DC0%0/2
$self->{"tok"}->is_IDENT and $self->_peek_token->is_KW("in")
$self->{"tok"}->is_IDENT $self->_peek_token->is_KW("in")
Truth table33%1/3
A and B
A= $self->{"tok"}->is_IDENTB= $self->_peek_token->is_KW("in")
ABresult
0X0
100
111
1518 15 $id = $self->_eat('IDENT');
1519 15 $var = $id->value;
1520 15 ▶ if ( !$self->_lookup($var) and !$self->_has_wildcard_import_in_scope ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_lookup($var) or $self->_has_wildcard_import_in_scope) 13 2 15
Condition66%2/3
$self->_lookup($var) or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
2013
MC/DC50%1/2
$self->_lookup($var) or $self->_has_wildcard_import_in_scope
$self->_lookup($var) $self->_has_wildcard_import_in_scope
Truth table66%2/3
A or B
A= $self->_lookup($var)B= $self->_has_wildcard_import_in_scope
ABresult
1X1
011
000
1521 13 $self->_err("Use of undeclared identifier '$var' (compile-time)", $id);
1522 }
1523 2 $self->_eat('KW', 'in');
1524 2 $col = $self->parse_expression;
1525 }
1526 else {
1527 0 $id = $self->{tok};
1528 0 $var = '^^';
1529 0 $declares_loop_var = 1;
1530 0 $loop_var_kind = 'const';
1531 0 $col = $self->parse_expression;
1532 }
1533 734 $self->_eat('OP', ')');
1534  
1535 734 my $body;
1536 734 ▶ if ($declares_loop_var) {
Branch: 1 branch
BranchTrueFalseTotal
if ($declares_loop_var) { } 732 2 734
1537 # Loop variable is scoped to body only when declared in header.
1538 732 $self->_push_scope;
1539 732 ▶ if ( $var ne '^^' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var ne "^^") 732 0 732
1540 732 ▶ $self->_declare(
Branch: 1 branch
BranchTrueFalseTotal
$loop_var_kind eq 'let' ? : 730 2 732
1541 $var,
1542 {
1543 kind => $loop_var_kind,
1544 mutable => ( $loop_var_kind eq 'let' ? 1 : 0 ),
1545 },
1546 $id
1547 );
1548 }
1549 732 $body = $self->parse_block;
1550 732 $self->_pop_scope;
1551 }
1552 else {
1553 2 $body = $self->parse_block;
1554 }
1555  
1556 734 my $else_block;
1557 734 ▶ if ($self->{tok}->is_KW && $self->{tok}->value eq 'else') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW and $self->{"tok"}->value eq "else") 17 717 734
Condition100%3/3
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "else"
!ll&&!rl&&r
28243517
MC/DC100%2/2
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "else"
$self->{"tok"}->is_KW $self->{"tok"}->value eq "else"
Truth table100%3/3
A and B
A= $self->{"tok"}->is_KWB= $self->{"tok"}->value eq "else"
ABresult
0X0
100
111
1558 17 $self->_eat('KW', 'else');
1559 17 $else_block = $self->parse_block;
1560 }
1561  
1562 734 return Zuzu::AST::Stmt::For->new(
1563 file => $kw->file, line => $kw->line,
1564 var => $var,
1565 declare_loop_var => $declares_loop_var,
1566 loop_var_kind => $loop_var_kind,
1567 collection => $col,
1568 body => $body,
1569 else_block => $else_block
1570 );
1571 }
1572  
1573 31 ▶sub parse_switch {
Subroutine parse_switch: called CC=9 SCAR=22.1
Pod undocumented
1574 31 my ($self) = @_;
1575  
1576 31 my $kw = $self->_eat('KW', 'switch');
1577 31 $self->_eat('OP', '(');
1578 31 my $value_expr = $self->parse_expression;
1579 30 my $comparator = '==';
1580 30 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ":")) 15 15 30
1581 15 my $tok = $self->{tok};
1582 15 my $operator = $self->_switch_comparator_from_token($tok);
1583 15 ▶ if ( defined $operator ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $operator) { } 15 0 15
1584 15 $comparator = $operator;
1585 15 $self->{tok} = $self->{lexer}->next_token;
1586 }
1587 else {
1588 0 $self->_err("Expected switch comparator operator", $tok);
1589 }
1590 }
1591 30 $self->_eat('OP', ')');
1592 30 $self->_eat('OP', '{');
1593  
1594 30 my @cases;
1595 my $default_block;
1596  
1597 30 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 288 30 318
1598 288 ▶ $self->_err("Unterminated switch", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 0 288 288
1599 288 ▶ if ( $self->{tok}->is_KW('case') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("case")) 281 7 288
1600 281 my $case_kw = $self->_eat('KW', 'case');
1601 281 my @values = ( $self->_parse_switch_case_value );
1602 281 ▶ while ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 24 281 305
1603 24 push @values, $self->_parse_switch_case_value;
1604 }
1605 281 $self->_eat('OP', ':');
1606 281 my $body = $self->_parse_switch_body_until_labels;
1607 281 push @cases, {
1608 file => $case_kw->file,
1609 line => $case_kw->line,
1610 values => \@values,
1611 body => $body,
1612 };
1613 281 next;
1614 }
1615 7 ▶ if ( $self->{tok}->is_KW('default') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("default")) 7 0 7
1616 7 my $default_kw = $self->_eat('KW', 'default');
1617 7 ▶ $self->_err("Duplicate default case in switch", $default_kw) if defined $default_block;
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_block 0 7 7
1618 7 $self->_eat('OP', ':');
1619 7 $default_block = $self->_parse_switch_body_until_end;
1620 7 next;
1621 }
1622 0 $self->_err("Expected 'case', 'default', or '}' in switch", $self->{tok});
1623 }
1624  
1625 30 $self->_eat('OP', '}');
1626  
1627 30 return Zuzu::AST::Stmt::Switch->new(
1628 file => $kw->file,
1629 line => $kw->line,
1630 value_expr => $value_expr,
1631 comparator => $comparator,
1632 cases => \@cases,
1633 default_block => $default_block,
1634 );
1635 }
1636  
1637 305 ▶sub _parse_switch_case_value {
Subroutine _parse_switch_case_value: called CC=6 SCAR=24.6
1638 305 my ($self) = @_;
1639  
1640 305 my $operator = $self->_switch_comparator_from_token($self->{tok});
1641 305 ▶ if ( defined $operator ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $operator) 0 305 305
1642 0 $self->{tok} = $self->{lexer}->next_token;
1643 }
1644 305 my $value;
1645 305 ▶ if ( defined $operator and $operator eq 'can' and ( $self->{tok}->is_IDENT or $self->{tok}->is_KW ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $operator and $operator eq 'can' and $self->{'tok'}->is_IDENT || $self->{'tok'}->is_KW) { } 0 305 305
Condition22%2/9
defined $operator and $operator eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
!ll&&!rl&&r
30500
defined $operator and $operator eq "can"
!ll&&!rl&&r
30500
$self->{"tok"}->is_IDENT or $self->{"tok"}->is_KW
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $operator and $operator eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
defined $operator $operator eq "can" $self->{"tok"}->is_IDENT $self->{"tok"}->is_KW
Truth table20%1/5
A and B and C or D
A= defined $operatorB= $operator eq "can"C= $self->{"tok"}->is_IDENTD= $self->{"tok"}->is_KW
ABCDresult
0XXX0
10XX0
11000
111X1
11011
1646 0 my $name_tok = $self->{tok};
1647 0 $self->{tok} = $self->{lexer}->next_token;
1648 0 $value = Zuzu::AST::Expr::Literal->new(
1649 file => $name_tok->file,
1650 line => $name_tok->line,
1651 value => $name_tok->value,
1652 );
1653 }
1654 else {
1655 305 $value = $self->parse_expression;
1656 }
1657  
1658 return {
1659 305 operator => $operator,
1660 value => $value,
1661 };
1662 }
1663  
1664 320 ▶sub _switch_comparator_from_token {
Subroutine _switch_comparator_from_token: called CC=5 SCAR=16.2
1665 320 my ( $self, $tok ) = @_;
1666  
1667 320 ▶ return if !$tok;
Branch: 1 branch
BranchTrueFalseTotal
unless $tok 0 320 320
1668 320 ▶ return if !( $tok->is_OP or $tok->is_KW );
Branch: 1 branch
BranchTrueFalseTotal
unless $tok->is_OP or $tok->is_KW 305 15 320
Condition100%3/3
$tok->is_OP or $tok->is_KW
l!l&&r!l&&!r
312305
MC/DC100%2/2
$tok->is_OP or $tok->is_KW
$tok->is_OP $tok->is_KW
Truth table100%3/3
A or B
A= $tok->is_OPB= $tok->is_KW
ABresult
1X1
011
000
1669 15 my $value = $tok->value;
1670 15 ▶ return _is_switch_comparator($value) ? $value : undef;
Branch: 1 branch
BranchTrueFalseTotal
_is_switch_comparator($value) ? : 15 0 15
1671 }
1672  
1673 15 ▶sub _is_switch_comparator {
Subroutine _is_switch_comparator: called CC=1 SCAR=0.0
1674 15 my ($value) = @_;
1675  
1676 return !!{
1677 690 map { $_ => 1 } qw(
1678 > < >= ≤ <= ≥ = != ≠ == ≡ ≢ <=> ≶ ≷
1679 eq ne gt ge lt le cmp eqi nei gti gei lti lei cmpi
1680 in ∈ ∉ subsetof ⊂ supersetof ⊃ equivalentof ⊂⊃
1681 instanceof does can ~ @? ∣ divides ∤
1682 )
1683 15 }->{$value};
1684 }
1685  
1686 281 ▶sub _parse_switch_body_until_labels {
Subroutine _parse_switch_body_until_labels: called CC=9 SCAR=22.1
1687 281 my ($self) = @_;
1688  
1689 281 my @stmts;
1690 281 while ( 1 ) {
1691 568 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 23 545 568
1692 545 ▶ last if $self->{tok}->is_KW('case');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_KW("case") 251 294 545
1693 294 ▶ last if $self->{tok}->is_KW('default');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_KW("default") 7 287 294
1694 287 $self->_eat_optional_statement_separators;
1695 287 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 287 287
1696 287 ▶ last if $self->{tok}->is_KW('case');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_KW("case") 0 287 287
1697 287 ▶ last if $self->{tok}->is_KW('default');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_KW("default") 0 287 287
1698 287 push @stmts, $self->parse_statement;
1699 }
1700  
1701 return Zuzu::AST::Block->new(
1702 file => @stmts ? $stmts[0]->file : $self->{tok}->file,
1703 line => @stmts ? $stmts[0]->line : $self->{tok}->line,
1704 281 ▶ statements => \@stmts,
Branch: 2 branches
BranchTrueFalseTotal
@stmts ? : 280 1 281
@stmts ? : 280 1 281
1705 );
1706 }
1707  
1708 7 ▶sub _parse_switch_body_until_end {
Subroutine _parse_switch_body_until_end: called CC=6 SCAR=18.6
1709 7 my ($self) = @_;
1710  
1711 7 my @stmts;
1712 7 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 7 7 14
1713 7 ▶ $self->_err("Unterminated switch", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 0 7 7
1714 7 $self->_eat_optional_statement_separators;
1715 7 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 7 7
1716 7 push @stmts, $self->parse_statement;
1717 }
1718  
1719 return Zuzu::AST::Block->new(
1720 file => @stmts ? $stmts[0]->file : $self->{tok}->file,
1721 line => @stmts ? $stmts[0]->line : $self->{tok}->line,
1722 7 ▶ statements => \@stmts,
Branch: 2 branches
BranchTrueFalseTotal
@stmts ? : 7 0 7
@stmts ? : 7 0 7
1723 );
1724 }
1725  
1726 154 ▶sub parse_try {
Subroutine parse_try: called CC=8 SCAR=21.3
Pod undocumented
1727 154 my ( $self ) = @_;
1728  
1729 154 my $kw = $self->_eat('KW', 'try');
1730 154 my $block = $self->parse_block;
1731 153 my @catches;
1732 153 ▶ while ( $self->_maybe('KW', 'catch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("KW", "catch")) 155 153 308
1733 155 my ( $type_expr, $name );
1734 155 ▶ if ( $self->_maybe('OP', '(') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '(')) { } 69 86 155
1735 69 ▶ if ( $self->_maybe('OP', ')') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ')')) { } 0 69 69
1736 0 $type_expr = Zuzu::AST::Expr::TypeRef->new(
1737 file => $kw->file,
1738 line => $kw->line,
1739 root => 'Exception',
1740 member => undef,
1741 );
1742 0 $name = 'e';
1743 }
1744 else {
1745 69 my $first = $self->_eat('IDENT');
1746 69 ▶ if ( $self->_maybe('OP', ')') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ')')) { } 1 68 69
1747 1 $type_expr = Zuzu::AST::Expr::TypeRef->new(
1748 file => $first->file,
1749 line => $first->line,
1750 root => 'Exception',
1751 member => undef,
1752 );
1753 1 $name = $first->value;
1754 }
1755 else {
1756 68 my $info = $self->_lookup( $first->value );
1757 68 ▶ if ( !$info and !$self->_has_wildcard_import_in_scope ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info or $self->_has_wildcard_import_in_scope) 0 68 68
Condition33%1/3
$info or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
6800
MC/DC0%0/2
$info or $self->_has_wildcard_import_in_scope
$info $self->_has_wildcard_import_in_scope
Truth table33%1/3
A or B
A= $infoB= $self->_has_wildcard_import_in_scope
ABresult
1X1
011
000
1758 0 $self->_err("Use of undeclared identifier '".$first->value."' (compile-time)", $first);
1759 }
1760 68 $type_expr = Zuzu::AST::Expr::TypeRef->new(
1761 file => $first->file,
1762 line => $first->line,
1763 root => $first->value,
1764 member => undef,
1765 );
1766 68 $name = $self->_eat('IDENT')->value;
1767 68 $self->_eat('OP', ')');
1768 }
1769 }
1770 }
1771 else {
1772 86 $type_expr = Zuzu::AST::Expr::TypeRef->new(
1773 file => $kw->file,
1774 line => $kw->line,
1775 root => 'Exception',
1776 member => undef,
1777 );
1778 86 $name = 'e';
1779 }
1780 155 $self->_push_scope;
1781 155 $self->_declare($name, { kind => 'let', mutable => 1 }, $kw);
1782 155 my $catch_block = $self->parse_block;
1783 155 $self->_pop_scope;
1784 155 push @catches, Zuzu::AST::Stmt::Catch->new(
1785 file => $kw->file,
1786 line => $kw->line,
1787 type_expr => $type_expr,
1788 name => $name,
1789 block => $catch_block,
1790 );
1791 }
1792  
1793 153 ▶ $self->_err("try requires at least one catch clause", $self->{tok}) if !@catches;
Branch: 1 branch
BranchTrueFalseTotal
unless @catches 0 153 153
1794  
1795 153 return Zuzu::AST::Stmt::Try->new(
1796 file => $kw->file,
1797 line => $kw->line,
1798 block => $block,
1799 catches => \@catches,
1800 );
1801 }
1802  
1803 5299 ▶sub parse_return {
Subroutine parse_return: called CC=6 SCAR=18.1
Pod documented
1804 5299 my ($self) = @_;
1805  
1806 5299 my $kw = $self->_eat('KW', 'return');
1807 5299 my $expr;
1808 $expr = $self->parse_expression unless (
1809 $self->{tok}->is_OP(';')
1810 or $self->{tok}->is_OP('}')
1811 or $self->{tok}->is_EOF
1812 or $self->{tok}->is_KW('if')
1813 5299 ▶ or $self->{tok}->is_KW('unless')
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF or $self->{"tok"}->is_KW("if") or $self->{"tok"}->is_KW("unless") 5187 112 5299
Condition75%9/12
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF or $self->{"tok"}->is_KW("if") or $self->{"tok"}->is_KW("unless")
l!l&&r!l&&!r
11205187
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF or $self->{"tok"}->is_KW("if")
l!l&&r!l&&!r
11205187
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF
l!l&&r!l&&!r
11205187
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}")
l!l&&r!l&&!r
11115187
MC/DC40%2/5
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF or $self->{"tok"}->is_KW("if") or $self->{"tok"}->is_KW("unless")
$self->{"tok"}->is_OP(";") $self->{"tok"}->is_OP("}") $self->{"tok"}->is_EOF $self->{"tok"}->is_KW("if") $self->{"tok"}->is_KW("unless")
Truth table50%3/6
A or B or C or D or E
A= $self->{"tok"}->is_OP(";")B= $self->{"tok"}->is_OP("}")C= $self->{"tok"}->is_EOFD= $self->{"tok"}->is_KW("if")E= $self->{"tok"}->is_KW("unless")
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
1814 );
1815 5299 my $stmt = Zuzu::AST::Stmt::Return->new(file => $kw->file, line => $kw->line, expr => $expr);
1816  
1817 5299 return $self->_finish_with_postfix_condition($stmt);
1818 }
1819  
1820 711 ▶sub parse_import {
Subroutine parse_import: called CC=19 SCAR=29.5
Pod documented
1821 711 my ($self) = @_;
1822  
1823 711 my $kw = $self->_eat('KW', 'from');
1824 711 my $mod_tok = $self->_eat('IDENT');
1825 711 my $module = $mod_tok->value;
1826  
1827 711 ▶ while ($self->_maybe('OP', '/')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "/")) 1116 710 1826
1828 1116 ▶ if ( $self->{tok}->is_OP and $self->{tok}->value eq '.' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq ".") 1 1115 1116
Condition66%2/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "."
!ll&&!rl&&r
111501
MC/DC50%1/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "."
$self->{"tok"}->is_OP $self->{"tok"}->value eq "."
Truth table66%2/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "."
ABresult
0X0
100
111
1829 $self->_err(
1830 "Import module path cannot contain '..' segments",
1831 $self->{tok},
1832 1 );
1833 }
1834 1115 my $seg = $self->_eat_import_path_segment;
1835 1115 $module .= '/' . $seg->value;
1836 }
1837  
1838 710 ▶ my $try_mode = $self->_maybe('KW', 'try') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->_maybe('KW', 'try') ? : 18 692 710
1839 710 $self->_eat('KW', 'import');
1840  
1841 710 my @items;
1842 710 my $saw_star = 0;
1843 710 while (1) {
1844 1234 ▶ if ( $self->_maybe('OP', '*') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '*')) { } 208 1026 1234
1845 208 push @items, { star => 1 };
1846 208 $saw_star = 1;
1847 }
1848 else {
1849 1026 my $name = $self->_eat('IDENT')->value;
1850 1026 my $alias = $name;
1851 1026 ▶ if ( $self->{tok}->is_KW and $self->{tok}->value eq 'as' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW and $self->{"tok"}->value eq "as") 51 975 1026
Condition100%3/3
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "as"
!ll&&!rl&&r
972351
MC/DC100%2/2
$self->{"tok"}->is_KW and $self->{"tok"}->value eq "as"
$self->{"tok"}->is_KW $self->{"tok"}->value eq "as"
Truth table100%3/3
A and B
A= $self->{"tok"}->is_KWB= $self->{"tok"}->value eq "as"
ABresult
0X0
100
111
1852 51 $self->_eat('KW', 'as');
1853 51 $alias = $self->_eat('IDENT')->value;
1854 }
1855 1026 push @items, { name => $name, alias => $alias };
1856 }
1857 1234 ▶ last if !$self->_maybe('OP', ',');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", ",") 710 524 1234
1858 524 ▶ next if $self->{tok}->is_OP and $self->{tok}->value eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP and $self->{"tok"}->value eq ";" 0 524 524
Condition33%1/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq ";"
!ll&&!rl&&r
52400
MC/DC0%0/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq ";"
$self->{"tok"}->is_OP $self->{"tok"}->value eq ";"
Truth table33%1/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq ";"
ABresult
0X0
100
111
1859 }
1860  
1861 710 my $condition_expr;
1862 710 my $condition_positive = 1;
1863 710 ▶ if ( $self->{tok}->is_KW('if') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_KW('if')) { } 3 707 710
elsif ($self->{'tok'}->is_KW('unless')) { } 1 706 707
1864 3 $self->_eat('KW', 'if');
1865 3 $condition_expr = $self->parse_expression;
1866 }
1867 elsif ( $self->{tok}->is_KW('unless') ) {
1868 1 $self->_eat('KW', 'unless');
1869 1 $condition_positive = 0;
1870 1 $condition_expr = $self->parse_expression;
1871 }
1872  
1873 710 ▶ if ( $saw_star and ( $try_mode or defined $condition_expr ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_star and $try_mode || defined $condition_expr) 2 708 710
Condition100%6/6
$saw_star and $try_mode || defined $condition_expr
!ll&&!rl&&r
5022062
$try_mode or defined $condition_expr
l!l&&r!l&&!r
11206
MC/DC100%3/3
$saw_star and $try_mode || defined $condition_expr
$saw_star $try_mode defined $condition_expr
Truth table100%4/4
A and B or C
A= $saw_starB= $try_modeC= defined $condition_expr
ABCresult
0XX0
1000
11X1
1011
1874 $self->_err(
1875 "Wildcard import '*' cannot be combined with try import or postfix if/unless",
1876 $self->{tok},
1877 2 );
1878 }
1879  
1880 708 ▶ $self->_mark_wildcard_import_in_scope if $saw_star;
Branch: 1 branch
BranchTrueFalseTotal
if $saw_star 206 502 708
1881 708 $self->_eat_statement_separator;
1882  
1883 # Declare imported aliases at compile-time as "import" (mutable depends on source at runtime)
1884 707 for my $it (@items) {
1885 1231 ▶ next if $it->{star};
Branch: 1 branch
BranchTrueFalseTotal
if $it->{"star"} 205 1026 1231
1886 $self->_declare(
1887 $it->{alias},
1888 1026 { kind => 'import', mutable => 1 },
1889 $kw,
1890 { allow_builtin_shadow => 1 },
1891 );
1892 }
1893  
1894 707 return Zuzu::AST::Stmt::Import->new(
1895 file => $kw->file,
1896 line => $kw->line,
1897 module => $module,
1898 items => \@items,
1899 try_mode => $try_mode,
1900 condition_expr => $condition_expr,
1901 condition_positive => $condition_positive,
1902 );
1903 }
1904  
1905 1115 ▶sub _eat_import_path_segment {
Subroutine _eat_import_path_segment: called CC=3 SCAR=11.4
1906 1115 my ( $self ) = @_;
1907  
1908 return $self->_eat('IDENT')
1909 1115 ▶ if $self->{tok}->is_IDENT;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_IDENT 1113 2 1115
1910 return $self->_eat('KW')
1911 2 ▶ if $self->{tok}->is_KW;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_KW 2 0 2
1912  
1913 0 return $self->_eat('IDENT');
1914 }
1915  
1916 # Expression parsing (Pratt)
1917  
1918 59644 ▶sub parse_expression {
Subroutine parse_expression: called CC=23 SCAR=31.4
Pod documented
1919 59644 my ($self) = @_;
1920  
1921 59644 my $cond = $self->parse_chain_expression;
1922  
1923 59544 ▶ my $assign_op = $self->_maybe('OP', ':=')
Condition100%30/30
$self->_maybe('OP', ':=') || $self->_maybe('OP', '~=') || $self->_maybe('OP', '+=') || $self->_maybe('OP', '-=') || $self->_maybe('OP', '*=') || $self->_maybe('OP', "\327=") || $self->_maybe('OP', '/=') || $self->_maybe('OP', "\367=") || $self->_maybe('OP', '**=') || $self->_maybe('OP', '_=') || $self->_maybe('OP', '?:=')
l!l&&r!l&&!r
22271457303
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=") or $self->_maybe("OP", "\x{d7}=") or $self->_maybe("OP", "/=") or $self->_maybe("OP", "\x{f7}=") or $self->_maybe("OP", "**=") or $self->_maybe("OP", "_=")
l!l&&r!l&&!r
179443357317
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=") or $self->_maybe("OP", "\x{d7}=") or $self->_maybe("OP", "/=") or $self->_maybe("OP", "\x{f7}=") or $self->_maybe("OP", "**=")
l!l&&r!l&&!r
1790457750
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=") or $self->_maybe("OP", "\x{d7}=") or $self->_maybe("OP", "/=") or $self->_maybe("OP", "\x{f7}=")
l!l&&r!l&&!r
1789157754
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=") or $self->_maybe("OP", "\x{d7}=") or $self->_maybe("OP", "/=")
l!l&&r!l&&!r
1784557755
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=") or $self->_maybe("OP", "\x{d7}=")
l!l&&r!l&&!r
1783157760
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=")
l!l&&r!l&&!r
1778557761
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=")
l!l&&r!l&&!r
1772657766
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=")
l!l&&r!l&&!r
160616657772
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=")
l!l&&r!l&&!r
1598857938
MC/DC100%11/11
$self->_maybe('OP', ':=') || $self->_maybe('OP', '~=') || $self->_maybe('OP', '+=') || $self->_maybe('OP', '-=') || $self->_maybe('OP', '*=') || $self->_maybe('OP', "\327=") || $self->_maybe('OP', '/=') || $self->_maybe('OP', "\367=") || $self->_maybe('OP', '**=') || $self->_maybe('OP', '_=') || $self->_maybe('OP', '?:=')
$self->_maybe("OP", ":=") $self->_maybe("OP", "~=") $self->_maybe("OP", "+=") $self->_maybe("OP", "-=") $self->_maybe("OP", "*=") $self->_maybe("OP", "\x{d7}=") $self->_maybe("OP", "/=") $self->_maybe("OP", "\x{f7}=") $self->_maybe("OP", "**=") $self->_maybe("OP", "_=") $self->_maybe('OP', '?:=')
Truth table100%12/12
A or B or C or D or E or F or G or H or I or J || K
A= $self->_maybe("OP", ":=")B= $self->_maybe("OP", "~=")C= $self->_maybe("OP", "+=")D= $self->_maybe("OP", "-=")E= $self->_maybe("OP", "*=")F= $self->_maybe("OP", "\x{d7}=")G= $self->_maybe("OP", "/=")H= $self->_maybe("OP", "\x{f7}=")I= $self->_maybe("OP", "**=")J= $self->_maybe("OP", "_=")K= $self->_maybe('OP', '?:=')
ABCDEFGHIJKresult
1XXXXXXXXXX1
01XXXXXXXXX1
001XXXXXXXX1
0001XXXXXXX1
00001XXXXXX1
000001XXXXX1
0000001XXXX1
00000001XXX1
000000001XX1
0000000001X1
000000000011
000000000000
1924 || $self->_maybe('OP', '~=')
1925 || $self->_maybe('OP', '+=')
1926 || $self->_maybe('OP', '-=')
1927 || $self->_maybe('OP', '*=')
1928 || $self->_maybe('OP', '×=')
1929 || $self->_maybe('OP', '/=')
1930 || $self->_maybe('OP', '÷=')
1931 || $self->_maybe('OP', '**=')
1932 || $self->_maybe('OP', '_=')
1933 || $self->_maybe('OP', '?:=');
1934 59544 ▶ if ( $assign_op ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op) 2241 57303 59544
1935 2241 $self->_assert_mutable_target( $cond, $assign_op );
1936 2236 ▶ if ( $assign_op->value eq '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op->value eq "~=") 8 2228 2236
1937 8 my $match_expr = $self->parse_expression;
1938 8 ▶ my $arrow = $self->_maybe( 'OP', '->' ) || $self->_maybe( 'OP', '→' );
Condition66%2/3
$self->_maybe('OP', '->') || $self->_maybe('OP', "\x{2192}")
l!l&&r!l&&!r
530
MC/DC0%0/2
$self->_maybe('OP', '->') || $self->_maybe('OP', "\x{2192}")
$self->_maybe('OP', '->') $self->_maybe('OP', "\x{2192}")
Truth table66%2/3
A || B
A= $self->_maybe('OP', '->')B= $self->_maybe('OP', "\x{2192}")
ABresult
1X1
011
000
1939 8 ▶ $self->_err( "Regexp replacement expects '->' or '→'", $self->{tok} ) if ! $arrow;
Branch: 1 branch
BranchTrueFalseTotal
unless $arrow 0 8 8
1940 8 $self->_push_scope;
1941 8 $self->_declare( 'm', { mutable => 0 }, $arrow );
1942 8 my $replace_expr = $self->parse_expression;
1943 8 $self->_pop_scope;
1944  
1945 8 return Zuzu::AST::Stmt::Assign->new(
1946 file => $assign_op->file,
1947 line => $assign_op->line,
1948 target => $cond,
1949 op => $assign_op->value,
1950 match_expr => $match_expr,
1951 replace_expr => $replace_expr,
1952 );
1953 }
1954 2228 my $rhs = $self->parse_expression;
1955 2228 my $is_weak_write = $self->_parse_optional_weak_modifier('assignment');
1956 2228 ▶ if ( $is_weak_write and $assign_op->value ne ':=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak_write and $assign_op->value ne ":=") 3 2225 2228
Condition100%3/3
$is_weak_write and $assign_op->value ne ":="
!ll&&!rl&&r
2206193
MC/DC100%2/2
$is_weak_write and $assign_op->value ne ":="
$is_weak_write $assign_op->value ne ":="
Truth table100%3/3
A and B
A= $is_weak_writeB= $assign_op->value ne ":="
ABresult
0X0
100
111
1957 3 $self->_err("but weak is only valid on ':=' assignments", $assign_op);
1958 }
1959 2225 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op and $cond->op eq "\@?") 1 2224 2225
Condition83%10/12
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op and $cond->op eq "\@?"
!ll&&!rl&&r
222041
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op
!ll&&!rl&&r
222005
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary")
!ll&&!rl&&r
2206145
$is_weak_write and builtin::blessed($cond)
!ll&&!rl&&r
2206019
MC/DC60%3/5
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op and $cond->op eq "\@?"
$is_weak_write builtin::blessed($cond) $cond->isa("Zuzu::AST::Expr::Binary") defined $cond->op $cond->op eq "\@?"
Truth table66%4/6
A and B and C and D and E
A= $is_weak_writeB= builtin::blessed($cond)C= $cond->isa("Zuzu::AST::Expr::Binary")D= defined $cond->opE= $cond->op eq "\@?"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1960 $is_weak_write
1961 and blessed($cond)
1962 and $cond->isa('Zuzu::AST::Expr::Binary')
1963 and defined $cond->op
1964 and $cond->op eq '@?'
1965 ) {
1966 1 $self->_err("but weak is not valid on @? path assignments", $assign_op);
1967 }
1968  
1969 2224 ▶ return Zuzu::AST::Stmt::Assign->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_write ? : 18 2206 2224
1970 file => $assign_op->file,
1971 line => $assign_op->line,
1972 target => $cond,
1973 op => $assign_op->value,
1974 expr => $rhs,
1975 is_weak_write => $is_weak_write ? 1 : 0,
1976 );
1977 }
1978  
1979 57303 return $cond;
1980 }
1981  
1982 59674 ▶sub parse_ternary_expression {
Subroutine parse_ternary_expression: called CC=3 SCAR=11.0
Pod undocumented
1983 59674 my ($self) = @_;
1984  
1985 59674 my $cond = $self->_parse_prec(0);
1986  
1987 59574 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?")) 576 58998 59574
1988 576 my $if_true = $self->parse_expression;
1989 576 $self->_eat('OP', ':');
1990 576 my $if_false = $self->parse_expression;
1991  
1992 576 return Zuzu::AST::Expr::Ternary->new(
1993 file => $cond->file,
1994 line => $cond->line,
1995 cond => $cond,
1996 if_true => $if_true,
1997 if_false => $if_false,
1998 );
1999 }
2000  
2001 58998 ▶ if ( $self->_maybe('OP', '?:') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?:")) 23 58975 58998
2002 23 my $if_false = $self->parse_expression;
2003  
2004 23 return Zuzu::AST::Expr::Ternary->new(
2005 file => $cond->file,
2006 line => $cond->line,
2007 cond => $cond,
2008 if_true => undef,
2009 if_false => $if_false,
2010 );
2011 }
2012  
2013 58975 return $cond;
2014 }
2015  
2016 57909 ▶sub _chain_direction {
Subroutine _chain_direction: called CC=5 SCAR=16.1
2017 57909 my ( $self, $op ) = @_;
2018  
2019 57909 ▶ return 'right' if $op eq '▷' or $op eq '|>';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25b7}" or $op eq "|>" 27 57882 57909
Condition100%3/3
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
19857882
MC/DC100%2/2
$op eq "\x{25b7}" or $op eq "|>"
$op eq "\x{25b7}" $op eq "|>"
Truth table100%3/3
A or B
A= $op eq "\x{25b7}"B= $op eq "|>"
ABresult
1X1
011
000
2020 57882 ▶ return 'left' if $op eq '◁' or $op eq '<|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25c1}" or $op eq "<|" 3 57879 57882
Condition66%2/3
$op eq "\x{25c1}" or $op eq "<|"
l!l&&r!l&&!r
0357879
MC/DC50%1/2
$op eq "\x{25c1}" or $op eq "<|"
$op eq "\x{25c1}" $op eq "<|"
Truth table66%2/3
A or B
A= $op eq "\x{25c1}"B= $op eq "<|"
ABresult
1X1
011
000
2021  
2022 57879 return undef;
2023 }
2024  
2025 59644 ▶sub parse_chain_expression {
Subroutine parse_chain_expression: called CC=11 SCAR=24.1
Pod undocumented
2026 59644 my ($self) = @_;
2027  
2028 59644 my $left = $self->parse_ternary_expression;
2029 59546 my $op_tok = $self->{tok};
2030 59546 ▶ return $left if !$op_tok->is_OP;
Branch: 1 branch
BranchTrueFalseTotal
unless $op_tok->is_OP 1668 57878 59546
2031  
2032 57878 my $direction = $self->_chain_direction( $op_tok->value );
2033 57878 ▶ return $left if !$direction;
Branch: 1 branch
BranchTrueFalseTotal
unless $direction 57863 15 57878
2034  
2035 15 $self->{tok} = $self->{lexer}->next_token;
2036 15 ▶ my $right = $direction eq 'left'
Branch: 1 branch
BranchTrueFalseTotal
$direction eq 'left' ? : 3 12 15
2037 ? $self->_parse_leftward_chain_rhs
2038 : $self->parse_ternary_expression;
2039 15 $left = Zuzu::AST::Expr::Binary->new(
2040 file => $op_tok->file,
2041 line => $op_tok->line,
2042 op => $op_tok->value,
2043 left => $left,
2044 right => $right,
2045 );
2046  
2047 15 ▶ while ( $direction eq 'right' and $self->{tok}->is_OP ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($direction eq "right" and $self->{"tok"}->is_OP) 25 3 28
Condition66%2/3
$direction eq "right" and $self->{"tok"}->is_OP
!ll&&!rl&&r
3025
MC/DC50%1/2
$direction eq "right" and $self->{"tok"}->is_OP
$direction eq "right" $self->{"tok"}->is_OP
Truth table66%2/3
A and B
A= $direction eq "right"B= $self->{"tok"}->is_OP
ABresult
0X0
100
111
2048 25 my $next_dir = $self->_chain_direction( $self->{tok}->value );
2049 25 ▶ last if !$next_dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $next_dir 10 15 25
2050 $self->_err("Mixed chain directions require parentheses", $self->{tok})
2051 15 ▶ if $next_dir ne $direction;
Branch: 1 branch
BranchTrueFalseTotal
if $next_dir ne $direction 0 15 15
2052 15 $op_tok = $self->{tok};
2053 15 $self->{tok} = $self->{lexer}->next_token;
2054 15 $right = $self->parse_ternary_expression;
2055 13 $left = Zuzu::AST::Expr::Binary->new(
2056 file => $op_tok->file,
2057 line => $op_tok->line,
2058 op => $op_tok->value,
2059 left => $left,
2060 right => $right,
2061 );
2062 }
2063  
2064 13 ▶ if ( $direction eq 'left' and $self->{tok}->is_OP ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($direction eq "left" and $self->{"tok"}->is_OP) 3 10 13
Condition66%2/3
$direction eq "left" and $self->{"tok"}->is_OP
!ll&&!rl&&r
1003
MC/DC50%1/2
$direction eq "left" and $self->{"tok"}->is_OP
$direction eq "left" $self->{"tok"}->is_OP
Truth table66%2/3
A and B
A= $direction eq "left"B= $self->{"tok"}->is_OP
ABresult
0X0
100
111
2065 3 my $next_dir = $self->_chain_direction( $self->{tok}->value );
2066 $self->_err("Mixed chain directions require parentheses", $self->{tok})
2067 3 ▶ if defined $next_dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $next_dir 0 3 3
2068 }
2069  
2070 13 return $left;
2071 }
2072  
2073 3 ▶sub _parse_leftward_chain_rhs {
Subroutine _parse_leftward_chain_rhs: called CC=4 SCAR=17.9
2074 3 my ($self) = @_;
2075  
2076 3 my $left = $self->parse_ternary_expression;
2077 3 my $op_tok = $self->{tok};
2078 3 ▶ return $left if !$op_tok->is_OP;
Branch: 1 branch
BranchTrueFalseTotal
unless $op_tok->is_OP 0 3 3
2079  
2080 3 my $direction = $self->_chain_direction( $op_tok->value );
2081 3 ▶ return $left if !$direction;
Branch: 1 branch
BranchTrueFalseTotal
unless $direction 3 0 3
2082 0 ▶ $self->_err("Mixed chain directions require parentheses", $op_tok)
Branch: 1 branch
BranchTrueFalseTotal
if $direction ne "left" 0 0 0
2083 if $direction ne 'left';
2084  
2085 0 $self->{tok} = $self->{lexer}->next_token;
2086 0 my $right = $self->_parse_leftward_chain_rhs;
2087  
2088 0 return Zuzu::AST::Expr::Binary->new(
2089 file => $op_tok->file,
2090 line => $op_tok->line,
2091 op => $op_tok->value,
2092 left => $left,
2093 right => $right,
2094 );
2095 }
2096  
2097 17855 ▶sub _prec {
Subroutine _prec: called CC=104 SCAR=49.2
2098 17855 my ($self, $op) = @_;
2099  
2100 17855 ▶ return 1 if $op eq 'or' || $op eq '⋁' || $op eq 'or?' || $op eq '⋁?';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?" 1092 16763 17855
Condition77%7/9
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?"
l!l&&r!l&&!r
1092016763
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?"
l!l&&r!l&&!r
10751716763
$op eq "or" or $op eq "\x{22c1}"
l!l&&r!l&&!r
1075016780
MC/DC50%2/4
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?"
$op eq "or" $op eq "\x{22c1}" $op eq "or?" $op eq "\x{22c1}?"
Truth table60%3/5
A or B or C or D
A= $op eq "or"B= $op eq "\x{22c1}"C= $op eq "or?"D= $op eq "\x{22c1}?"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2101  
2102 16763 ▶ return 2 if $op eq 'onlyif' || $op eq '⊨' || $op eq 'onlyif?' || $op eq '⊨?';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?" 0 16763 16763
Condition33%3/9
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?"
l!l&&r!l&&!r
0016763
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
0016763
$op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
0016763
MC/DC0%0/4
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?"
$op eq "onlyif" $op eq "\x{22a8}" $op eq "onlyif?" $op eq "\x{22a8}?"
Truth table20%1/5
A or B or C or D
A= $op eq "onlyif"B= $op eq "\x{22a8}"C= $op eq "onlyif?"D= $op eq "\x{22a8}?"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2103  
2104 16763 ▶ return 3 if $op eq 'xor' || $op eq '⊻' || $op eq 'xor?' || $op eq '⊻?'
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?" 10 16753 16763
Condition69%23/33
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?"
l!l&&r!l&&!r
10016753
$op eq "xor" or $op eq "\x{22bb}"
l!l&&r!l&&!r
8216753
MC/DC16%2/12
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?"
$op eq "xor" $op eq "\x{22bb}" $op eq "xor?" $op eq "\x{22bb}?" $op eq "nor" $op eq "\x{22bd}" $op eq "nor?" $op eq "\x{22bd}?" $op eq "xnor" $op eq "\x{2194}" $op eq "xnor?" $op eq "\x{2194}?"
Truth table23%3/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $op eq "xor"B= $op eq "\x{22bb}"C= $op eq "xor?"D= $op eq "\x{22bb}?"E= $op eq "nor"F= $op eq "\x{22bd}"G= $op eq "nor?"H= $op eq "\x{22bd}?"I= $op eq "xnor"J= $op eq "\x{2194}"K= $op eq "xnor?"L= $op eq "\x{2194}?"
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
2105 || $op eq 'nor' || $op eq '⊽' || $op eq 'nor?' || $op eq '⊽?'
2106 || $op eq 'xnor' || $op eq '↔' || $op eq 'xnor?' || $op eq '↔?';
2107  
2108 16753 ▶ return 4 if $op eq 'and' || $op eq '⋀' || $op eq 'and?' || $op eq '⋀?'
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?" 2047 14706 16753
Condition69%23/33
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}"
l!l&&r!l&&!r
2047014706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand"
l!l&&r!l&&!r
2046114706
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?"
l!l&&r!l&&!r
2046014707
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?"
l!l&&r!l&&!r
2046014707
$op eq "and" or $op eq "\x{22c0}"
l!l&&r!l&&!r
2046014707
MC/DC16%2/12
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?"
$op eq "and" $op eq "\x{22c0}" $op eq "and?" $op eq "\x{22c0}?" $op eq "nand" $op eq "\x{22bc}" $op eq "nand?" $op eq "\x{22bc}?" $op eq "butnot" $op eq "\x{22ad}" $op eq "butnot?" $op eq "\x{22ad}?"
Truth table23%3/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $op eq "and"B= $op eq "\x{22c0}"C= $op eq "and?"D= $op eq "\x{22c0}?"E= $op eq "nand"F= $op eq "\x{22bc}"G= $op eq "nand?"H= $op eq "\x{22bc}?"I= $op eq "butnot"J= $op eq "\x{22ad}"K= $op eq "butnot?"L= $op eq "\x{22ad}?"
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
2109 || $op eq 'nand' || $op eq '⊼' || $op eq 'nand?' || $op eq '⊼?'
2110 || $op eq 'butnot' || $op eq '⊭' || $op eq 'butnot?' || $op eq '⊭?';
2111  
2112 14706 ▶ return 5 if $op eq 'default';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "default" 18 14688 14706
2113  
2114 14688 ▶ return 5 if $op eq '==' || $op eq '≡' || $op eq '!=' || $op eq '≢';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}" 2329 12359 14688
Condition100%9/9
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
l!l&&r!l&&!r
185247712359
$op eq "==" or $op eq "\x{2261}" or $op eq "!="
l!l&&r!l&&!r
17856712836
$op eq "==" or $op eq "\x{2261}"
l!l&&r!l&&!r
309147612903
MC/DC100%4/4
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
$op eq "==" $op eq "\x{2261}" $op eq "!=" $op eq "\x{2262}"
Truth table100%5/5
A or B or C or D
A= $op eq "=="B= $op eq "\x{2261}"C= $op eq "!="D= $op eq "\x{2262}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2115  
2116 12359 ▶ return 6 if $op eq '=' || $op eq '≠' || $op eq '<' || $op eq '>' || $op eq '<=' || $op eq '≤' || $op eq '>=' || $op eq '≥' || $op eq '<=>' || $op eq '≶' || $op eq '≷' || $op eq 'eq' || $op eq 'ne' || $op eq 'gt' || $op eq 'ge' || $op eq 'lt' || $op eq 'le' || $op eq 'cmp' || $op eq 'eqi' || $op eq 'nei' || $op eq 'gti' || $op eq 'gei' || $op eq 'lti' || $op eq 'lei' || $op eq 'cmpi' || $op eq 'in' || $op eq '∈' || $op eq '∉' || $op eq 'subsetof' || $op eq '⊂' || $op eq 'supersetof' || $op eq '⊃' || $op eq 'equivalentof' || $op eq '⊂⊃' || $op eq 'instanceof' || $op eq 'does' || $op eq 'can' || $op eq '~' || $op eq '@' || $op eq '@?' || $op eq '@@' || $op eq '∣' || $op eq 'divides' || $op eq '∤';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@" or $op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}" 4151 8208 12359
Condition89%116/129
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@" or $op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}"
l!l&&r!l&&!r
415108208
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@" or $op eq "\x{2223}" or $op eq "divides"
l!l&&r!l&&!r
415108208
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@" or $op eq "\x{2223}"
l!l&&r!l&&!r
415108208
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@"
l!l&&r!l&&!r
4130218208
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?"
l!l&&r!l&&!r
4114168229
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@"
l!l&&r!l&&!r
4087278245
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~"
l!l&&r!l&&!r
37952928272
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can"
l!l&&r!l&&!r
3746498564
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does"
l!l&&r!l&&!r
374248613
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof"
l!l&&r!l&&!r
27579858617
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}"
l!l&&r!l&&!r
275709602
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof"
l!l&&r!l&&!r
275529602
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}"
l!l&&r!l&&!r
275509604
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof"
l!l&&r!l&&!r
275329604
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}"
l!l&&r!l&&!r
275309606
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof"
l!l&&r!l&&!r
275039606
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}"
l!l&&r!l&&!r
274469609
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}"
l!l&&r!l&&!r
273689615
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in"
l!l&&r!l&&!r
26291079623
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei"
l!l&&r!l&&!r
262909730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi"
l!l&&r!l&&!r
262819730
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp"
l!l&&r!l&&!r
2591379731
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le"
l!l&&r!l&&!r
258749768
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt"
l!l&&r!l&&!r
258169772
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge"
l!l&&r!l&&!r
257839778
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt"
l!l&&r!l&&!r
257539781
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne"
l!l&&r!l&&!r
24391369784
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq"
l!l&&r!l&&!r
18156249920
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}"
l!l&&r!l&&!r
1815010544
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}"
l!l&&r!l&&!r
1814110544
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>"
l!l&&r!l&&!r
18021210545
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}"
l!l&&r!l&&!r
1797510557
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">="
l!l&&r!l&&!r
154725010562
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}"
l!l&&r!l&&!r
1545210812
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<="
l!l&&r!l&&!r
14757010814
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">"
l!l&&r!l&&!r
109338210884
$op eq "=" or $op eq "\x{2260}" or $op eq "<"
l!l&&r!l&&!r
36073311266
$op eq "=" or $op eq "\x{2260}"
l!l&&r!l&&!r
357311999
MC/DC0%0/44
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<=" or $op eq "\x{2264}" or $op eq ">=" or $op eq "\x{2265}" or $op eq "<=>" or $op eq "\x{2276}" or $op eq "\x{2277}" or $op eq "eq" or $op eq "ne" or $op eq "gt" or $op eq "ge" or $op eq "lt" or $op eq "le" or $op eq "cmp" or $op eq "eqi" or $op eq "nei" or $op eq "gti" or $op eq "gei" or $op eq "lti" or $op eq "lei" or $op eq "cmpi" or $op eq "in" or $op eq "\x{2208}" or $op eq "\x{2209}" or $op eq "subsetof" or $op eq "\x{2282}" or $op eq "supersetof" or $op eq "\x{2283}" or $op eq "equivalentof" or $op eq "\x{2282}\x{2283}" or $op eq "instanceof" or $op eq "does" or $op eq "can" or $op eq "~" or $op eq "\@" or $op eq "\@?" or $op eq "\@\@" or $op eq "\x{2223}" or $op eq "divides" or $op eq "\x{2224}"
too many conditions
2117  
2118 8208 ▶ return 7 if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 8 8200 8208
2119  
2120 8200 ▶ return 8 if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 6 8194 8200
2121  
2122 8194 ▶ return 9 if $op eq '&';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "&" 21 8173 8194
2123  
2124 8173 ▶ return 10 if $op eq '<<' || $op eq '«' || $op eq '>>' || $op eq '»';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}" 2 8171 8173
Condition77%7/9
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
l!l&&r!l&&!r
118171
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>"
l!l&&r!l&&!r
108172
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
018172
MC/DC50%2/4
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
$op eq "<<" $op eq "\x{ab}" $op eq ">>" $op eq "\x{bb}"
Truth table60%3/5
A or B or C or D
A= $op eq "<<"B= $op eq "\x{ab}"C= $op eq ">>"D= $op eq "\x{bb}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2125  
2126 8171 ▶ return 11 if $op eq 'union' || $op eq '⋃' || $op eq 'intersection' || $op eq '⋂' || $op eq '\\' || $op eq '∖';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}" or $op eq "\\" or $op eq "\x{2216}" 21 8150 8171
Condition93%14/15
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}" or $op eq "\\" or $op eq "\x{2216}"
l!l&&r!l&&!r
2018150
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}" or $op eq "\\"
l!l&&r!l&&!r
1648151
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}"
l!l&&r!l&&!r
1608155
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection"
l!l&&r!l&&!r
1068155
$op eq "union" or $op eq "\x{22c3}"
l!l&&r!l&&!r
738161
MC/DC83%5/6
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}" or $op eq "\\" or $op eq "\x{2216}"
$op eq "union" $op eq "\x{22c3}" $op eq "intersection" $op eq "\x{22c2}" $op eq "\\" $op eq "\x{2216}"
Truth table85%6/7
A or B or C or D or E or F
A= $op eq "union"B= $op eq "\x{22c3}"C= $op eq "intersection"D= $op eq "\x{22c2}"E= $op eq "\\"F= $op eq "\x{2216}"
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
2127  
2128 8150 ▶ return 12 if $op eq '_' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "_" 2228 5922 8150
2129  
2130 5922 ▶ return 13 if $op eq '+' || $op eq '-' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "+" or $op eq "-" 1164 4758 5922
Condition100%3/3
$op eq "+" or $op eq "-"
l!l&&r!l&&!r
7793854758
MC/DC100%2/2
$op eq "+" or $op eq "-"
$op eq "+" $op eq "-"
Truth table100%3/3
A or B
A= $op eq "+"B= $op eq "-"
ABresult
1X1
011
000
2131  
2132 4758 ▶ return 14 if $op eq '*' || $op eq '/' || $op eq '×' || $op eq '÷' || $op eq 'mod';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}" or $op eq "mod" 248 4510 4758
Condition100%12/12
$op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}" or $op eq "mod"
l!l&&r!l&&!r
189594510
$op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}"
l!l&&r!l&&!r
18544569
$op eq "*" or $op eq "/" or $op eq "\x{d7}"
l!l&&r!l&&!r
165204573
$op eq "*" or $op eq "/"
l!l&&r!l&&!r
125404593
MC/DC100%5/5
$op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}" or $op eq "mod"
$op eq "*" $op eq "/" $op eq "\x{d7}" $op eq "\x{f7}" $op eq "mod"
Truth table100%6/6
A or B or C or D or E
A= $op eq "*"B= $op eq "/"C= $op eq "\x{d7}"D= $op eq "\x{f7}"E= $op eq "mod"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2133  
2134 4510 ▶ return 15 if $op eq '**';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "**" 5 4505 4510
2135  
2136 4505 return 0;
2137 }
2138  
2139 70641 ▶sub _parse_prec {
Subroutine _parse_prec: called CC=24 SCAR=31.8
2140 70641 my ($self, $min_prec) = @_;
2141  
2142 70641 my $t = $self->{tok};
2143 70641 my $left = $self->parse_prefix;
2144  
2145 70541 while (1) {
2146 81540 my $op_tok = $self->{tok};
2147 81540 my $op;
2148  
2149 81540 ▶ if ($op_tok->is_OP || $op_tok->is_KW) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op_tok->is_OP or $op_tok->is_KW) { } 81049 491 81540
Condition100%3/3
$op_tok->is_OP or $op_tok->is_KW
l!l&&r!l&&!r
746386411491
MC/DC100%2/2
$op_tok->is_OP or $op_tok->is_KW
$op_tok->is_OP $op_tok->is_KW
Truth table100%3/3
A or B
A= $op_tok->is_OPB= $op_tok->is_KW
ABresult
1X1
011
000
2150 81049 $op = $op_tok->value;
2151 } else {
2152 491 last;
2153 }
2154  
2155 # stop at statement terminators / closers
2156 81049 ▶ last if $op_tok->is_OP && ($op eq ';' || $op eq ')' || $op eq ']' || $op eq '}' || $op eq ',' || $op eq ':');
Branch: 1 branch
BranchTrueFalseTotal
if $op_tok->is_OP and $op eq ";" || $op eq ")" || $op eq "]" || $op eq "}" || $op eq "," || $op eq ":" 63144 17905 81049
Condition100%18/18
$op_tok->is_OP and $op eq ";" || $op eq ")" || $op eq "]" || $op eq "}" || $op eq "," || $op eq ":"
!ll&&!rl&&r
64111149463144
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq "," or $op eq ":"
l!l&&r!l&&!r
62116102811494
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq ","
l!l&&r!l&&!r
457841633212522
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}"
l!l&&r!l&&!r
4532446028854
$op eq ";" or $op eq ")" or $op eq "]"
l!l&&r!l&&!r
43648167629314
$op eq ";" or $op eq ")"
l!l&&r!l&&!r
208552279330990
MC/DC100%7/7
$op_tok->is_OP and $op eq ";" || $op eq ")" || $op eq "]" || $op eq "}" || $op eq "," || $op eq ":"
$op_tok->is_OP $op eq ";" $op eq ")" $op eq "]" $op eq "}" $op eq "," $op eq ":"
Truth table100%8/8
A and B or C or D or E or F or G
A= $op_tok->is_OPB= $op eq ";"C= $op eq ")"D= $op eq "]"E= $op eq "}"F= $op eq ","G= $op eq ":"
ABCDEFGresult
0XXXXXX0
10000000
11XXXXX1
101XXXX1
1001XXX1
10001XX1
100001X1
10000011
2157  
2158 # Inside << ... >> or « ... » the pending closer terminates the
2159 # set literal rather than acting as a shift operator.
2160 last if $op_tok->is_OP
2161 11494 ▶ && @{ $self->{_pending_set_closers} || [] }
Condition100%2/2
$self->{'_pending_set_closers'} || []
l!l
17211322
MC/DC100%1/1
$self->{'_pending_set_closers'} || []
$self->{'_pending_set_closers'}
Truth table100%2/2
A
A= $self->{'_pending_set_closers'}
Aresult
11
00
2162 17905 ▶ && $op eq $self->{_pending_set_closers}[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];} and $op eq $self->{"_pending_set_closers"}[-1] 50 17855 17905
Condition100%6/6
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];} and $op eq $self->{"_pending_set_closers"}[-1]
!ll&&!rl&&r
17852350
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];}
!ll&&!rl&&r
64111144153
MC/DC100%3/3
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];} and $op eq $self->{"_pending_set_closers"}[-1]
$op_tok->is_OP @{$self->{"_pending_set_closers"} or [];} $op eq $self->{"_pending_set_closers"}[-1]
Truth table100%4/4
A and B and C
A= $op_tok->is_OPB= @{$self->{"_pending_set_closers"} or [];}C= $op eq $self->{"_pending_set_closers"}[-1]
ABCresult
0XX0
10X0
1100
1111
2163  
2164 17855 my $prec = $self->_prec($op);
2165 17855 ▶ last if $prec < $min_prec || $prec == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $prec < $min_prec or $prec == 0 6856 10999 17855
Condition100%3/3
$prec < $min_prec or $prec == 0
l!l&&r!l&&!r
2714414210999
MC/DC100%2/2
$prec < $min_prec or $prec == 0
$prec < $min_prec $prec == 0
Truth table100%3/3
A or B
A= $prec < $min_precB= $prec == 0
ABresult
1X1
011
000
2166  
2167 10999 ▶ my $right_assoc = $op eq '**'
Condition66%8/12
$op eq '**' || $op eq 'onlyif' || $op eq "\x{22a8}" || $op eq 'onlyif?' || $op eq "\x{22a8}?"
l!l&&r!l&&!r
5010994
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
5010994
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
5010994
$op eq "**" or $op eq "onlyif"
l!l&&r!l&&!r
5010994
MC/DC20%1/5
$op eq '**' || $op eq 'onlyif' || $op eq "\x{22a8}" || $op eq 'onlyif?' || $op eq "\x{22a8}?"
$op eq "**" $op eq "onlyif" $op eq "\x{22a8}" $op eq "onlyif?" $op eq "\x{22a8}?"
Truth table33%2/6
A or B or C or D || E
A= $op eq "**"B= $op eq "onlyif"C= $op eq "\x{22a8}"D= $op eq "onlyif?"E= $op eq "\x{22a8}?"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
2168 || $op eq 'onlyif'
2169 || $op eq '⊨'
2170 || $op eq 'onlyif?'
2171 || $op eq '⊨?';
2172 10999 ▶ my $next_min = $right_assoc ? $prec : ($prec + 1);
Branch: 1 branch
BranchTrueFalseTotal
$right_assoc ? : 5 10994 10999
2173  
2174 10999 $self->{tok} = $self->{lexer}->next_token; # consume op
2175 10999 my $right;
2176 10999 ▶ if ( $op eq 'can' and ( $self->{tok}->is_IDENT or $self->{tok}->is_KW ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op eq 'can' and $self->{'tok'}->is_IDENT || $self->{'tok'}->is_KW) { } 32 10967 10999
Condition83%5/6
$op eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
!ll&&!rl&&r
109501732
$self->{"tok"}->is_IDENT or $self->{"tok"}->is_KW
l!l&&r!l&&!r
32017
MC/DC66%2/3
$op eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
$op eq "can" $self->{"tok"}->is_IDENT $self->{"tok"}->is_KW
Truth table75%3/4
A and B or C
A= $op eq "can"B= $self->{"tok"}->is_IDENTC= $self->{"tok"}->is_KW
ABCresult
0XX0
1000
11X1
1011
2177 32 my $name_tok = $self->{tok};
2178 32 $self->{tok} = $self->{lexer}->next_token;
2179 32 $right = Zuzu::AST::Expr::Literal->new(
2180 file => $name_tok->file,
2181 line => $name_tok->line,
2182 value => $name_tok->value,
2183 );
2184 }
2185 else {
2186 10967 $right = $self->_parse_prec($next_min);
2187 }
2188  
2189 10999 $left = Zuzu::AST::Expr::Binary->new(
2190 file => $op_tok->file, line => $op_tok->line,
2191 op => $op, left => $left, right => $right
2192 );
2193 }
2194  
2195 70541 return $left;
2196 }
2197  
2198 72503 ▶sub parse_prefix {
Subroutine parse_prefix: called CC=41 SCAR=37.2
Pod documented
2199 72503 my ($self) = @_;
2200  
2201 72503 my $t = $self->{tok};
2202  
2203 72503 ▶ if ( $t->is_OP and ( $t->value eq '->' or $t->value eq '→' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "->" || $t->value eq "\x{2192}") 6 72497 72503
Condition100%6/6
$t->is_OP and $t->value eq "->" || $t->value eq "\x{2192}"
!ll&&!rl&&r
6898435136
$t->value eq "->" or $t->value eq "\x{2192}"
l!l&&r!l&&!r
333513
MC/DC100%3/3
$t->is_OP and $t->value eq "->" || $t->value eq "\x{2192}"
$t->is_OP $t->value eq "->" $t->value eq "\x{2192}"
Truth table100%4/4
A and B or C
A= $t->is_OPB= $t->value eq "->"C= $t->value eq "\x{2192}"
ABCresult
0XX0
1000
11X1
1011
2204 6 my $arrow = $self->_eat('OP');
2205 6 my $expr = $self->parse_expression;
2206 6 my $ret = Zuzu::AST::Stmt::Return->new(
2207 file => $arrow->file,
2208 line => $arrow->line,
2209 expr => $expr,
2210 );
2211 6 my $body = Zuzu::AST::Block->new(
2212 file => $arrow->file,
2213 line => $arrow->line,
2214 statements => [ $ret ],
2215 );
2216  
2217 6 return Zuzu::AST::Expr::Function->new(
2218 file => $arrow->file,
2219 line => $arrow->line,
2220 params => [ '^^' ],
2221 vararg => undef,
2222 body => $body,
2223 param_types => { '^^' => 'Any' },
2224 vararg_type => 'Any',
2225 named_vararg => undef,
2226 named_vararg_type => 'PairList',
2227 param_optional => { '^^' => 1 },
2228 param_defaults => {},
2229 return_type => 'Any',
2230 is_async => 0,
2231 );
2232 }
2233  
2234 72497 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "+" || $t->value eq "-" || $t->value eq "!" || $t->value eq "\x{ac}" || $t->value eq "~" || $t->value eq "#" || $t->value eq "\x{221a}" || $t->value eq "\\") 138 72359 72497
Condition91%22/24
$t->is_OP and $t->value eq "+" || $t->value eq "-" || $t->value eq "!" || $t->value eq "\x{ac}" || $t->value eq "~" || $t->value eq "#" || $t->value eq "\x{221a}" || $t->value eq "\\"
!ll&&!rl&&r
689843375138
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#" or $t->value eq "\x{221a}" or $t->value eq "\\"
l!l&&r!l&&!r
111273375
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#" or $t->value eq "\x{221a}"
l!l&&r!l&&!r
11103402
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#"
l!l&&r!l&&!r
72393402
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~"
l!l&&r!l&&!r
6393441
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}"
l!l&&r!l&&!r
6303450
$t->value eq "+" or $t->value eq "-" or $t->value eq "!"
l!l&&r!l&&!r
6123450
$t->value eq "+" or $t->value eq "-"
l!l&&r!l&&!r
1603452
MC/DC77%7/9
$t->is_OP and $t->value eq "+" || $t->value eq "-" || $t->value eq "!" || $t->value eq "\x{ac}" || $t->value eq "~" || $t->value eq "#" || $t->value eq "\x{221a}" || $t->value eq "\\"
$t->is_OP $t->value eq "+" $t->value eq "-" $t->value eq "!" $t->value eq "\x{ac}" $t->value eq "~" $t->value eq "#" $t->value eq "\x{221a}" $t->value eq "\\"
Truth table80%8/10
A and B or C or D or E or F or G or H or I
A= $t->is_OPB= $t->value eq "+"C= $t->value eq "-"D= $t->value eq "!"E= $t->value eq "\x{ac}"F= $t->value eq "~"G= $t->value eq "#"H= $t->value eq "\x{221a}"I= $t->value eq "\\"
ABCDEFGHIresult
0XXXXXXXX0
1000000000
11XXXXXXX1
101XXXXXX1
1001XXXXX1
10001XXXX1
100001XXX1
1000001XX1
10000001X1
1000000011
2235 $t->is_OP
2236 and (
2237 $t->value eq '+'
2238 or $t->value eq '-'
2239 or $t->value eq '!'
2240 or $t->value eq '¬'
2241 or $t->value eq '~'
2242 or $t->value eq '#'
2243 or $t->value eq '√'
2244 or $t->value eq '\\'
2245 )
2246 ) {
2247 138 $self->{tok} = $self->{lexer}->next_token;
2248 137 my $expr = $self->parse_prefix;
2249 108 ▶ if ( $t->value eq '\\' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->value eq "\\") 27 81 108
2250 27 $self->_assert_reference_target( $expr, $t );
2251 }
2252  
2253 108 return Zuzu::AST::Expr::Unary->new(file => $t->file, line => $t->line, op => $t->value, expr => $expr);
2254 }
2255 72359 ▶ if ( $t->is_KW and $t->value eq 'not' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW and $t->value eq "not") 1000 71359 72359
Condition100%3/3
$t->is_KW and $t->value eq "not"
!ll&&!rl&&r
6727940801000
MC/DC100%2/2
$t->is_KW and $t->value eq "not"
$t->is_KW $t->value eq "not"
Truth table100%3/3
A and B
A= $t->is_KWB= $t->value eq "not"
ABresult
0X0
100
111
2256 1000 $self->{tok} = $self->{lexer}->next_token;
2257 1000 my $expr = $self->parse_prefix;
2258  
2259 998 return Zuzu::AST::Expr::Unary->new(file => $t->file, line => $t->line, op => 'not', expr => $expr);
2260 }
2261 71359 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 1 71358 71359
Condition66%2/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
1071358
MC/DC50%1/2
$t->is_KW("let") or $t->is_KW("const")
$t->is_KW("let") $t->is_KW("const")
Truth table66%2/3
A or B
A= $t->is_KW("let")B= $t->is_KW("const")
ABresult
1X1
011
000
2262 1 return $self->_parse_let_decl(0);
2263 }
2264 71358 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 23 71335 71358
2265 23 return $self->parse_try;
2266 }
2267 71335 ▶ if ( $t->is_KW('await') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("await")) 112 71223 71335
2268 112 my $kw = $self->_eat( 'KW', 'await' );
2269 $self->_err("await may only be used inside async code", $kw)
2270 112 ▶ if !( $self->{_async_context_depth} // 0 );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_async_context_depth"} // 0 1 111 112
Condition50%1/2
$self->{"_async_context_depth"} // 0
l!l
1120
MC/DC0%0/1
$self->{"_async_context_depth"} // 0
$self->{"_async_context_depth"}
Truth table50%1/2
A
A= $self->{"_async_context_depth"}
Aresult
11
00
2271 111 my $block = $self->parse_block;
2272  
2273 109 return Zuzu::AST::Expr::Await->new(
2274 file => $kw->file,
2275 line => $kw->line,
2276 block => $block,
2277 );
2278 }
2279 71223 ▶ if ( $t->is_KW('spawn') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("spawn")) 17 71206 71223
2280 17 my $kw = $self->_eat( 'KW', 'spawn' );
2281 17 my $block = $self->parse_block;
2282  
2283 17 return Zuzu::AST::Expr::Spawn->new(
2284 file => $kw->file,
2285 line => $kw->line,
2286 block => $block,
2287 );
2288 }
2289 71206 ▶ if ( $t->is_KW('do') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("do")) 8 71198 71206
2290 8 $self->_eat( 'KW', 'do' );
2291  
2292 8 return $self->parse_block;
2293 }
2294 71198 ▶ if ( $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("async")) 7 71191 71198
2295 7 my $kw = $self->_eat( 'KW', 'async' );
2296 $self->_err("Expected function or fn after async", $self->{tok})
2297 if !$self->{tok}->is_KW('function')
2298 7 ▶ and !$self->{tok}->is_KW('fn');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tok"}->is_KW("function") or $self->{"tok"}->is_KW("fn") 0 7 7
Condition33%1/3
$self->{"tok"}->is_KW("function") or $self->{"tok"}->is_KW("fn")
l!l&&r!l&&!r
070
MC/DC0%0/2
$self->{"tok"}->is_KW("function") or $self->{"tok"}->is_KW("fn")
$self->{"tok"}->is_KW("function") $self->{"tok"}->is_KW("fn")
Truth table33%1/3
A or B
A= $self->{"tok"}->is_KW("function")B= $self->{"tok"}->is_KW("fn")
ABresult
1X1
011
000
2299 7 local $self->{_next_function_expr_async} = 1;
2300 7 my $prim = $self->parse_primary;
2301  
2302 7 return $self->parse_postfix($prim);
2303 }
2304 71191 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW and $t->value eq "abs" || $t->value eq "sqrt" || $t->value eq "floor" || $t->value eq "ceil" || $t->value eq "round" || $t->value eq "int" || $t->value eq "uc" || $t->value eq "lc" || $t->value eq "length" || $t->value eq "typeof") 714 70477 71191
Condition100%30/30
$t->is_KW and $t->value eq "abs" || $t->value eq "sqrt" || $t->value eq "floor" || $t->value eq "ceil" || $t->value eq "round" || $t->value eq "int" || $t->value eq "uc" || $t->value eq "lc" || $t->value eq "length" || $t->value eq "typeof"
!ll&&!rl&&r
672793198714
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round" or $t->value eq "int" or $t->value eq "uc" or $t->value eq "lc" or $t->value eq "length" or $t->value eq "typeof"
l!l&&r!l&&!r
667473198
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round" or $t->value eq "int" or $t->value eq "uc" or $t->value eq "lc" or $t->value eq "length"
l!l&&r!l&&!r
2324353245
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round" or $t->value eq "int" or $t->value eq "uc" or $t->value eq "lc"
l!l&&r!l&&!r
144883680
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round" or $t->value eq "int" or $t->value eq "uc"
l!l&&r!l&&!r
122223768
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round" or $t->value eq "int"
l!l&&r!l&&!r
58643790
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil" or $t->value eq "round"
l!l&&r!l&&!r
5083854
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil"
l!l&&r!l&&!r
4733862
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor"
l!l&&r!l&&!r
14333865
$t->value eq "abs" or $t->value eq "sqrt"
l!l&&r!l&&!r
1133898
MC/DC100%11/11
$t->is_KW and $t->value eq "abs" || $t->value eq "sqrt" || $t->value eq "floor" || $t->value eq "ceil" || $t->value eq "round" || $t->value eq "int" || $t->value eq "uc" || $t->value eq "lc" || $t->value eq "length" || $t->value eq "typeof"
$t->is_KW $t->value eq "abs" $t->value eq "sqrt" $t->value eq "floor" $t->value eq "ceil" $t->value eq "round" $t->value eq "int" $t->value eq "uc" $t->value eq "lc" $t->value eq "length" $t->value eq "typeof"
Truth table100%12/12
A and B or C or D or E or F or G or H or I or J or K
A= $t->is_KWB= $t->value eq "abs"C= $t->value eq "sqrt"D= $t->value eq "floor"E= $t->value eq "ceil"F= $t->value eq "round"G= $t->value eq "int"H= $t->value eq "uc"I= $t->value eq "lc"J= $t->value eq "length"K= $t->value eq "typeof"
ABCDEFGHIJKresult
0XXXXXXXXXX0
100000000000
11XXXXXXXXX1
101XXXXXXXX1
1001XXXXXXX1
10001XXXXXX1
100001XXXXX1
1000001XXXX1
10000001XXX1
100000001XX1
1000000001X1
100000000011
2305 $t->is_KW
2306 and (
2307 $t->value eq 'abs'
2308 or $t->value eq 'sqrt'
2309 or $t->value eq 'floor'
2310 or $t->value eq 'ceil'
2311 or $t->value eq 'round'
2312 or $t->value eq 'int'
2313 or $t->value eq 'uc'
2314 or $t->value eq 'lc'
2315 or $t->value eq 'length'
2316 or $t->value eq 'typeof'
2317 )
2318 ) {
2319 714 $self->{tok} = $self->{lexer}->next_token;
2320 714 my $expr = $self->parse_prefix;
2321  
2322 714 return Zuzu::AST::Expr::Unary->new(
2323 file => $t->file,
2324 line => $t->line,
2325 op => $t->value,
2326 expr => $expr,
2327 );
2328 }
2329 70477 ▶ if ($t->is_OP && ($t->value eq '++' || $t->value eq '--')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "++" || $t->value eq "--") 11 70466 70477
Condition83%5/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
67102336411
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
1103364
MC/DC66%2/3
$t->is_OP and $t->value eq "++" || $t->value eq "--"
$t->is_OP $t->value eq "++" $t->value eq "--"
Truth table75%3/4
A and B or C
A= $t->is_OPB= $t->value eq "++"C= $t->value eq "--"
ABCresult
0XX0
1000
11X1
1011
2330 11 $self->{tok} = $self->{lexer}->next_token;
2331 11 my $target = $self->parse_prefix;
2332 11 $self->_assert_mutable_target($target, $t);
2333  
2334 10 return Zuzu::AST::Expr::IncDec->new(
2335 file => $t->file,
2336 line => $t->line,
2337 op => $t->value,
2338 target => $target,
2339 postfix => 0,
2340 );
2341 }
2342  
2343 70466 my $prim = $self->parse_primary;
2344  
2345 70375 return $self->parse_postfix($prim);
2346 }
2347  
2348 71264 ▶sub parse_primary {
Subroutine parse_primary: called CC=74 SCAR=46.3
Pod documented
2349 71264 my ($self) = @_;
2350  
2351 71264 my $t = $self->{tok};
2352  
2353 71264 ▶ if ($t->is_NUMBER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NUMBER) 6439 64825 71264
2354 6439 $self->{tok} = $self->{lexer}->next_token;
2355 6439 my $v = $t->value;
2356 6439 ▶ $v = ($v =~ /\./) ? 0.0 + $v : 0 + $v;
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /\./ ? : 72 6367 6439
2357  
2358 6439 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => $v);
2359 }
2360 64825 ▶ if ($t->is_STRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_STRING) 10806 54019 64825
2361 10806 $self->{tok} = $self->{lexer}->next_token;
2362  
2363 10806 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => $t->value);
2364 }
2365 54019 ▶ if ( $t->is_type('BINARY_STRING') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("BINARY_STRING")) 12 54007 54019
2366 12 $self->{tok} = $self->{lexer}->next_token;
2367  
2368 12 return Zuzu::AST::Expr::Literal->new(
2369 file => $t->file,
2370 line => $t->line,
2371 value => Zuzu::Value::BinaryString->new( bytes => $t->value ),
2372 );
2373 }
2374 54007 ▶ if ( $t->is_type('TEMPLATE') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("TEMPLATE")) 374 53633 54007
2375 374 $self->{tok} = $self->{lexer}->next_token;
2376  
2377 374 return $self->_parse_template_expression($t);
2378 }
2379 53633 ▶ if ($t->is_REGEXP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_REGEXP) 324 53309 53633
2380 324 $self->{tok} = $self->{lexer}->next_token;
2381 324 ▶ my $spec = $t->value // {};
Condition50%1/2
$t->value // {}
l!l
3240
MC/DC0%0/1
$t->value // {}
$t->value
Truth table50%1/2
A
A= $t->value
Aresult
11
00
2382 324 ▶ my $parts = $spec->{parts} // [ { text => $spec->{pattern} // '' } ];
Condition25%1/4
$spec->{"parts"} // [{"text", $spec->{"pattern"} // ""}]
l!l
3240
$spec->{"pattern"} // ""
l!l
00
MC/DC0%0/1
$spec->{"parts"} // [{"text", $spec->{"pattern"} // ""}]
$spec->{"parts"}
MC/DC0%0/1
$spec->{"pattern"} // ""
$spec->{"pattern"}
Truth table50%1/2
A
A= $spec->{"parts"}
Aresult
11
00
Truth table0%0/2
A
A= $spec->{"pattern"}
Aresult
11
00
2383 324 ▶ if ( grep { ref $_ eq 'HASH' and exists $_->{expr} } @{$parts} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {ref $_ eq "HASH" and exists $_->{"expr"};} @{$parts;}) 0 324 324
Condition33%1/3
ref $_ eq 'HASH' && exists $_->{'expr'}
!ll&&!rl&&r
03240
MC/DC0%0/2
ref $_ eq 'HASH' && exists $_->{'expr'}
ref $_ eq 'HASH' exists $_->{'expr'}
Truth table33%1/3
A && B
A= ref $_ eq 'HASH'B= exists $_->{'expr'}
ABresult
0X0
100
111
2384 my @parsed_parts = map {
2385 ref $_ eq 'HASH' && exists $_->{expr}
2386 0 ▶ ? { expr => $self->_parse_embedded_expression( $_->{expr}, $t ) }
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'HASH' && exists $_->{'expr'} ? : 0 0 0
Condition0%0/3
ref $_ eq "HASH" and exists $_->{"expr"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ eq "HASH" and exists $_->{"expr"}
ref $_ eq "HASH" exists $_->{"expr"}
Truth table0%0/3
A and B
A= ref $_ eq "HASH"B= exists $_->{"expr"}
ABresult
0X0
100
111
2387 : $_
2388 0 } @{$parts};
2389 return Zuzu::AST::Expr::Regexp->new(
2390 file => $t->file,
2391 line => $t->line,
2392 parts => \@parsed_parts,
2393 0 ▶ flags => $spec->{flags} // '',
Condition0%0/2
$spec->{"flags"} // ""
l!l
00
MC/DC0%0/1
$spec->{"flags"} // ""
$spec->{"flags"}
Truth table0%0/2
A
A= $spec->{"flags"}
Aresult
11
00
2394 );
2395 }
2396  
2397 return Zuzu::AST::Expr::Literal->new(
2398 file => $t->file,
2399 line => $t->line,
2400 value => Zuzu::Value::Regexp->new(
2401 pattern => $spec->{pattern} // '',
2402 324 ▶ flags => $spec->{flags} // '',
Condition50%2/4
$spec->{"pattern"} // ""
l!l
3240
$spec->{"flags"} // ""
l!l
3240
MC/DC0%0/1
$spec->{"pattern"} // ""
$spec->{"pattern"}
MC/DC0%0/1
$spec->{"flags"} // ""
$spec->{"flags"}
Truth table50%1/2
A
A= $spec->{"pattern"}
Aresult
11
00
Truth table50%1/2
A
A= $spec->{"flags"}
Aresult
11
00
2403 ),
2404 );
2405 }
2406 53309 ▶ if ($t->is_BOOL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_BOOL) 1963 51346 53309
2407 1963 $self->{tok} = $self->{lexer}->next_token;
2408  
2409 1963 ▶ return Zuzu::AST::Expr::Literal->new(
Branch: 1 branch
BranchTrueFalseTotal
$t->value ? : 938 1025 1963
2410 file => $t->file,
2411 line => $t->line,
2412 value => Zuzu::Value::Boolean->new( value => $t->value ? 1 : 0 ),
2413 );
2414 }
2415 51346 ▶ if ($t->is_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NULL) 1824 49522 51346
2416 1824 $self->{tok} = $self->{lexer}->next_token;
2417  
2418 1824 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => undef);
2419 }
2420 49522 ▶ if ($t->is_IDENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_IDENT) 42925 6597 49522
2421 42925 my $id = $self->_eat('IDENT');
2422 42925 my $name = $id->value;
2423 42925 my $info = $self->_lookup($name);
2424 my $is_named_arg_label
2425 = ( $self->{_invocation_arg_depth} // 0 )
2426 42925 ▶ and $self->{tok}->is_OP(':');
Branch: 1 branch
BranchTrueFalseTotal
my $is_named_arg_label = $self->{"_invocation_arg_depth"} // 0 and $self->{"tok"}->is_OP(":") 17139 25786 42925
Condition100%2/2
$self->{"_invocation_arg_depth"} // 0
l!l
413621563
MC/DC100%1/1
$self->{"_invocation_arg_depth"} // 0
$self->{"_invocation_arg_depth"}
Truth table100%2/2
A
A= $self->{"_invocation_arg_depth"}
Aresult
11
00
2427 42925 my $is_chain_placeholder = $name eq '^^';
2428 42925 ▶ if ( !$info and !$is_chain_placeholder and !$self->_has_wildcard_import_in_scope and !$is_named_arg_label ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope or $is_named_arg_label) 36 42889 42925
Condition88%8/9
$info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope or $is_named_arg_label
l!l&&r!l&&!r
42889036
$info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
4270318636
$info or $is_chain_placeholder
l!l&&r!l&&!r
4266043222
MC/DC75%3/4
$info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope or $is_named_arg_label
$info $is_chain_placeholder $self->_has_wildcard_import_in_scope $is_named_arg_label
Truth table80%4/5
A or B or C or D
A= $infoB= $is_chain_placeholderC= $self->_has_wildcard_import_in_scopeD= $is_named_arg_label
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2429 36 $self->_err("Use of undeclared identifier '$name' (compile-time)", $id);
2430 }
2431  
2432 42889 return Zuzu::AST::Expr::Var->new(file => $id->file, line => $id->line, name => $name);
2433 }
2434 6597 ▶ if ($t->is_KW('self')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("self")) 1922 4675 6597
2435 1922 my $id = $self->_eat('KW', 'self');
2436 1922 my $name = $id->value;
2437 1922 my $info = $self->_lookup($name);
2438 1922 ▶ $self->_err("Use of undeclared identifier '$name' (compile-time)", $id) if !$info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 1922 1922
2439  
2440 1922 return Zuzu::AST::Expr::Var->new(file => $id->file, line => $id->line, name => $name);
2441 }
2442 4675 ▶ if ($t->is_KW('super')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("super")) 37 4638 4675
2443 37 my $id = $self->_eat('KW', 'super');
2444 37 my $name = $id->value;
2445 37 my $info = $self->_lookup($name);
2446 37 ▶ $self->_err("Use of undeclared identifier '$name' (compile-time)", $id) if !$info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 37 37
2447  
2448 37 return Zuzu::AST::Expr::Var->new(file => $id->file, line => $id->line, name => $name);
2449 }
2450 4638 ▶ if ($t->is_OP && $t->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "(") 1193 3445 4638
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
127021751193
MC/DC100%2/2
$t->is_OP and $t->value eq "("
$t->is_OP $t->value eq "("
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "("
ABresult
0X0
100
111
2451 1193 $self->_eat('OP', '(');
2452 1193 my $e = $self->parse_expression;
2453 1193 $self->_eat('OP', ')');
2454  
2455 1182 return $e;
2456 }
2457 3445 ▶ if ( $t->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("...")) 3 3442 3445
2458 3 $self->_err("Spread argument '...' is only valid in call argument lists", $t);
2459 }
2460 3442 ▶ if ( $t->is_OP('⌊') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("\x{230a}")) 3 3439 3442
2461 3 my $tok = $self->_eat('OP', '⌊');
2462 3 my $expr = $self->parse_expression;
2463 3 $self->_eat('OP', '⌋');
2464  
2465 3 return Zuzu::AST::Expr::Unary->new(
2466 file => $tok->file,
2467 line => $tok->line,
2468 op => 'floor',
2469 expr => $expr,
2470 );
2471 }
2472 3439 ▶ if ( $t->is_OP('⌈') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("\x{2308}")) 3 3436 3439
2473 3 my $tok = $self->_eat('OP', '⌈');
2474 3 my $expr = $self->parse_expression;
2475 3 $self->_eat('OP', '⌉');
2476  
2477 3 return Zuzu::AST::Expr::Unary->new(
2478 file => $tok->file,
2479 line => $tok->line,
2480 op => 'ceil',
2481 expr => $expr,
2482 );
2483 }
2484 3436 ▶ if ($t->is_OP && $t->value eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "[") 1192 2244 3436
Condition100%3/3
$t->is_OP and $t->value eq "["
!ll&&!rl&&r
12709741192
MC/DC100%2/2
$t->is_OP and $t->value eq "["
$t->is_OP $t->value eq "["
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "["
ABresult
0X0
100
111
2485  
2486 1192 return $self->parse_array_literal;
2487 }
2488 2244 ▶ if ($t->is_OP('<<') or $t->is_OP('«')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("<<") or $t->is_OP("\x{ab}")) 55 2189 2244
Condition100%3/3
$t->is_OP("<<") or $t->is_OP("\x{ab}")
l!l&&r!l&&!r
5412189
MC/DC100%2/2
$t->is_OP("<<") or $t->is_OP("\x{ab}")
$t->is_OP("<<") $t->is_OP("\x{ab}")
Truth table100%3/3
A or B
A= $t->is_OP("<<")B= $t->is_OP("\x{ab}")
ABresult
1X1
011
000
2489  
2490 55 return $self->parse_set_literal;
2491 }
2492 2189 ▶ if ($t->is_OP('<<<')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("<<<")) 43 2146 2189
2493  
2494 43 return $self->parse_bag_literal;
2495 }
2496 2146 ▶ if ($t->is_EMPTY_SET) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_EMPTY_SET) 3 2143 2146
2497 3 my $tok = $self->_eat('EMPTY_SET');
2498  
2499 3 return Zuzu::AST::Expr::Set->new(
2500 file => $tok->file,
2501 line => $tok->line,
2502 items => [],
2503 );
2504 }
2505 2143 ▶ if ($t->is_OP && $t->value eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "{") 825 1318 2143
Condition100%3/3
$t->is_OP and $t->value eq "{"
!ll&&!rl&&r
126751825
MC/DC100%2/2
$t->is_OP and $t->value eq "{"
$t->is_OP $t->value eq "{"
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "{"
ABresult
0X0
100
111
2506  
2507 825 return $self->parse_dict_literal;
2508 }
2509 1318 ▶ if ( $t->is_OP('{{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("{{")) 40 1278 1318
2510  
2511 40 return $self->parse_pairlist_literal;
2512 }
2513 1278 ▶ if ($t->is_KW('new')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("new")) 785 493 1278
2514 785 my $kw = $self->_eat('KW', 'new');
2515 785 my $class_expr = $self->parse_primary;
2516 776 while (1) {
2517 776 ▶ if ( $self->{tok}->is_OP('.') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP(".")) 0 776 776
2518 0 my $dot = $self->_eat('OP', '.');
2519 0 my $m = $self->_eat_member_name;
2520 0 $class_expr = Zuzu::AST::Expr::MemberCall->new(
2521 file => $dot->file,
2522 line => $dot->line,
2523 object => $class_expr,
2524 method => $m,
2525 args => [],
2526 );
2527 0 next;
2528 }
2529 776 ▶ if ( $self->{tok}->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("{")) 0 776 776
2530 0 my $lb = $self->_eat('OP', '{');
2531 0 my $key = $self->_parse_dict_key_expr;
2532 0 $self->_eat('OP', '}');
2533 0 $class_expr = Zuzu::AST::Expr::DictGet->new(file => $lb->file, line => $lb->line, dict => $class_expr, key => $key);
2534 0 next;
2535 }
2536 776 last;
2537 }
2538 776 my @traits;
2539 776 ▶ if ( $self->{tok}->is_KW('with') or $self->{tok}->is_KW('but') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")) 3 773 776
Condition66%2/3
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
l!l&&r!l&&!r
30773
MC/DC50%1/2
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
$self->{"tok"}->is_KW("with") $self->{"tok"}->is_KW("but")
Truth table66%2/3
A or B
A= $self->{"tok"}->is_KW("with")B= $self->{"tok"}->is_KW("but")
ABresult
1X1
011
000
2540 3 $self->_eat('KW');
2541 3 push @traits, $self->parse_type_ref;
2542 3 ▶ while ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 3 3
2543 0 push @traits, $self->parse_type_ref;
2544 }
2545 }
2546 776 $self->_eat('OP', '(');
2547 775 my @args = $self->_parse_invocation_args;
2548 775 $self->_eat('OP', ')');
2549  
2550 775 return Zuzu::AST::Expr::New->new(
2551 file => $kw->file,
2552 line => $kw->line,
2553 class_expr => $class_expr,
2554 traits => \@traits,
2555 args => \@args,
2556 );
2557 }
2558 493 ▶ if ($t->is_KW('function')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("function")) 274 219 493
2559 274 my $kw = $self->_eat('KW', 'function');
2560 274 ▶ my $is_async = $self->{_next_function_expr_async} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_next_function_expr_async'} ? : 0 274 274
2561 274 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
2562 271 my $return_type = $self->_parse_optional_return_type;
2563 my @arg_decls = map {
2564 {
2565 name => $_,
2566 mutable => 0,
2567 1108 ▶ declared_type => $param_types->{$_} // 'Any',
Condition50%1/2
$param_types->{$_} // "Any"
l!l
11080
MC/DC0%0/1
$param_types->{$_} // "Any"
$param_types->{$_}
Truth table50%1/2
A
A= $param_types->{$_}
Aresult
11
00
2568 }
2569 271 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
2710
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
2570 271 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 2 269 271
2571 2 ▶ push @arg_decls, {
Condition50%1/2
$vararg_type // "Any"
l!l
20
MC/DC0%0/1
$vararg_type // "Any"
$vararg_type
Truth table50%1/2
A
A= $vararg_type
Aresult
11
00
2572 name => $vararg,
2573 mutable => 0,
2574 declared_type => $vararg_type // 'Any',
2575 };
2576 }
2577 271 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 4 267 271
2578 4 ▶ push @arg_decls, {
Condition50%1/2
$named_vararg_type // "PairList"
l!l
40
MC/DC0%0/1
$named_vararg_type // "PairList"
$named_vararg_type
Truth table50%1/2
A
A= $named_vararg_type
Aresult
11
00
2579 name => $named_vararg,
2580 mutable => 0,
2581 declared_type => $named_vararg_type // 'PairList',
2582 };
2583 }
2584 271 my $body = $self->_parse_block_in_async_context(
2585 $is_async,
2586 \@arg_decls,
2587 [],
2588 );
2589  
2590 271 return Zuzu::AST::Expr::Function->new(
2591 file => $kw->file,
2592 line => $kw->line,
2593 params => $params,
2594 vararg => $vararg,
2595 body => $body,
2596 param_types => $param_types,
2597 vararg_type => $vararg_type,
2598 named_vararg => $named_vararg,
2599 named_vararg_type => $named_vararg_type,
2600 param_optional => $param_optional,
2601 param_defaults => $param_defaults,
2602 return_type => $return_type,
2603 is_async => $is_async,
2604 );
2605 }
2606 219 ▶ if ($t->is_KW('fn')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("fn")) 191 28 219
2607 191 my $kw = $self->_eat('KW', 'fn');
2608 191 ▶ my $is_async = $self->{_next_function_expr_async} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_next_function_expr_async'} ? : 7 184 191
2609 191 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type );
2610 191 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_IDENT) { } 150 41 191
elsif ($self->{'tok'}->is_OP('(')) { } 41 0 41
2611 150 my ( $type_name, $param_name ) = $self->_parse_param_name;
2612 150 $params = [ $param_name ];
2613 150 $vararg = undef;
2614 150 $param_types = { $param_name => $type_name };
2615 150 $vararg_type = 'Any';
2616 150 $param_optional = {};
2617 150 $param_defaults = {};
2618 150 $named_vararg = undef;
2619 150 $named_vararg_type = 'PairList';
2620 }
2621 elsif ( $self->{tok}->is_OP('(') ) {
2622 41 ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
2623 }
2624 else {
2625 0 $self->_err("Expected identifier or '(' after fn", $self->{tok});
2626 }
2627  
2628 191 ▶ if ( ! $self->_maybe('OP', '->') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_maybe("OP", "->")) 75 116 191
2629 75 $self->_eat('OP', '→');
2630 }
2631  
2632 191 $self->_push_scope;
2633 191 ▶ for my $n ( @{ $params // [] } ) {
Condition50%1/2
$params // []
l!l
1910
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
2634 $self->_declare(
2635 $n,
2636 {
2637 kind => 'local',
2638 mutable => 0,
2639 217 ▶ declared_type => $param_types->{$n} // 'Any',
Condition50%1/2
$param_types->{$n} // "Any"
l!l
2170
MC/DC0%0/1
$param_types->{$n} // "Any"
$param_types->{$n}
Truth table50%1/2
A
A= $param_types->{$n}
Aresult
11
00
2640 },
2641 $kw,
2642 );
2643 }
2644 190 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 0 190 190
2645 0 ▶ $self->_declare(
Condition0%0/2
$vararg_type // "Any"
l!l
00
MC/DC0%0/1
$vararg_type // "Any"
$vararg_type
Truth table0%0/2
A
A= $vararg_type
Aresult
11
00
2646 $vararg,
2647 {
2648 kind => 'local',
2649 mutable => 0,
2650 declared_type => $vararg_type // 'Any',
2651 },
2652 $kw,
2653 );
2654 }
2655 190 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 0 190 190
2656 0 ▶ $self->_declare(
Condition0%0/2
$named_vararg_type // "PairList"
l!l
00
MC/DC0%0/1
$named_vararg_type // "PairList"
$named_vararg_type
Truth table0%0/2
A
A= $named_vararg_type
Aresult
11
00
2657 $named_vararg,
2658 {
2659 kind => 'local',
2660 mutable => 0,
2661 declared_type => $named_vararg_type // 'PairList',
2662 },
2663 $kw,
2664 );
2665 }
2666 190 my $expr;
2667 190 ▶ if ( $is_async ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_async) { } 7 183 190
2668 local $self->{_async_context_depth} =
2669 7 ▶ ( $self->{_async_context_depth} // 0 ) + 1;
Condition50%1/2
$self->{"_async_context_depth"} // 0
l!l
70
MC/DC0%0/1
$self->{"_async_context_depth"} // 0
$self->{"_async_context_depth"}
Truth table50%1/2
A
A= $self->{"_async_context_depth"}
Aresult
11
00
2670 7 $expr = $self->parse_expression;
2671 }
2672 else {
2673 183 local $self->{_async_context_depth} = 0;
2674 183 $expr = $self->parse_expression;
2675 }
2676 190 $self->_pop_scope;
2677 190 my $ret = Zuzu::AST::Stmt::Return->new(
2678 file => $kw->file,
2679 line => $kw->line,
2680 expr => $expr,
2681 );
2682 190 my $body = Zuzu::AST::Block->new(
2683 file => $kw->file,
2684 line => $kw->line,
2685 statements => [ $ret ],
2686 );
2687  
2688 190 return Zuzu::AST::Expr::Function->new(
2689 file => $kw->file,
2690 line => $kw->line,
2691 params => $params,
2692 vararg => $vararg,
2693 body => $body,
2694 param_types => $param_types,
2695 vararg_type => $vararg_type,
2696 named_vararg => $named_vararg,
2697 named_vararg_type => $named_vararg_type,
2698 param_optional => $param_optional,
2699 param_defaults => $param_defaults,
2700 return_type => 'Any',
2701 is_async => $is_async,
2702 );
2703 }
2704  
2705 28 ▶ $self->_err("Unexpected token in expression: ".$t->type." ".($t->value // ''), $t);
Condition100%2/2
$t->value // ""
l!l
1810
MC/DC100%1/1
$t->value // ""
$t->value
Truth table100%2/2
A
A= $t->value
Aresult
11
00
2706 }
2707  
2708 374 ▶sub _parse_template_expression {
Subroutine _parse_template_expression: called CC=10 SCAR=24.7
2709 374 my ( $self, $tok ) = @_;
2710  
2711 my @parts = ref( $tok->value ) eq 'ARRAY'
2712 374 ▶ ? @{ $tok->value }
Branch: 1 branch
BranchTrueFalseTotal
ref $tok->value eq 'ARRAY' ? : 374 0 374
Condition0%0/2
$tok->value // ""
l!l
00
MC/DC0%0/1
$tok->value // ""
$tok->value
Truth table0%0/2
A
A= $tok->value
Aresult
11
00
2713 : $self->_split_template_parts( $tok->value // '', $tok );
2714 374 my $expr;
2715  
2716 374 for my $part ( @parts ) {
2717 1135 my $piece;
2718 1135 ▶ if ( ref $part eq 'HASH' and exists $part->{expr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $part eq 'HASH' and exists $part->{'expr'}) { } 477 658 1135
Condition66%2/3
ref $part eq "HASH" and exists $part->{"expr"}
!ll&&!rl&&r
0658477
MC/DC50%1/2
ref $part eq "HASH" and exists $part->{"expr"}
ref $part eq "HASH" exists $part->{"expr"}
Truth table66%2/3
A and B
A= ref $part eq "HASH"B= exists $part->{"expr"}
ABresult
0X0
100
111
2719 477 $piece = $self->_parse_embedded_expression( $part->{expr}, $tok );
2720 }
2721 else {
2722 my $text = ref $part eq 'HASH' && exists $part->{text}
2723 ? $part->{text}
2724 658 ▶ : $part;
Branch: 1 branch
BranchTrueFalseTotal
ref $part eq 'HASH' && exists $part->{'text'} ? : 658 0 658
Condition33%1/3
ref $part eq "HASH" and exists $part->{"text"}
!ll&&!rl&&r
00658
MC/DC0%0/2
ref $part eq "HASH" and exists $part->{"text"}
ref $part eq "HASH" exists $part->{"text"}
Truth table33%1/3
A and B
A= ref $part eq "HASH"B= exists $part->{"text"}
ABresult
0X0
100
111
2725 658 $piece = Zuzu::AST::Expr::Literal->new(
2726 file => $tok->file,
2727 line => $tok->line,
2728 value => $text,
2729 );
2730 }
2731 1134 ▶ if ( ! defined $expr ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $expr) 374 760 1134
2732 374 $expr = $piece;
2733 374 next;
2734 }
2735 760 $expr = Zuzu::AST::Expr::Binary->new(
2736 file => $tok->file,
2737 line => $tok->line,
2738 op => '_',
2739 left => $expr,
2740 right => $piece,
2741 );
2742 }
2743  
2744 373 ▶ return $expr // Zuzu::AST::Expr::Literal->new(
Condition33%1/3
$expr // "Zuzu::AST::Expr::Literal"->new("file", $tok->file, "line", $tok->line, "value", "")
l!l&&r!l&&!r
37300
MC/DC0%0/2
$expr // "Zuzu::AST::Expr::Literal"->new("file", $tok->file, "line", $tok->line, "value", "")
$expr "Zuzu::AST::Expr::Literal"->new("file", $tok->file, "line", $tok->line, "value", "")
Truth table33%1/3
A // B
A= $exprB= "Zuzu::AST::Expr::Literal"->new("file", $tok->file, "line", $tok->line, "value", "")
ABresult
1X1
011
000
2745 file => $tok->file,
2746 line => $tok->line,
2747 value => '',
2748 );
2749 }
2750  
2751 0 ▶sub _split_template_parts {
Subroutine _split_template_parts: not called CC=18 SCAR=58.3
2752 0 my ( $self, $src, $tok ) = @_;
2753  
2754 0 my @parts;
2755 0 my $text = '';
2756 0 my $i = 0;
2757 0 my $len = length $src;
2758  
2759 0 ▶ while ( $i < $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
2760 0 my $ch = substr( $src, $i, 1 );
2761 0 ▶ if ( $ch eq '$' and $i + 1 < $len and substr( $src, $i + 1, 1 ) eq '{' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "\$" and $i + 1 < $len and substr($src, $i + 1, 1) eq "{") 0 0 0
Condition0%0/6
$ch eq "\$" and $i + 1 < $len and substr($src, $i + 1, 1) eq "{"
!ll&&!rl&&r
000
$ch eq "\$" and $i + 1 < $len
!ll&&!rl&&r
000
MC/DC0%0/3
$ch eq "\$" and $i + 1 < $len and substr($src, $i + 1, 1) eq "{"
$ch eq "\$" $i + 1 < $len substr($src, $i + 1, 1) eq "{"
Truth table0%0/4
A and B and C
A= $ch eq "\$"B= $i + 1 < $lenC= substr($src, $i + 1, 1) eq "{"
ABCresult
0XX0
10X0
1100
1111
2762 0 ▶ push @parts, $text if $text ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $text ne "" 0 0 0
2763 0 $text = '';
2764 0 $i += 2;
2765 0 my $start = $i;
2766 0 my $depth = 1;
2767 0 my $in_string = 0;
2768 0 my $escaped = 0;
2769 0 ▶ while ( $i < $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $len) 0 0 0
2770 0 my $c = substr( $src, $i, 1 );
2771 0 ▶ if ( $in_string ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_string) 0 0 0
2772 0 ▶ if ( $escaped ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($escaped) { } 0 0 0
elsif ($c eq '\\') { } 0 0 0
elsif ($c eq '"') { } 0 0 0
2773 0 $escaped = 0;
2774 }
2775 elsif ( $c eq '\\' ) {
2776 0 $escaped = 1;
2777 }
2778 elsif ( $c eq '"' ) {
2779 0 $in_string = 0;
2780 }
2781 0 $i++;
2782 0 next;
2783 }
2784 0 ▶ if ( $c eq '"' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\"") 0 0 0
2785 0 $in_string = 1;
2786 0 $i++;
2787 0 next;
2788 }
2789 0 ▶ if ( $c eq '{' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "{") 0 0 0
2790 0 $depth++;
2791 0 $i++;
2792 0 next;
2793 }
2794 0 ▶ if ( $c eq '}' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "}") 0 0 0
2795 0 $depth--;
2796 0 ▶ last if $depth == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $depth == 0 0 0 0
2797 0 $i++;
2798 0 next;
2799 }
2800 0 $i++;
2801 }
2802 0 ▶ $self->_err( "Unterminated template interpolation", $tok ) if $i >= $len;
Branch: 1 branch
BranchTrueFalseTotal
if $i >= $len 0 0 0
2803 0 my $expr_src = substr( $src, $start, $i - $start );
2804 0 push @parts, { expr => $expr_src };
2805 0 $i++;
2806 0 next;
2807 }
2808 0 $text .= $ch;
2809 0 $i++;
2810 }
2811  
2812 0 ▶ push @parts, $text if $text ne '' or !@parts;
Branch: 1 branch
BranchTrueFalseTotal
if $text ne "" or not @parts 0 0 0
Condition0%0/3
$text ne "" or not @parts
l!l&&r!l&&!r
000
MC/DC0%0/2
$text ne "" or not @parts
$text ne "" not @parts
Truth table0%0/3
A or not(B)
A= $text ne ""B= not @parts
ABresult
1X1
011
000
2813  
2814 0 return @parts;
2815 }
2816  
2817 477 ▶sub _parse_embedded_expression {
Subroutine _parse_embedded_expression: called CC=2 SCAR=7.0
2818 477 my ( $self, $src, $tok ) = @_;
2819  
2820 477 my $lexer = Zuzu::Lexer->new(
2821 src => $src,
2822 filename => $tok->file,
2823 );
2824 my $parser = __PACKAGE__->new(
2825 lexer => $lexer,
2826 filename => $tok->file,
2827 scopes => $self->{scopes},
2828 477 );
2829 477 my $expr = $parser->parse_expression;
2830 476 ▶ $parser->_err( "Unexpected trailing tokens in template interpolation", $parser->{tok} ) if ! $parser->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
unless $parser->{"tok"}->is_EOF 0 476 476
2831  
2832 476 return $expr;
2833 }
2834  
2835 70382 ▶sub parse_postfix {
Subroutine parse_postfix: called CC=20 SCAR=30.0
Pod documented
2836 70382 my ($self, $expr) = @_;
2837  
2838 70382 while (1) {
2839 89563 my $t = $self->{tok};
2840  
2841 # function call
2842 89563 ▶ if ($t->is_OP && $t->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "(") 6608 82955 89563
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
5418775376608
MC/DC100%2/2
$t->is_OP and $t->value eq "("
$t->is_OP $t->value eq "("
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "("
ABresult
0X0
100
111
2843 6608 my $lp = $self->_eat('OP', '(');
2844 6608 my @args = $self->_parse_invocation_args;
2845 6606 $self->_eat('OP', ')');
2846 6606 $expr = Zuzu::AST::Expr::Call->new(file => $lp->file, line => $lp->line, callee => $expr, args => \@args);
2847 6606 next;
2848 }
2849  
2850 # member call: obj.method(...) or obj.method (no-arg call handled at runtime by allowing method without ())
2851 82955 ▶ if ($t->is_OP && $t->value eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq ".") 8307 74648 82955
Condition100%3/3
$t->is_OP and $t->value eq "."
!ll&&!rl&&r
5418692308307
MC/DC100%2/2
$t->is_OP and $t->value eq "."
$t->is_OP $t->value eq "."
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "."
ABresult
0X0
100
111
2852 8307 my $dot = $self->_eat('OP', '.');
2853 8307 ▶ if ( $self->_maybe('OP', '(') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "(")) 11 8296 8307
2854 11 my $method_expr = $self->parse_expression;
2855 11 $self->_eat('OP', ')');
2856 11 $self->_eat('OP', '(');
2857 11 my @args = $self->_parse_invocation_args;
2858 11 $self->_eat('OP', ')');
2859 11 $expr = Zuzu::AST::Expr::DynamicMemberCall->new(
2860 file => $dot->file,
2861 line => $dot->line,
2862 object => $expr,
2863 method_expr => $method_expr,
2864 args => \@args,
2865 );
2866 11 next;
2867 }
2868 8296 my $method = $self->_eat_member_name;
2869 8296 my @args;
2870 8296 ▶ if ($self->{tok}->is_OP && $self->{tok}->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "(") 7836 460 8296
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "("
!ll&&!rl&&r
254357836
MC/DC100%2/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "("
$self->{"tok"}->is_OP $self->{"tok"}->value eq "("
Truth table100%3/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "("
ABresult
0X0
100
111
2871 7836 $self->_eat('OP', '(');
2872 7836 @args = $self->_parse_invocation_args;
2873 7835 $self->_eat('OP', ')');
2874 }
2875 8295 $expr = Zuzu::AST::Expr::MemberCall->new(
2876 file => $dot->file, line => $dot->line,
2877 object => $expr, method => $method, args => \@args
2878 );
2879 8295 next;
2880 }
2881  
2882 # index: a[expr]
2883 74648 ▶ if ($t->is_OP && $t->value eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "[") 1130 73518 74648
Condition100%3/3
$t->is_OP and $t->value eq "["
!ll&&!rl&&r
5418681001130
MC/DC100%2/2
$t->is_OP and $t->value eq "["
$t->is_OP $t->value eq "["
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "["
ABresult
0X0
100
111
2884 1130 my $lb = $self->_eat('OP', '[');
2885 1130 my ( $first, $is_slice );
2886 1130 ▶ if ( ! $self->{tok}->is_OP(':') and ! $self->{tok}->is_OP(']') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(":") or $self->{"tok"}->is_OP("]")) 1130 0 1130
Condition33%1/3
$self->{"tok"}->is_OP(":") or $self->{"tok"}->is_OP("]")
l!l&&r!l&&!r
001130
MC/DC0%0/2
$self->{"tok"}->is_OP(":") or $self->{"tok"}->is_OP("]")
$self->{"tok"}->is_OP(":") $self->{"tok"}->is_OP("]")
Truth table33%1/3
A or B
A= $self->{"tok"}->is_OP(":")B= $self->{"tok"}->is_OP("]")
ABresult
1X1
011
000
2887 1130 $first = $self->parse_expression;
2888 }
2889 1130 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ":")) 23 1107 1130
2890 23 $is_slice = 1;
2891 }
2892 1130 ▶ if ( $is_slice ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_slice) 23 1107 1130
2893 23 my $length;
2894 23 ▶ if ( ! $self->{tok}->is_OP(']') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("]")) 15 8 23
2895 15 $length = $self->parse_expression;
2896 }
2897 23 $self->_eat('OP', ']');
2898 23 $expr = Zuzu::AST::Expr::Slice->new(
2899 file => $lb->file,
2900 line => $lb->line,
2901 collection => $expr,
2902 start => $first,
2903 length => $length,
2904 );
2905 23 next;
2906 }
2907 1107 my $idx = $first;
2908 1107 $self->_eat('OP', ']');
2909 1107 $expr = Zuzu::AST::Expr::Index->new(file => $lb->file, line => $lb->line, array => $expr, index => $idx);
2910 1107 next;
2911 }
2912  
2913 # postfix increment/decrement
2914 73518 ▶ if ($t->is_OP && ($t->value eq '++' || $t->value eq '--')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "++" || $t->value eq "--") 683 72835 73518
Condition100%6/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
541867417683
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
6414267417
MC/DC100%3/3
$t->is_OP and $t->value eq "++" || $t->value eq "--"
$t->is_OP $t->value eq "++" $t->value eq "--"
Truth table100%4/4
A and B or C
A= $t->is_OPB= $t->value eq "++"C= $t->value eq "--"
ABCresult
0XX0
1000
11X1
1011
2915 683 my $op = $self->_eat('OP');
2916 683 $self->_assert_mutable_target($expr, $op);
2917 682 $expr = Zuzu::AST::Expr::IncDec->new(
2918 file => $op->file,
2919 line => $op->line,
2920 op => $op->value,
2921 target => $expr,
2922 postfix => 1,
2923 );
2924 682 next;
2925 }
2926  
2927 # dict access: d{expr} or d{ident}
2928 72835 ▶ if ($t->is_OP && $t->value eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "{") 2457 70378 72835
Condition100%3/3
$t->is_OP and $t->value eq "{"
!ll&&!rl&&r
5418649602457
MC/DC100%2/2
$t->is_OP and $t->value eq "{"
$t->is_OP $t->value eq "{"
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "{"
ABresult
0X0
100
111
2929 2457 my $lb = $self->_eat('OP', '{');
2930 2457 my $key = $self->_parse_dict_key_expr;
2931 2457 $self->_eat('OP', '}');
2932 2457 $expr = Zuzu::AST::Expr::DictGet->new(file => $lb->file, line => $lb->line, dict => $expr, key => $key);
2933 2457 next;
2934 }
2935  
2936 70378 last;
2937 }
2938  
2939 70378 return $expr;
2940 }
2941  
2942 15230 ▶sub _parse_invocation_args {
Subroutine _parse_invocation_args: called CC=15 SCAR=27.8
2943 15230 my ( $self ) = @_;
2944  
2945 15230 my @args;
2946 15230 $self->{_invocation_arg_depth}++;
2947 15230 ▶ while ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 23296 15227 38523
2948 # ignore superfluous commas between arguments
2949 0 ▶ if ( $self->_maybe('OP', ',') ) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 23296 23296
2950  
2951 23296 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 20 23276 23296
2952 20 my $spread_tok = $self->_eat('OP', '...');
2953 20 my $expr = $self->parse_expression;
2954 20 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 0 20 20
2955 0 $self->_err("Range syntax '...' is only valid in collection literals", $self->{tok});
2956 }
2957 20 push @args, [
2958 undef,
2959 Zuzu::AST::Expr::Spread->new(
2960 file => $spread_tok->file,
2961 line => $spread_tok->line,
2962 expr => $expr,
2963 ),
2964 ];
2965 20 $self->_maybe('OP', ',');
2966 20 next;
2967 }
2968  
2969 23276 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")) 1979 21297 23276
Condition100%6/6
$self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")
!ll&&!rl&&r
6736145611979
$self->{"tok"}->is_IDENT or $self->{"tok"}->is_KW
l!l&&r!l&&!r
157757656736
MC/DC100%3/3
$self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")
$self->{"tok"}->is_IDENT $self->{"tok"}->is_KW $self->_peek_token->is_OP(":")
Truth table100%5/5
A or B and C
A= $self->{"tok"}->is_IDENTB= $self->{"tok"}->is_KWC= $self->_peek_token->is_OP(":")
ABCresult
00X0
1X00
0100
1X11
0111
2970 ( $self->{tok}->is_IDENT or $self->{tok}->is_KW )
2971 and $self->_peek_token->is_OP(':')
2972 ) {
2973 1979 my $name_tok = $self->{tok};
2974 1979 $self->{tok} = $self->{lexer}->next_token;
2975 1979 $self->_eat('OP', ':');
2976 1979 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 1 1978 1979
2977 1 $self->_err("Spread arguments cannot be named", $self->{tok});
2978 }
2979 1978 my $value_expr = $self->parse_expression;
2980 1978 push @args, [ $name_tok->value, $value_expr ];
2981 1978 $self->_maybe('OP', ',');
2982 1978 next;
2983 }
2984  
2985 21297 my $expr = $self->parse_expression;
2986 21296 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':')) { } 6 21290 21296
2987 6 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 0 6 6
2988 0 $self->_err("Spread arguments cannot be named", $self->{tok});
2989 }
2990 6 my $value_expr = $self->parse_expression;
2991 6 ▶ if ( $expr and blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr and builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var')) { } 0 6 6
Condition33%2/6
$expr and builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
060
$expr and builtin::blessed($expr)
!ll&&!rl&&r
006
MC/DC0%0/3
$expr and builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
$expr builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table25%1/4
A and B and C
A= $exprB= builtin::blessed($expr)C= $expr->isa("Zuzu::AST::Expr::Var")
ABCresult
0XX0
10X0
1100
1111
2992 0 push @args, [ $expr->name, $value_expr ];
2993 }
2994 else {
2995 6 push @args, [ $expr, $value_expr, 1 ];
2996 }
2997 }
2998 else {
2999 21290 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 1 21289 21290
3000 1 $self->_err("Range syntax '...' is only valid in collection literals", $self->{tok});
3001 }
3002 21289 push @args, [ undef, $expr ];
3003 }
3004 21295 $self->_maybe('OP', ',');
3005 }
3006 15227 $self->{_invocation_arg_depth}--;
3007  
3008 15227 return @args;
3009 }
3010  
3011 2935 ▶sub _assert_mutable_target {
Subroutine _assert_mutable_target: called CC=6 SCAR=18.2
3012 2935 my ( $self, $expr, $tok ) = @_;
3013  
3014 2935 ▶ return if ! blessed($expr) or ! $expr->isa('Zuzu::AST::Expr::Var');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var") 238 2697 2935
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
02382697
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Var")
ABresult
0X0
100
111
3015  
3016 2697 my $info = $self->_lookup($expr->name);
3017 2697 ▶ return if ! $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 2697 2697
3018 2697 ▶ return if ! exists $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $info->{"mutable"} 0 2697 2697
3019 2697 ▶ return if $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"mutable"} 2690 7 2697
3020  
3021 7 $self->_err("Cannot assign to const '".$expr->name."' (compile-time)", $tok);
3022 }
3023  
3024 27 ▶sub _assert_reference_target {
Subroutine _assert_reference_target: called CC=11 SCAR=28.2
3025 27 my ( $self, $expr, $tok ) = @_;
3026  
3027 27 ▶ my $ok
Condition62%17/27
builtin::blessed($expr) && ($expr->isa('Zuzu::AST::Expr::Var') || $expr->isa('Zuzu::AST::Expr::Index') || $expr->isa('Zuzu::AST::Expr::DictGet') || $expr->isa('Zuzu::AST::Expr::Slice') || $expr->isa('Zuzu::AST::Expr::Binary') && defined $expr->op && ($expr->op eq '@' || $expr->op eq '@@' || $expr->op eq '@?'))
!ll&&!rl&&r
0027
$expr->isa("Zuzu::AST::Expr::Var") or $expr->isa("Zuzu::AST::Expr::Index") or $expr->isa("Zuzu::AST::Expr::DictGet") or $expr->isa("Zuzu::AST::Expr::Slice") or $expr->isa("Zuzu::AST::Expr::Binary") and defined $expr->op and $expr->op eq "\@" || $expr->op eq "\@\@" || $expr->op eq "\@?"
l!l&&r!l&&!r
2160
$expr->isa("Zuzu::AST::Expr::Var") or $expr->isa("Zuzu::AST::Expr::Index") or $expr->isa("Zuzu::AST::Expr::DictGet") or $expr->isa("Zuzu::AST::Expr::Slice")
l!l&&r!l&&!r
2106
$expr->isa("Zuzu::AST::Expr::Var") or $expr->isa("Zuzu::AST::Expr::Index") or $expr->isa("Zuzu::AST::Expr::DictGet")
l!l&&r!l&&!r
10116
$expr->isa("Zuzu::AST::Expr::Var") or $expr->isa("Zuzu::AST::Expr::Index")
l!l&&r!l&&!r
01017
$expr->isa("Zuzu::AST::Expr::Binary") and defined $expr->op and $expr->op eq "\@" || $expr->op eq "\@\@" || $expr->op eq "\@?"
!ll&&!rl&&r
006
$expr->isa("Zuzu::AST::Expr::Binary") and defined $expr->op
!ll&&!rl&&r
006
$expr->op eq "\@" or $expr->op eq "\@\@" or $expr->op eq "\@?"
l!l&&r!l&&!r
420
$expr->op eq "\@" or $expr->op eq "\@\@"
l!l&&r!l&&!r
222
MC/DC0%0/10
builtin::blessed($expr) && ($expr->isa('Zuzu::AST::Expr::Var') || $expr->isa('Zuzu::AST::Expr::Index') || $expr->isa('Zuzu::AST::Expr::DictGet') || $expr->isa('Zuzu::AST::Expr::Slice') || $expr->isa('Zuzu::AST::Expr::Binary') && defined $expr->op && ($expr->op eq '@' || $expr->op eq '@@' || $expr->op eq '@?'))
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var") $expr->isa("Zuzu::AST::Expr::Index") $expr->isa("Zuzu::AST::Expr::DictGet") $expr->isa("Zuzu::AST::Expr::Slice") $expr->isa("Zuzu::AST::Expr::Binary") defined $expr->op $expr->op eq "\@" $expr->op eq "\@\@" $expr->op eq "\@?"
Truth table45%5/11
A && B or C or D or E or F and G and H or I or J
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Var")C= $expr->isa("Zuzu::AST::Expr::Index")D= $expr->isa("Zuzu::AST::Expr::DictGet")E= $expr->isa("Zuzu::AST::Expr::Slice")F= $expr->isa("Zuzu::AST::Expr::Binary")G= defined $expr->opH= $expr->op eq "\@"I= $expr->op eq "\@\@"J= $expr->op eq "\@?"
ABCDEFGHIJresult
0XXXXXXXXX0
100000XXXX0
1000010XXX0
10000110000
11XXXXXXXX1
101XXXXXXX1
1001XXXXXX1
10001XXXXX1
10000111XX1
100001101X1
10000110011
3028 = blessed($expr)
3029 && (
3030 $expr->isa('Zuzu::AST::Expr::Var')
3031 or $expr->isa('Zuzu::AST::Expr::Index')
3032 or $expr->isa('Zuzu::AST::Expr::DictGet')
3033 or $expr->isa('Zuzu::AST::Expr::Slice')
3034 or (
3035 $expr->isa('Zuzu::AST::Expr::Binary')
3036 and defined $expr->op
3037 and (
3038 $expr->op eq '@'
3039 or $expr->op eq '@@'
3040 or $expr->op eq '@?'
3041 )
3042 )
3043 );
3044 27 ▶ return if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 27 0 27
3045  
3046 0 $self->_err("Reference operator expects an assignable target", $tok);
3047 }
3048  
3049 4764 ▶sub _parse_dict_key_expr {
Subroutine _parse_dict_key_expr: called CC=3 SCAR=11.0
3050 4764 my ( $self ) = @_;
3051  
3052 4764 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 4484 280 4764
3053 4484 my $id = $self->_eat('IDENT');
3054  
3055 4484 return Zuzu::AST::Expr::Literal->new(
3056 file => $id->file,
3057 line => $id->line,
3058 value => $id->value,
3059 );
3060 }
3061 280 ▶ if ( $self->{tok}->is_KW ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW) 47 233 280
3062 47 my $kw = $self->_eat('KW');
3063  
3064 47 return Zuzu::AST::Expr::Literal->new(
3065 file => $kw->file,
3066 line => $kw->line,
3067 value => $kw->value,
3068 );
3069 }
3070  
3071 233 return $self->parse_expression;
3072 }
3073  
3074 1192 ▶sub parse_array_literal {
Subroutine parse_array_literal: called CC=5 SCAR=16.1
Pod documented
3075 1192 my ($self) = @_;
3076  
3077 1192 my $lb = $self->_eat('OP', '[');
3078 1192 my @items;
3079 1192 ▶ while (!($self->{tok}->is_OP && $self->{tok}->value eq ']')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "]") 1687 1189 2876
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "]"
!ll&&!rl&&r
15351521189
MC/DC100%2/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "]"
$self->{"tok"}->is_OP $self->{"tok"}->value eq "]"
Truth table100%3/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "]"
ABresult
0X0
100
111
3080 # ignore duplicate/trailing commas
3081 0 ▶ if ($self->_maybe('OP', ',')) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 1687 1687
3082 1687 my $start = $self->parse_expression;
3083 1684 ▶ if ( $self->_maybe('OP', '...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '...')) { } 4 1680 1684
3084 4 my $end = $self->parse_expression;
3085 4 push @items, Zuzu::AST::Expr::Range->new(
3086 file => $lb->file,
3087 line => $lb->line,
3088 start => $start,
3089 end => $end,
3090 );
3091 }
3092 else {
3093 1680 push @items, $start;
3094 }
3095 1684 $self->_maybe('OP', ',');
3096 }
3097 1189 $self->_eat('OP', ']');
3098  
3099 1189 return Zuzu::AST::Expr::Array->new(file => $lb->file, line => $lb->line, items => \@items);
3100 }
3101  
3102 825 ▶sub parse_dict_literal {
Subroutine parse_dict_literal: called CC=4 SCAR=13.9
Pod documented
3103 825 my ($self) = @_;
3104  
3105 825 my $lb = $self->_eat('OP', '{');
3106 825 my @pairs;
3107 825 ▶ while (!($self->{tok}->is_OP && $self->{tok}->value eq '}')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "}") 2240 820 3060
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "}"
!ll&&!rl&&r
22391820
MC/DC100%2/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "}"
$self->{"tok"}->is_OP $self->{"tok"}->value eq "}"
Truth table100%3/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "}"
ABresult
0X0
100
111
3108 0 ▶ if ($self->_maybe('OP', ',')) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 2240 2240
3109 2240 my $key;
3110 2240 $key = $self->_parse_dict_key_expr;
3111 2238 $self->_eat('OP', ':');
3112 2237 my $val = $self->parse_expression;
3113 2235 push @pairs, [ $key, $val ];
3114 2235 $self->_maybe('OP', ',');
3115 }
3116 820 $self->_eat('OP', '}');
3117  
3118 820 return Zuzu::AST::Expr::Dict->new(file => $lb->file, line => $lb->line, pairs => \@pairs);
3119 }
3120  
3121 40 ▶sub parse_pairlist_literal {
Subroutine parse_pairlist_literal: called CC=3 SCAR=11.0
Pod undocumented
3122 40 my ( $self ) = @_;
3123  
3124 40 my $lb = $self->_eat( 'OP', '{{' );
3125 40 my @pairs;
3126 40 ▶ while ( ! $self->{tok}->is_OP('}}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}}")) 67 40 107
3127 67 ▶ if ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 67 67
3128 0 next;
3129 }
3130 67 my $key = $self->_parse_dict_key_expr;
3131 67 $self->_eat( 'OP', ':' );
3132 67 my $value = $self->parse_expression;
3133 67 push @pairs, [ $key, $value ];
3134 67 $self->_maybe( 'OP', ',' );
3135 }
3136 40 $self->_eat( 'OP', '}}' );
3137  
3138 40 return Zuzu::AST::Expr::PairList->new(
3139 file => $lb->file,
3140 line => $lb->line,
3141 pairs => \@pairs,
3142 );
3143 }
3144  
3145 55 ▶sub parse_set_literal {
Subroutine parse_set_literal: called CC=6 SCAR=17.9
Pod documented
3146 55 my ( $self ) = @_;
3147  
3148 55 my $open = $self->{tok}->value;
3149 55 ▶ my $close = $open eq '<<' ? '>>' : '»';
Branch: 1 branch
BranchTrueFalseTotal
$open eq '<<' ? : 54 1 55
3150 55 my $lb = $self->_eat('OP', $open);
3151 55 my @items;
3152 55 ▶ push @{ $self->{_pending_set_closers} ||= [] }, $close;
Condition100%2/2
$self->{"_pending_set_closers"} ||= []
l!l
2233
MC/DC100%1/1
$self->{"_pending_set_closers"} ||= []
$self->{"_pending_set_closers"}
Truth table100%2/2
A
A= $self->{"_pending_set_closers"}
Aresult
11
00
3153 55 my $closer_guard = Zuzu::Parser::_Impl::_CloserGuard->new($self);
3154 55 ▶ while ( ! $self->{tok}->is_OP($close) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP($close)) 109 55 164
3155 109 ▶ if ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 109 109
3156 0 next;
3157 }
3158 109 my $start = $self->parse_expression;
3159 109 ▶ if ( $self->_maybe('OP', '...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '...')) { } 3 106 109
3160 3 my $end = $self->parse_expression;
3161 3 push @items, Zuzu::AST::Expr::Range->new(
3162 file => $lb->file,
3163 line => $lb->line,
3164 start => $start,
3165 end => $end,
3166 );
3167 }
3168 else {
3169 106 push @items, $start;
3170 }
3171 109 $self->_maybe('OP', ',');
3172 }
3173 55 $self->_eat('OP', $close);
3174  
3175 55 return Zuzu::AST::Expr::Set->new(
3176 file => $lb->file,
3177 line => $lb->line,
3178 items => \@items,
3179 );
3180 }
3181  
3182 43 ▶sub parse_bag_literal {
Subroutine parse_bag_literal: called CC=4 SCAR=13.9
Pod documented
3183 43 my ( $self ) = @_;
3184  
3185 43 my $open = $self->{tok}->value;
3186 43 my $close = '>>>';
3187 43 my $lb = $self->_eat('OP', $open);
3188 43 my @items;
3189 43 ▶ while ( ! $self->{tok}->is_OP($close) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP($close)) 95 43 138
3190 95 ▶ if ( $self->_maybe('OP', ',') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 95 95
3191 0 next;
3192 }
3193 95 my $start = $self->parse_expression;
3194 95 ▶ if ( $self->_maybe('OP', '...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '...')) { } 3 92 95
3195 3 my $end = $self->parse_expression;
3196 3 push @items, Zuzu::AST::Expr::Range->new(
3197 file => $lb->file,
3198 line => $lb->line,
3199 start => $start,
3200 end => $end,
3201 );
3202 }
3203 else {
3204 92 push @items, $start;
3205 }
3206 95 $self->_maybe('OP', ',');
3207 }
3208 43 $self->_eat('OP', $close);
3209  
3210 43 return Zuzu::AST::Expr::Bag->new(
3211 file => $lb->file,
3212 line => $lb->line,
3213 items => \@items,
3214 );
3215 }
3216  
3217 =pod
3218  
3219 =head1 NAME
3220  
3221 Zuzu::Parser::_Impl - recursive-descent parser implementation
3222  
3223 =head1 DESCRIPTION
3224  
3225 Implements token-driven parsing routines that build typed AST node objects and enforce basic syntax rules.
3226  
3227 =head1 INHERITANCE
3228  
3229 Inherits from C<Moo::Object>.
3230  
3231 =head1 ROLES
3232  
3233 None.
3234  
3235 =head1 ATTRIBUTES
3236  
3237 =head2 lexer
3238  
3239 Type: B<InstanceOf["Zuzu::Lexer"]>.
3240  
3241 Lexer instance that provides the token stream.
3242  
3243 =head2 filename
3244  
3245 Type: B<Maybe[Str]>.
3246  
3247 Filename attached to generated tokens and parser errors.
3248  
3249 =head2 tok
3250  
3251 Type: B<InstanceOf["Zuzu::Token"]>.
3252  
3253 Current lookahead token.
3254  
3255 =head2 scopes
3256  
3257 Type: B<ArrayRef[HashRef]>.
3258  
3259 Stack of parser-declared symbol tables for lexical scopes.
3260  
3261 =head1 METHODS
3262  
3263 =head2 new
3264  
3265 Constructs and returns a new instance of this class.
3266  
3267 =head2 parse_program
3268  
3269 Parses a program construct and returns its AST node.
3270  
3271 =head2 parse_statement
3272  
3273 Parses a statement construct and returns its AST node.
3274  
3275 =head2 parse_block
3276  
3277 Parses a block construct and returns its AST node.
3278  
3279 =head2 parse_let
3280  
3281 Parses a let construct and returns its AST node.
3282  
3283 =head2 parse_function_def
3284  
3285 Parses a function def construct and returns its AST node.
3286  
3287 =head2 parse_class_def
3288  
3289 Parses a class def construct and returns its AST node.
3290  
3291 =head2 parse_trait_def
3292  
3293 Parses a trait def construct and returns its AST node.
3294  
3295 =head2 parse_type_ref
3296  
3297 Parses a type ref construct and returns its AST node.
3298  
3299 =head2 parse_method_def
3300  
3301 Parses a method def construct and returns its AST node.
3302  
3303 =head2 parse_if
3304  
3305 Parses a if construct and returns its AST node.
3306  
3307 =head2 parse_while
3308  
3309 Parses a while construct and returns its AST node.
3310  
3311 =head2 parse_for
3312  
3313 Parses a for construct and returns its AST node.
3314  
3315 =head2 parse_return
3316  
3317 Parses a return construct and returns its AST node.
3318  
3319 =head2 parse_import
3320  
3321 Parses a import construct and returns its AST node.
3322  
3323 =head2 parse_expression
3324  
3325 Parses a expression construct and returns its AST node.
3326  
3327 =head2 parse_prefix
3328  
3329 Parses a prefix construct and returns its AST node.
3330  
3331 =head2 parse_primary
3332  
3333 Parses a primary construct and returns its AST node.
3334  
3335 =head2 parse_postfix
3336  
3337 Parses a postfix construct and returns its AST node.
3338  
3339 =head2 parse_array_literal
3340  
3341 Parses a array literal construct and returns its AST node.
3342  
3343 =head2 parse_dict_literal
3344  
3345 Parses a dict literal construct and returns its AST node.
3346  
3347 =head2 parse_set_literal
3348  
3349 Parses a set literal construct and returns its AST node.
3350  
3351 =head2 parse_bag_literal
3352  
3353 Parses a bag literal construct and returns its AST node.
3354  
3355 =head1 SEE ALSO
3356  
3357 Subclasses: none in this distribution.
3358  
3359 =head1 COPYRIGHT AND LICENCE
3360  
3361 B<< Zuzu::Parser::_Impl >> is copyright Toby Inkster.
3362  
3363 It is free software; you may redistribute it and/or modify it under
3364 the terms of either the Artistic License 1.0 or the GNU General Public
3365 License version 2.
3366  
3367 =cut
3368  
3369 {
3370 # Pops the pending set-literal closer even if parsing dies.
3371 package Zuzu::Parser::_Impl::_CloserGuard;
3372 55 ▶ sub new {
Subroutine new: called CC=1 SCAR=0.0
3373 55 my ( $class, $parser ) = @_;
3374 55 return bless { parser => $parser }, $class;
3375 }
3376 55 ▶ sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.1
3377 55 my ( $self ) = @_;
3378 55 ▶ pop @{ $self->{parser}{_pending_set_closers} || [] };
Condition50%1/2
$self->{'parser'}{'_pending_set_closers'} || []
l!l
550
MC/DC0%0/1
$self->{'parser'}{'_pending_set_closers'} || []
$self->{'parser'}{'_pending_set_closers'}
Truth table50%1/2
A
A= $self->{'parser'}{'_pending_set_closers'}
Aresult
11
00
3379 }
3380 }
3381  
3382 78 1;
« blib/lib/Zuzu/Module/DNS.pm ↑ Summary blib/lib/Zuzu/Lexer.pm »