blib/lib/Zuzu/Parser/_Impl.pm

filter: Statementstmt 92.5% 1419 / 1533 Branchbran 82.6% 620 / 750 Conditioncond 75.6% 611 / 808 MC/DCmcdc 38.1% 145 / 380 Subroutinesub 99.2% 135 / 136 Podpod 75.8% 22 / 29 totaltotal 81.1% 2952 / 3636 CC 666 SCAR 38.4
CC
666
Cov
86%
_split_template_parts
342.0
_prec
143.8
parse_primary
101.6
CRAP 46.4
« 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.007000';
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 default => sub {
74 my %root = map {
75 932 ▶ $_ => { kind => 'builtin', mutable => 0 }
Subroutine __ANON__: called CC=1 SCAR=0.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 932 return [ \%root ];
114 },
115 78 );
116  
117 sub BUILD {
118 1409 ▶ my ($self, $args) = @_;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
119  
120 1409 $self->{tok} = $self->{lexer}->next_token;
121  
122 1398 return;
123 }
124  
125 sub _err {
126 164 ▶ my ($self, $msg, $tok) = @_;
Subroutine _err: called CC=2 SCAR=7.6
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 sub _eat {
133 202900 ▶ my ($self, $type, $value) = @_;
Subroutine _eat: called CC=5 SCAR=16.1
134  
135 202900 my $t = $self->{tok};
136 202900 ▶ $self->_err("Expected $type", $t) if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 41 202859 202900
137 202859 ▶ $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 202847 202859
Condition80%4/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
8368511916212
$t->value // ""
l!l
1191740
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 202847 $self->{tok} = $self->{lexer}->next_token;
139  
140 202846 return $t;
141 }
142  
143 sub _maybe {
144 926044 ▶ my ($self, $type, $value) = @_;
Subroutine _maybe: called CC=5 SCAR=16.2
145  
146 926044 my $t = $self->{tok};
147  
148 926044 ▶ return 0 if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 86633 839411 926044
149  
150 839411 ▶ return 0 if defined($value) && (($t->value // '') ne $value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and ($t->value // "") ne $value 790841 48570 839411
Condition60%3/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
048570790841
$t->value // ""
l!l
8394110
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 48570 $self->{tok} = $self->{lexer}->next_token;
152  
153 48568 return $t;
154 }
155  
156 sub _peek_token {
157 16545 ▶ my ($self) = @_;
Subroutine _peek_token: called CC=1 SCAR=0.0
158  
159 16545 my $lexer = $self->{lexer};
160 16545 my ( $pos, $line, $col, $last ) = (
161 $lexer->pos,
162 $lexer->line,
163 $lexer->col,
164 $lexer->last_token,
165 );
166 16545 my $tok = $lexer->next_token;
167 16545 $lexer->pos($pos);
168 16545 $lexer->line($line);
169 16545 $lexer->col($col);
170 16545 $lexer->last_token($last);
171  
172 16545 return $tok;
173 }
174  
175 sub _eat_member_name {
176 9809 ▶ my ( $self ) = @_;
Subroutine _eat_member_name: called CC=3 SCAR=11.2
177  
178 9809 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 9031 778 9809
179 9031 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 13506 ▶sub _push_scope { push @{$_[0]->{scopes}}, {} }
Subroutine _push_scope: called CC=1 SCAR=0.0
188  
189 13482 ▶sub _pop_scope { pop @{$_[0]->{scopes}} }
Subroutine _pop_scope: called CC=1 SCAR=0.0
190  
191 sub _parse_block_in_async_context {
192 3268 ▶ my ( $self, $is_async, $decls, $imports ) = @_;
Subroutine _parse_block_in_async_context: called CC=3 SCAR=11.0
193  
194 3268 ▶ if ( $is_async ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_async) 47 3221 3268
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 3221 local $self->{_async_context_depth} = 0;
201 3221 return $self->_parse_block_with_decls( $decls, $imports );
202 }
203  
204 sub _mark_wildcard_import_in_scope {
205 206 ▶ my ( $self ) = @_;
Subroutine _mark_wildcard_import_in_scope: called CC=1 SCAR=0.0
206  
207 206 $self->{scopes}[-1]{'__wildcard_import__'} = 1;
208  
209 206 return;
210 }
211  
212 sub _has_wildcard_import_in_scope {
213 236 ▶ my ( $self ) = @_;
Subroutine _has_wildcard_import_in_scope: called CC=3 SCAR=11.0
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 sub _declare {
223 13311 ▶ my ($self, $name, $info, $tok, $opts) = @_;
Subroutine _declare: called CC=8 SCAR=21.6
224  
225 13311 ▶ $tok //= $self->{tok};
Condition33%1/3
$tok //= $self->{"tok"}
l!l&&r!l&&!r
1331100
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 13311 ▶ $opts //= {};
Condition100%2/2
$opts //= {}
l!l
102612285
MC/DC100%1/1
$opts //= {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
227 13311 ▶ $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 13311 13311
228 13311 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 1 13310 13311
229 13310 my $scope = $self->{scopes}[-1];
230 13310 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 2 13308 13310
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 13308 $scope->{$name} = $info;
237 }
238  
239 sub _declare_function_name {
240 1523 ▶ my ( $self, $name, $tok, $is_predeclared ) = @_;
Subroutine _declare_function_name: called CC=7 SCAR=20.5
241  
242 1523 ▶ $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 1523 1523
243 1523 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 0 1523 1523
244 1523 my $scope = $self->{scopes}[-1];
245 1523 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 32 1491 1523
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 1491 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$is_predeclared ? : 32 1459 1491
255 kind => $is_predeclared ? 'func_predecl' : 'func',
256 mutable => 0,
257 };
258 }
259  
260 sub _lookup {
261 47783 ▶ my ($self, $name) = @_;
Subroutine _lookup: called CC=3 SCAR=11.0
262  
263 47783 ▶ for (my $i = $#{$self->{scopes}}; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 93514 279 93793
264  
265 93514 ▶ return $self->{scopes}[$i]{$name} if exists $self->{scopes}[$i]{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"scopes"}[$i]{$name} 47504 46010 93514
266 }
267  
268 279 return undef;
269 }
270  
271 sub parse_program {
272 921 ▶ my ($self) = @_;
Subroutine parse_program: called CC=4 SCAR=13.9
Pod documented
273  
274 921 my @stmts;
275 {
276 921 local $self->{_async_context_depth} =
277 921 ▶ ( $self->{_async_context_depth} // 0 ) + 1;
Condition50%1/2
$self->{"_async_context_depth"} // 0
l!l
0921
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 921 ▶ while ( ! $self->{tok}->is_EOF ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_EOF) 4186 751 4937
279 4186 $self->_eat_optional_statement_separators;
280 4186 ▶ last if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 4184 4186
281 4184 push @stmts, $self->parse_statement;
282 }
283 }
284  
285 753 return Zuzu::AST::Program->new(file => $self->{filename}, line => 1, statements => \@stmts);
286 }
287  
288 sub _eat_optional_statement_separators {
289 26309 ▶ my ( $self ) = @_;
Subroutine _eat_optional_statement_separators: called CC=2 SCAR=6.9
290  
291 26309 ▶ while ( $self->_maybe( 'OP', ';' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 5 26309 26314
292 # Consume no-op statement separators.
293 }
294  
295 26309 return;
296 }
297  
298 sub parse_statement {
299 26307 ▶ my ($self) = @_;
Subroutine parse_statement: called CC=27 SCAR=33.0
Pod documented
300  
301 26307 my $t = $self->{tok};
302  
303 26307 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 5853 20454 26307
Condition100%3/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
548037320454
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 5853 return $self->parse_let;
306 }
307 20454 ▶ if ( $t->is_KW('function') or $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("function") or $t->is_KW("async")) 1539 18915 20454
Condition100%3/3
$t->is_KW("function") or $t->is_KW("async")
l!l&&r!l&&!r
14964318915
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 1539 return $self->parse_function_def;
310 }
311 18915 ▶ if ( $t->is_KW('class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("class")) 307 18608 18915
312  
313 307 return $self->parse_class_def;
314 }
315 18608 ▶ if ( $t->is_KW('trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("trait")) 14 18594 18608
316  
317 14 return $self->parse_trait_def;
318 }
319 18594 ▶ if ( $t->is_KW('if') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("if")) 3528 15066 18594
320  
321 3528 return $self->parse_if;
322 }
323 15066 ▶ if ( $t->is_KW('while') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("while")) 496 14570 15066
324  
325 496 return $self->parse_while;
326 }
327 14570 ▶ if ( $t->is_KW('for') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("for")) 748 13822 14570
328  
329 748 return $self->parse_for;
330 }
331 13822 ▶ if ( $t->is_KW('switch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("switch")) 31 13791 13822
332  
333 31 return $self->parse_switch;
334 }
335 13791 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 130 13661 13791
336  
337 130 return $self->parse_try;
338 }
339 13661 ▶ if ( $t->is_KW('return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("return")) 5296 8365 13661
340  
341 5296 return $self->parse_return;
342 }
343 8365 ▶ 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")) 14 8186 8200
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
167128186
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug")
l!l&&r!l&&!r
16528198
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn")
l!l&&r!l&&!r
15968200
$t->is_KW("say") or $t->is_KW("print")
l!l&&r!l&&!r
351248206
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 8186 ▶ if ( $t->is_KW('throw') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("throw")) 34 8152 8186
353 34 my $kw = $self->_eat('KW', 'throw');
354 34 my $expr = $self->parse_expression;
355 34 my $stmt = Zuzu::AST::Stmt::Throw->new(
356 file => $kw->file,
357 line => $kw->line,
358 expr => $expr,
359 );
360  
361 34 return $self->_finish_with_postfix_condition($stmt);
362 }
363 8152 ▶ if ( $t->is_KW('die') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("die")) 817 7335 8152
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 7335 ▶ if ( $t->is_KW('next') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("next")) 277 7058 7335
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 7058 ▶ if ( $t->is_KW('continue') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("continue")) 20 7038 7058
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 7038 ▶ if ( $t->is_KW('last') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("last")) 85 6953 7038
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 6953 ▶ if ( $t->is_KW('from') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("from")) 711 6242 6953
393  
394 711 return $self->parse_import;
395 }
396 6242 ▶ if ( $t->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("{")) 19 6223 6242
397  
398 19 return $self->parse_block;
399 }
400  
401 # assignment or expr stmt
402 6223 my $expr = $self->parse_expression;
403  
404 6157 ▶ 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")) 2216 3941 6157
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Stmt::Assign")
!ll&&!rl&&r
039412216
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 2216 return $self->_finish_with_postfix_condition($expr);
406 }
407  
408 3941 my $stmt = Zuzu::AST::Stmt::Expr->new(file => $t->file, line => $t->line, expr => $expr);
409  
410 3941 return $self->_finish_with_postfix_condition($stmt);
411 }
412  
413 sub parse_builtin_statement {
414 179 ▶ my ($self) = @_;
Subroutine parse_builtin_statement: called CC=4 SCAR=13.9
Pod undocumented
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 sub _finish_with_postfix_condition {
467 12855 ▶ my ($self, $stmt) = @_;
Subroutine _finish_with_postfix_condition: called CC=5 SCAR=16.1
468  
469 12855 my $has_postfix = 0;
470 12855 my $negate = 0;
471 12855 ▶ if ( $self->{tok}->is_KW('if') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_KW('if')) { } 1116 11739 12855
elsif ($self->{'tok'}->is_KW('unless')) { } 94 11645 11739
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 12855 ▶ if ( $has_postfix ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_postfix) { } 1210 11645 12855
elsif ($self->{'tok'}->is_KW('for')) { } 9 11636 11645
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 12855 $self->_eat_statement_separator;
510  
511 12849 return $stmt;
512 }
513  
514 sub _eat_statement_separator {
515 19378 ▶ my ($self) = @_;
Subroutine _eat_statement_separator: called CC=4 SCAR=13.9
516  
517 19378 ▶ return if $self->_maybe('OP', ';');
Branch: 1 branch
BranchTrueFalseTotal
if $self->_maybe("OP", ";") 19358 18 19376
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 sub parse_block {
525 5840 ▶ my ($self) = @_;
Subroutine parse_block: called CC=4 SCAR=13.9
Pod documented
526  
527 5840 my $lb = $self->_eat('OP', '{');
528 5840 $self->_push_scope;
529 5840 my @stmts;
530 5840 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 11034 5829 16863
531 11034 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 6 11028 11034
532 11028 $self->_eat_optional_statement_separators;
533 11028 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 11028 11028
534 11028 push @stmts, $self->parse_statement;
535 }
536 5829 $self->_eat('OP', '}');
537 5829 $self->_pop_scope;
538  
539 5829 return Zuzu::AST::Block->new(file => $lb->file, line => $lb->line, statements => \@stmts);
540 }
541  
542 sub _parse_let_decl {
543 5854 ▶ my ( $self, $expect_semicolon ) = @_;
Subroutine _parse_let_decl: called CC=11 SCAR=24.2
544  
545 5854 my $kw = $self->_eat('KW');
546 5854 ▶ my $is_const = ($kw->value eq 'const') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$kw->value eq 'const' ? : 373 5481 5854
547  
548 5854 ▶ if ( $self->{tok}->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("{")) 22 5832 5854
549 22 return $self->_parse_let_unpack_decl( $kw, $is_const, $expect_semicolon );
550 }
551  
552 5832 my ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
553 5817 my $is_weak_storage = $self->_parse_optional_weak_modifier('declaration');
554  
555 # Detect forbidden "let x = 1"
556 5817 ▶ if ($self->{tok}->is_OP && $self->{tok}->value eq '=') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "=") 0 5817 5817
Condition33%1/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "="
!ll&&!rl&&r
058170
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 5817 my $init;
561 5817 ▶ if ($self->_maybe('OP', ':=')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':=')) { } 5765 52 5817
562 5765 $init = $self->parse_expression;
563 5745 ▶ $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
045741
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 5797 ▶ $self->_eat_statement_separator if $expect_semicolon;
Branch: 1 branch
BranchTrueFalseTotal
if $expect_semicolon 5796 1 5797
568  
569 5796 ▶ $self->_declare(
Branch: 2 branches
BranchTrueFalseTotal
$is_const ? : 371 5425 5796
$is_const ? : 371 5425 5796
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 5794 ▶ return Zuzu::AST::Stmt::Let->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_storage ? : 8 5786 5794
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 sub _parse_let_unpack_decl {
587 22 ▶ my ( $self, $kw, $is_const, $expect_semicolon ) = @_;
Subroutine _parse_let_unpack_decl: called CC=8 SCAR=20.9
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 sub _parse_unpack_binding {
633 36 ▶ my ( $self ) = @_;
Subroutine _parse_unpack_binding: called CC=10 SCAR=23.2
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 sub parse_let {
717 5853 ▶ my ($self) = @_;
Subroutine parse_let: called CC=1 SCAR=0.0
Pod documented
718  
719 5853 return $self->_parse_let_decl(1);
720 }
721  
722 sub parse_function_def {
723 1539 ▶ my ($self) = @_;
Subroutine parse_function_def: called CC=15 SCAR=28.2
Pod documented
724  
725 1539 my $async_tok;
726 1539 ▶ if ( $self->{tok}->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("async")) 43 1496 1539
727 43 $async_tok = $self->_eat('KW', 'async');
728 }
729 1539 my $kw = $self->_eat('KW', 'function');
730 1539 my $name_tok = $self->_eat('IDENT');
731 1523 my $name = $name_tok->value;
732  
733 1523 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 32 1491 1523
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 1491 $self->_declare_function_name( $name, $name_tok, 0 );
746  
747 1491 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
748 1490 my $return_type = $self->_parse_optional_return_type;
749  
750 my @arg_decls = map {
751 {
752 name => $_,
753 mutable => 0,
754 2260 ▶ declared_type => $param_types->{$_} // 'Any',
Condition50%1/2
$param_types->{$_} // "Any"
l!l
22600
MC/DC0%0/1
$param_types->{$_} // "Any"
$param_types->{$_}
Truth table50%1/2
A
A= $param_types->{$_}
Aresult
11
00
755 }
756 1490 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
14900
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
757 1490 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 28 1462 1490
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 1490 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 64 1426 1490
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 1490 ▶ my $is_async = $async_tok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$async_tok ? : 43 1447 1490
772 1490 my $body = $self->_parse_block_in_async_context(
773 $is_async,
774 \@arg_decls,
775 [],
776 );
777  
778 1483 ▶ return Zuzu::AST::Stmt::Function->new(
Condition66%4/6
$async_tok // $kw
l!l&&r!l&&!r
4214410
$async_tok // $kw
l!l&&r!l&&!r
4214410
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 sub parse_class_def {
797 307 ▶ my ($self) = @_;
Subroutine parse_class_def: called CC=20 SCAR=30.8
Pod documented
798  
799 307 my $kw = $self->_eat('KW', 'class');
800 307 my $name_tok = $self->_eat('IDENT');
801 307 my $name = $name_tok->value;
802 307 my $parent;
803 my @traits;
804 307 ▶ if ( $self->_maybe('KW', 'extends') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("KW", "extends")) 131 176 307
805 131 $parent = $self->parse_type_ref;
806 }
807 307 ▶ 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 286 307
Condition100%3/3
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
l!l&&r!l&&!r
174286
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 306 $self->_declare($name, { kind => 'class', mutable => 0 }, $name_tok);
816  
817 306 my @fields;
818 my @methods;
819 306 my @static_methods;
820 306 my @classes;
821  
822 306 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 96 210 306
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 210 $self->_eat('OP', '{');
837 210 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 1950 209 2159
838 1950 my $t = $self->{tok};
839 1950 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 466 1484 1950
Condition66%2/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
46601484
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 466 my $decl = $self->_eat('KW');
841 466 my ( $declared_type, $name ) = $self->_parse_typed_identifier;
842 466 my $accessors = $self->_parse_field_accessor_list;
843 466 my $is_weak_storage = $self->_parse_optional_weak_modifier('field declaration');
844 466 my $init;
845 466 ▶ if ( $self->{tok}->is_OP('=') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("=")) 0 466 466
846 0 $self->_err("Invalid assignment '=' in declaration. Use ':='", $self->{tok});
847 }
848 466 ▶ if ( $self->_maybe('OP', ':=') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ":=")) 374 92 466
849 374 $init = $self->parse_expression;
850 374 ▶ $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
11372
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 466 $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 466 ▶ accessors => [ @{ $accessors // [] } ],
Branch: 2 branches
BranchTrueFalseTotal
$decl->value eq 'const' ? : 0 466 466
$is_weak_storage ? : 24 442 466
Condition50%1/2
$accessors // []
l!l
4660
MC/DC0%0/1
$accessors // []
$accessors
Truth table50%1/2
A
A= $accessors
Aresult
11
00
860 };
861 466 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 466 next;
870 }
871 1484 ▶ 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")) 1412 0 1412
Condition83%5/6
$t->is_KW("static") or $t->is_KW("async") or $t->is_KW("method")
l!l&&r!l&&!r
7514090
$t->is_KW("static") or $t->is_KW("async")
l!l&&r!l&&!r
7231409
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 1484 my $m = $self->parse_method_def( \@fields );
873 1483 ▶ if ( $m->is_static ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m->is_static) { } 73 1410 1483
874 73 push @static_methods, $m;
875 }
876 else {
877 1410 push @methods, $m;
878 }
879 1483 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 209 $self->_eat('OP', '}');
888  
889 209 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 sub _parse_field_accessor_list {
903 466 ▶ my ( $self ) = @_;
Subroutine _parse_field_accessor_list: called CC=5 SCAR=16.2
904  
905 466 ▶ return [] if not $self->_maybe( 'KW', 'with' );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("KW", "with") 426 40 466
906  
907 40 my %valid = map { $_ => 1 } qw( get set clear has );
908 40 my @ops;
909 40 while (1) {
910 84 my $tok = $self->_eat('IDENT');
911 84 my $kind = $tok->value;
912 84 ▶ if ( not $valid{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($valid{$kind}) 0 84 84
913 0 $self->_err(
914 "Unknown field accessor '$kind'. Expected one of: get, set, clear, has",
915 $tok,
916 );
917 }
918 84 ▶ push @ops, $kind if not grep { $_ eq $kind } @ops;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $kind;} @ops 84 0 84
919 84 ▶ last if not $self->_maybe('OP', ',');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", ",") 40 44 84
920 }
921  
922 40 return \@ops;
923 }
924  
925 sub _parse_optional_weak_modifier {
926 14660 ▶ my ( $self, $context ) = @_;
Subroutine _parse_optional_weak_modifier: called CC=6 SCAR=21.8
927  
928 14660 ▶ return 0 if not $self->{tok}->is_KW('but');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tok"}->is_KW("but") 14602 58 14660
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 sub _build_field_accessor_methods {
945 466 ▶ my ( $self, %args ) = @_;
Subroutine _build_field_accessor_methods: called CC=9 SCAR=22.0
946  
947 466 my $name = $args{name};
948 466 ▶ my $declared_type = $args{declared_type} // 'Any';
Condition50%1/2
$args{"declared_type"} // "Any"
l!l
4660
MC/DC0%0/1
$args{"declared_type"} // "Any"
$args{"declared_type"}
Truth table50%1/2
A
A= $args{"declared_type"}
Aresult
11
00
949 466 ▶ my $accessors = $args{accessors} // [];
Condition50%1/2
$args{"accessors"} // []
l!l
4660
MC/DC0%0/1
$args{"accessors"} // []
$args{"accessors"}
Truth table50%1/2
A
A= $args{"accessors"}
Aresult
11
00
950 466 ▶ my $is_weak_storage = $args{is_weak_storage} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'is_weak_storage'} ? : 24 442 466
951 466 my $file = $args{file};
952 466 my $line = $args{line};
953 466 my @methods;
954  
955 466 for my $kind ( @{ $accessors } ) {
956 84 ▶ if ( $kind eq 'get' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($kind eq 'get') { } 38 46 84
elsif ($kind eq 'set') { } 20 26 46
elsif ($kind eq 'clear') { } 10 16 26
elsif ($kind eq 'has') { } 16 0 16
957 38 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 38 $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 466 return \@methods;
1136 }
1137  
1138 sub parse_trait_def {
1139 14 ▶ my ( $self ) = @_;
Subroutine parse_trait_def: called CC=5 SCAR=16.7
Pod documented
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 sub parse_type_ref {
1177 155 ▶ my ( $self ) = @_;
Subroutine parse_type_ref: called CC=3 SCAR=11.0
Pod documented
1178  
1179 155 my $root_tok = $self->_eat('IDENT');
1180 155 my $info = $self->_lookup( $root_tok->value );
1181 155 ▶ if ( !$info and !$self->_has_wildcard_import_in_scope ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info or $self->_has_wildcard_import_in_scope) 1 154 155
Condition66%2/3
$info or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
15401
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 154 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 sub parse_method_def {
1194 1516 ▶ my ( $self, $fields ) = @_;
Subroutine parse_method_def: called CC=23 SCAR=32.2
Pod documented
1195  
1196 1516 my $is_static = 0;
1197 1516 my $is_async = 0;
1198 1516 my $saw_static_before_async = 0;
1199 1516 my $start_tok;
1200 1516 ▶ 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 1516 1593
Condition100%3/3
$self->{"tok"}->is_KW("static") or $self->{"tok"}->is_KW("async")
l!l&&r!l&&!r
7341516
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 1516 my $kw = $self->_eat('KW', 'method');
1221 1516 ▶ $start_tok //= $kw;
Condition66%2/3
$start_tok //= $kw
l!l&&r!l&&!r
7514410
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 1516 my $name = $self->_eat_member_name;
1223  
1224 1516 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 9 1507 1516
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 1507 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
1238 1507 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 1507 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
15070
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
1247 1507 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 32 1475 1507
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 1507 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 47 1460 1507
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 1507 push @locals, 'self';
1262 1507 ▶ if ( ! $is_static ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_static) 1437 70 1507
1263 push @locals, map {
1264 {
1265 name => $_->{name},
1266 mutable => $_->{is_const} ? 0 : 1,
1267 7631 ▶ declared_type => $_->{declared_type} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$_->{'is_const'} ? : 0 7631 7631
Condition50%1/2
$_->{"declared_type"} // "Any"
l!l
76310
MC/DC0%0/1
$_->{"declared_type"} // "Any"
$_->{"declared_type"}
Truth table50%1/2
A
A= $_->{"declared_type"}
Aresult
11
00
1268 }
1269 1437 ▶ } @{ $fields // [] };
Condition50%1/2
$fields // []
l!l
14370
MC/DC0%0/1
$fields // []
$fields
Truth table50%1/2
A
A= $fields
Aresult
11
00
1270 }
1271 1507 push @locals, 'super';
1272 1507 my $body = $self->_parse_block_in_async_context(
1273 $is_async,
1274 \@locals,
1275 [],
1276 );
1277  
1278 1506 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 sub _parse_optional_return_type {
1298 3268 ▶ my ( $self ) = @_;
Subroutine _parse_optional_return_type: called CC=3 SCAR=11.0
1299  
1300 3268 ▶ return 'Any' if ! $self->_maybe('OP', '->') and ! $self->_maybe('OP', 'โ†’');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}") 3249 19 3268
Condition100%3/3
$self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}")
l!l&&r!l&&!r
1093249
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 sub _parse_param_list {
1307 3313 ▶ my ($self) = @_;
Subroutine _parse_param_list: called CC=18 SCAR=29.0
1308  
1309 3313 $self->_eat('OP', '(');
1310 3313 my @params;
1311 my $vararg;
1312 3313 my $named_vararg;
1313 3313 my %param_types;
1314 3313 my %param_optional;
1315 3313 my %param_defaults;
1316 3313 my $vararg_type = 'Any';
1317 3313 my $named_vararg_type = 'PairList';
1318 3313 my $seen_optional = 0;
1319 3313 $self->_push_scope;
1320 3313 ▶ if ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 2457 856 3313
1321 2457 while (1) {
1322 4986 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 130 4856 4986
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 4856 my ( $type_name, $param_name ) = $self->_parse_param_name;
1357 4853 push @params, $param_name;
1358 4853 $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 4853 );
1368 4853 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_maybe('OP', '?')) { } 214 4639 4853
elsif ($self->_maybe('OP', ':=')) { } 174 4465 4639
elsif ($seen_optional) { } 1 4464 4465
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 4852 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 2294 2558 4852
1383 2558 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 7 2551 2558
1384 7 next;
1385 }
1386 2551 $self->_eat('OP', ',');
1387 2551 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 29 2522 2551
1388 }
1389 }
1390 3309 $self->_eat('OP', ')');
1391 3309 $self->_pop_scope;
1392  
1393 3309 return ( \@params, $vararg, \%param_types, $vararg_type, \%param_optional, \%param_defaults, $named_vararg, $named_vararg_type );
1394 }
1395  
1396 sub _parse_param_name {
1397 5183 ▶ my ( $self ) = @_;
Subroutine _parse_param_name: called CC=2 SCAR=6.9
1398  
1399 5183 my $first = $self->_eat('IDENT');
1400  
1401 5180 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 1559 3621 5180
1402 1559 my $name_tok = $self->_eat('IDENT');
1403 1559 return ( $first->value, $name_tok->value );
1404 }
1405  
1406 3621 return ( 'Any', $first->value );
1407 }
1408  
1409 sub _parse_typed_identifier {
1410 6311 ▶ my ( $self ) = @_;
Subroutine _parse_typed_identifier: called CC=2 SCAR=6.9
1411  
1412 6311 my $first = $self->_eat('IDENT');
1413 6296 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 207 6089 6296
1414 207 my $name_tok = $self->_eat('IDENT');
1415 207 return ( $first->value, $name_tok->value, $name_tok );
1416 }
1417  
1418 6089 return ( 'Any', $first->value, $first );
1419 }
1420  
1421 sub _parse_block_with_decls {
1422 3268 ▶ my ( $self, $decls, $extras ) = @_;
Subroutine _parse_block_with_decls: called CC=15 SCAR=27.7
1423  
1424 3268 my $lb = $self->_eat('OP', '{');
1425 3268 $self->_push_scope;
1426 3268 ▶ for my $n ( @{ $decls // [] }, @{ $extras // [] } ) {
Condition50%2/4
$decls // []
l!l
32680
$extras // []
l!l
32680
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 15606 ▶ next if ! defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 15606 15606
1428 15606 my ( $name, $mutable, $declared_type );
1429 15606 ▶ if ( ref($n) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n eq 'HASH') { } 12592 3014 15606
1430 12592 $name = $n->{name};
1431 12592 ▶ $mutable = defined $n->{mutable} ? $n->{mutable} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $n->{'mutable'} ? : 12592 0 12592
1432 12592 ▶ $declared_type = $n->{declared_type} // 'Any';
Condition50%1/2
$n->{"declared_type"} // "Any"
l!l
125920
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 3014 $name = $n;
1436 3014 $mutable = 1;
1437 3014 $declared_type = 'Any';
1438 }
1439 15606 ▶ next if ! defined $name || $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 15606 15606
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
0015606
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 15606 my $scope = $self->{scopes}[-1];
1441 15606 ▶ next if exists $scope->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $scope->{$name} 2 15604 15606
1442 15604 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$mutable ? : 10643 4961 15604
1443 kind => 'local',
1444 mutable => $mutable ? 1 : 0,
1445 declared_type => $declared_type,
1446 };
1447 }
1448 3268 my @stmts;
1449 3268 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 10803 3261 14064
1450 10803 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 10801 10803
1451 10801 $self->_eat_optional_statement_separators;
1452 10801 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 10801 10801
1453 10801 push @stmts, $self->parse_statement;
1454 }
1455 3261 $self->_eat('OP', '}');
1456 3260 $self->_pop_scope;
1457  
1458 3260 return Zuzu::AST::Block->new(file => $lb->file, line => $lb->line, statements => \@stmts);
1459 }
1460  
1461 sub parse_if {
1462 3868 ▶ my ($self) = @_;
Subroutine parse_if: called CC=4 SCAR=13.9
Pod documented
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 sub parse_while {
1486 496 ▶ my ($self) = @_;
Subroutine parse_while: called CC=1 SCAR=0.0
Pod documented
1487  
1488 496 my $kw = $self->_eat('KW', 'while');
1489 496 $self->_eat('OP', '(');
1490 496 my $cond = $self->parse_expression;
1491 495 $self->_eat('OP', ')');
1492 495 my $body = $self->parse_block;
1493  
1494 495 return Zuzu::AST::Stmt::While->new(file => $kw->file, line => $kw->line, cond => $cond, body => $body);
1495 }
1496  
1497 sub parse_for {
1498 748 ▶ my ($self) = @_;
Subroutine parse_for: called CC=14 SCAR=26.8
Pod documented
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 sub parse_switch {
1574 31 ▶ my ($self) = @_;
Subroutine parse_switch: called CC=9 SCAR=22.1
Pod undocumented
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 sub _parse_switch_case_value {
1638 305 ▶ my ($self) = @_;
Subroutine _parse_switch_case_value: called CC=6 SCAR=24.6
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 sub _switch_comparator_from_token {
1665 320 ▶ my ( $self, $tok ) = @_;
Subroutine _switch_comparator_from_token: called CC=5 SCAR=16.2
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 sub _is_switch_comparator {
1674 15 ▶ my ($value) = @_;
Subroutine _is_switch_comparator: called CC=1 SCAR=0.0
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 sub _parse_switch_body_until_labels {
1687 281 ▶ my ($self) = @_;
Subroutine _parse_switch_body_until_labels: called CC=9 SCAR=22.1
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 sub _parse_switch_body_until_end {
1709 7 ▶ my ($self) = @_;
Subroutine _parse_switch_body_until_end: called CC=6 SCAR=18.6
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 sub parse_try {
1727 153 ▶ my ( $self ) = @_;
Subroutine parse_try: called CC=8 SCAR=21.3
Pod undocumented
1728  
1729 153 my $kw = $self->_eat('KW', 'try');
1730 153 my $block = $self->parse_block;
1731 152 my @catches;
1732 152 ▶ while ( $self->_maybe('KW', 'catch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("KW", "catch")) 154 152 306
1733 154 my ( $type_expr, $name );
1734 154 ▶ if ( $self->_maybe('OP', '(') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', '(')) { } 68 86 154
1735 68 ▶ if ( $self->_maybe('OP', ')') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ')')) { } 0 68 68
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 68 my $first = $self->_eat('IDENT');
1746 68 ▶ if ( $self->_maybe('OP', ')') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ')')) { } 1 67 68
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 67 my $info = $self->_lookup( $first->value );
1757 67 ▶ if ( !$info and !$self->_has_wildcard_import_in_scope ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info or $self->_has_wildcard_import_in_scope) 0 67 67
Condition33%1/3
$info or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
6700
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 67 $type_expr = Zuzu::AST::Expr::TypeRef->new(
1761 file => $first->file,
1762 line => $first->line,
1763 root => $first->value,
1764 member => undef,
1765 );
1766 67 $name = $self->_eat('IDENT')->value;
1767 67 $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 154 $self->_push_scope;
1781 154 $self->_declare($name, { kind => 'let', mutable => 1 }, $kw);
1782 154 my $catch_block = $self->parse_block;
1783 154 $self->_pop_scope;
1784 154 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 152 ▶ $self->_err("try requires at least one catch clause", $self->{tok}) if !@catches;
Branch: 1 branch
BranchTrueFalseTotal
unless @catches 0 152 152
1794  
1795 152 return Zuzu::AST::Stmt::Try->new(
1796 file => $kw->file,
1797 line => $kw->line,
1798 block => $block,
1799 catches => \@catches,
1800 );
1801 }
1802  
1803 sub parse_return {
1804 5296 ▶ my ($self) = @_;
Subroutine parse_return: called CC=6 SCAR=18.1
Pod documented
1805  
1806 5296 my $kw = $self->_eat('KW', 'return');
1807 5296 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 5296 ▶ 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") 5184 112 5296
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
11205184
$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
11205184
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF
l!l&&r!l&&!r
11205184
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}")
l!l&&r!l&&!r
11115184
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 5296 my $stmt = Zuzu::AST::Stmt::Return->new(file => $kw->file, line => $kw->line, expr => $expr);
1816  
1817 5296 return $self->_finish_with_postfix_condition($stmt);
1818 }
1819  
1820 sub parse_import {
1821 711 ▶ my ($self) = @_;
Subroutine parse_import: called CC=19 SCAR=29.5
Pod documented
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/DC66%2/3
$saw_star and $try_mode || defined $condition_expr
$saw_star $try_mode defined $condition_expr
Truth table75%3/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 sub _eat_import_path_segment {
1906 1115 ▶ my ( $self ) = @_;
Subroutine _eat_import_path_segment: called CC=3 SCAR=11.4
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 sub parse_expression {
1919 59607 ▶ my ($self) = @_;
Subroutine parse_expression: called CC=23 SCAR=31.4
Pod documented
1920  
1921 59607 my $cond = $self->parse_chain_expression;
1922  
1923 59507 ▶ 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
22241457269
$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
179143357283
$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
1787457716
$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
1786157720
$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
1781557721
$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
1780157726
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=")
l!l&&r!l&&!r
1775557727
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=")
l!l&&r!l&&!r
1769657732
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=")
l!l&&r!l&&!r
160316657738
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=")
l!l&&r!l&&!r
1595857904
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 59507 ▶ if ( $assign_op ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op) 2238 57269 59507
1935 2238 $self->_assert_mutable_target( $cond, $assign_op );
1936 2233 ▶ if ( $assign_op->value eq '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op->value eq "~=") 8 2225 2233
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 2225 my $rhs = $self->parse_expression;
1955 2225 my $is_weak_write = $self->_parse_optional_weak_modifier('assignment');
1956 2225 ▶ if ( $is_weak_write and $assign_op->value ne ':=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak_write and $assign_op->value ne ":=") 3 2222 2225
Condition100%3/3
$is_weak_write and $assign_op->value ne ":="
!ll&&!rl&&r
2203193
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 2222 ▶ 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 2221 2222
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
221741
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op
!ll&&!rl&&r
221705
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary")
!ll&&!rl&&r
2203145
$is_weak_write and builtin::blessed($cond)
!ll&&!rl&&r
2203019
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 2221 ▶ return Zuzu::AST::Stmt::Assign->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_write ? : 18 2203 2221
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 57269 return $cond;
1980 }
1981  
1982 sub parse_ternary_expression {
1983 59637 ▶ my ($self) = @_;
Subroutine parse_ternary_expression: called CC=3 SCAR=11.0
Pod undocumented
1984  
1985 59637 my $cond = $self->_parse_prec(0);
1986  
1987 59537 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?")) 576 58961 59537
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 58961 ▶ if ( $self->_maybe('OP', '?:') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?:")) 23 58938 58961
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 58938 return $cond;
2014 }
2015  
2016 sub _chain_direction {
2017 57872 ▶ my ( $self, $op ) = @_;
Subroutine _chain_direction: called CC=5 SCAR=16.1
2018  
2019 57872 ▶ return 'right' if $op eq 'โ–ท' or $op eq '|>';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25b7}" or $op eq "|>" 27 57845 57872
Condition100%3/3
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
19857845
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 57845 ▶ return 'left' if $op eq 'โ—' or $op eq '<|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25c1}" or $op eq "<|" 3 57842 57845
Condition66%2/3
$op eq "\x{25c1}" or $op eq "<|"
l!l&&r!l&&!r
0357842
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 57842 return undef;
2023 }
2024  
2025 sub parse_chain_expression {
2026 59607 ▶ my ($self) = @_;
Subroutine parse_chain_expression: called CC=11 SCAR=24.1
Pod undocumented
2027  
2028 59607 my $left = $self->parse_ternary_expression;
2029 59509 my $op_tok = $self->{tok};
2030 59509 ▶ return $left if !$op_tok->is_OP;
Branch: 1 branch
BranchTrueFalseTotal
unless $op_tok->is_OP 1668 57841 59509
2031  
2032 57841 my $direction = $self->_chain_direction( $op_tok->value );
2033 57841 ▶ return $left if !$direction;
Branch: 1 branch
BranchTrueFalseTotal
unless $direction 57826 15 57841
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 sub _parse_leftward_chain_rhs {
2074 3 ▶ my ($self) = @_;
Subroutine _parse_leftward_chain_rhs: called CC=4 SCAR=17.9
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 sub _prec {
2098 17837 ▶ my ($self, $op) = @_;
Subroutine _prec: called CC=104 SCAR=49.7
2099  
2100 17837 ▶ 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}?" 17 16745 16762
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
1092016745
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?"
l!l&&r!l&&!r
10751716745
$op eq "or" or $op eq "\x{22c1}"
l!l&&r!l&&!r
1075016762
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 16745 ▶ 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 16745 16745
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
0016745
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
0016745
$op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
0016745
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 16745 ▶ 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}?" 0 16735 16735
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
10016735
$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
10016735
$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
10016735
$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
10016735
$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
10016735
$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
10016735
$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
10016735
$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
10016735
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?"
l!l&&r!l&&!r
10016735
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?"
l!l&&r!l&&!r
10016735
$op eq "xor" or $op eq "\x{22bb}"
l!l&&r!l&&!r
8216735
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 16735 ▶ 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}?" 0 14688 14688
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
2047014688
$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
2047014688
$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
2047014688
$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
2047014688
$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
2047014688
$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
2047014688
$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
2047014688
$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
2046114688
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?"
l!l&&r!l&&!r
2046014689
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?"
l!l&&r!l&&!r
2046014689
$op eq "and" or $op eq "\x{22c0}"
l!l&&r!l&&!r
2046014689
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 14688 ▶ return 5 if $op eq 'default';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "default" 18 14670 14688
2113  
2114 14670 ▶ 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}" 544 12341 12885
Condition100%9/9
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
l!l&&r!l&&!r
185247712341
$op eq "==" or $op eq "\x{2261}" or $op eq "!="
l!l&&r!l&&!r
17856712818
$op eq "==" or $op eq "\x{2261}"
l!l&&r!l&&!r
309147612885
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 12341 ▶ 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}" 0 8192 8192
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
414908192
$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
414908192
$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
414908192
$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
4128218192
$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
4112168213
$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
4085278229
$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
37932928256
$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
3744498548
$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
374048597
$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
27559858601
$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
275509586
$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
275329586
$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
275309588
$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
275129588
$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
275109590
$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
274839590
$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
274269593
$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
273489599
$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
26271079607
$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
262709714
$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
262709714
$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
262709714
$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
262709714
$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
262709714
$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
262709714
$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
262619714
$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
2589379715
$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
258549752
$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
257969756
$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
257639762
$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
257339765
$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
24371369768
$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
18136249904
$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
1813010528
$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
1812110528
$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
18001210529
$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
1795510541
$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
154525010546
$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
1543210796
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<="
l!l&&r!l&&!r
14737010798
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">"
l!l&&r!l&&!r
109138210868
$op eq "=" or $op eq "\x{2260}" or $op eq "<"
l!l&&r!l&&!r
35873311250
$op eq "=" or $op eq "\x{2260}"
l!l&&r!l&&!r
355311983
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 8192 ▶ return 7 if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 8 8184 8192
2119  
2120 8184 ▶ return 8 if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 6 8178 8184
2121  
2122 8178 ▶ return 9 if $op eq '&';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "&" 21 8157 8178
2123  
2124 8157 ▶ 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}" 1 8155 8156
Condition77%7/9
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
l!l&&r!l&&!r
118155
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>"
l!l&&r!l&&!r
108156
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
018156
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 8155 ▶ 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}" 5 8134 8139
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
2018134
$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
1648135
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}"
l!l&&r!l&&!r
1608139
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection"
l!l&&r!l&&!r
1068139
$op eq "union" or $op eq "\x{22c3}"
l!l&&r!l&&!r
738145
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 8134 ▶ return 12 if $op eq '_' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "_" 2215 5919 8134
2129  
2130 5919 ▶ return 13 if $op eq '+' || $op eq '-' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "+" or $op eq "-" 1164 4755 5919
Condition100%3/3
$op eq "+" or $op eq "-"
l!l&&r!l&&!r
7793854755
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 4755 ▶ 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" 63 4507 4570
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
189594507
$op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}"
l!l&&r!l&&!r
18544566
$op eq "*" or $op eq "/" or $op eq "\x{d7}"
l!l&&r!l&&!r
165204570
$op eq "*" or $op eq "/"
l!l&&r!l&&!r
125404590
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 4507 ▶ return 15 if $op eq '**';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "**" 5 4502 4507
2135  
2136 4502 return 0;
2137 }
2138  
2139 sub _parse_prec {
2140 70594 ▶ my ($self, $min_prec) = @_;
Subroutine _parse_prec: called CC=24 SCAR=31.8
2141  
2142 70594 my $t = $self->{tok};
2143 70594 my $left = $self->parse_prefix;
2144  
2145 70494 while (1) {
2146 81483 my $op_tok = $self->{tok};
2147 81483 my $op;
2148  
2149 81483 ▶ if ($op_tok->is_OP || $op_tok->is_KW) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op_tok->is_OP or $op_tok->is_KW) { } 80992 491 81483
Condition100%3/3
$op_tok->is_OP or $op_tok->is_KW
l!l&&r!l&&!r
745816411491
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 80992 $op = $op_tok->value;
2151 } else {
2152 491 last;
2153 }
2154  
2155 # stop at statement terminators / closers
2156 80992 ▶ 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 ":" 17352 17887 35239
Condition100%18/18
$op_tok->is_OP and $op eq ";" || $op eq ")" || $op eq "]" || $op eq "}" || $op eq "," || $op eq ":"
!ll&&!rl&&r
6411714503131
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq "," or $op eq ":"
l!l&&r!l&&!r
62077102811476
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq ","
l!l&&r!l&&!r
457531632412504
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}"
l!l&&r!l&&!r
4529346028828
$op eq ";" or $op eq ")" or $op eq "]"
l!l&&r!l&&!r
43617167629288
$op eq ";" or $op eq ")"
l!l&&r!l&&!r
208302278730964
MC/DC28%2/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 table37%3/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 11476 ▶ && @{ $self->{_pending_set_closers} || [] }
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_pending_set_closers"} or [] 11304 172 11476
2162 17887 ▶ && $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 17837 17887
Condition100%6/6
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];} and $op eq $self->{"_pending_set_closers"}[-1]
!ll&&!rl&&r
17834350
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];}
!ll&&!rl&&r
64111142353
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 17837 my $prec = $self->_prec($op);
2165 17837 ▶ last if $prec < $min_prec || $prec == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $prec < $min_prec or $prec == 0 6848 10989 17837
Condition100%3/3
$prec < $min_prec or $prec == 0
l!l&&r!l&&!r
2709413910989
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 10989 ▶ 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
5010984
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
5010984
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
5010984
$op eq "**" or $op eq "onlyif"
l!l&&r!l&&!r
5010984
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 10989 ▶ my $next_min = $right_assoc ? $prec : ($prec + 1);
Branch: 1 branch
BranchTrueFalseTotal
$right_assoc ? : 5 10984 10989
2173  
2174 10989 $self->{tok} = $self->{lexer}->next_token; # consume op
2175 10989 my $right;
2176 10989 ▶ 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 10957 10989
Condition83%5/6
$op eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
!ll&&!rl&&r
109401732
$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 10957 $right = $self->_parse_prec($next_min);
2187 }
2188  
2189 10989 $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 70494 return $left;
2196 }
2197  
2198 sub parse_prefix {
2199 72458 ▶ my ($self) = @_;
Subroutine parse_prefix: called CC=41 SCAR=37.2
Pod documented
2200  
2201 72458 my $t = $self->{tok};
2202  
2203 72458 ▶ 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 72452 72458
Condition100%6/6
$t->is_OP and $t->value eq "->" || $t->value eq "\x{2192}"
!ll&&!rl&&r
6893735183
$t->value eq "->" or $t->value eq "\x{2192}"
l!l&&r!l&&!r
333515
MC/DC66%2/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 table75%3/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 72452 ▶ 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 "\\") 27 72314 72341
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
68937348827
$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
111273377
$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
11103404
$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
72393404
$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
6393443
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}"
l!l&&r!l&&!r
6303452
$t->value eq "+" or $t->value eq "-" or $t->value eq "!"
l!l&&r!l&&!r
6123452
$t->value eq "+" or $t->value eq "-"
l!l&&r!l&&!r
1603454
MC/DC44%4/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 table50%5/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 72314 ▶ if ( $t->is_KW and $t->value eq 'not' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW and $t->value eq "not") 1002 71312 72314
Condition100%3/3
$t->is_KW and $t->value eq "not"
!ll&&!rl&&r
6723640761002
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 1002 $self->{tok} = $self->{lexer}->next_token;
2257 1002 my $expr = $self->parse_prefix;
2258  
2259 1000 return Zuzu::AST::Expr::Unary->new(file => $t->file, line => $t->line, op => 'not', expr => $expr);
2260 }
2261 71312 ▶ 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 71311 71312
Condition66%2/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
1071311
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 71311 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 23 71288 71311
2265 23 return $self->parse_try;
2266 }
2267 71288 ▶ if ( $t->is_KW('await') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("await")) 112 71176 71288
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 71176 ▶ if ( $t->is_KW('spawn') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("spawn")) 17 71159 71176
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 71159 ▶ if ( $t->is_KW('do') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("do")) 8 71151 71159
2290 8 $self->_eat( 'KW', 'do' );
2291  
2292 8 return $self->parse_block;
2293 }
2294 71151 ▶ if ( $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("async")) 7 71144 71151
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 71144 ▶ 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") 482 70430 70912
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
67236380999
$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
667473194
$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
2324353241
$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
144883676
$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
122223764
$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
58643786
$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
5083850
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor" or $t->value eq "ceil"
l!l&&r!l&&!r
4733858
$t->value eq "abs" or $t->value eq "sqrt" or $t->value eq "floor"
l!l&&r!l&&!r
14333861
$t->value eq "abs" or $t->value eq "sqrt"
l!l&&r!l&&!r
1133894
MC/DC27%3/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 table33%4/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 70430 ▶ 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 70419 70430
Condition66%4/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
6705333770
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
1103366
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 70419 my $prim = $self->parse_primary;
2344  
2345 70328 return $self->parse_postfix($prim);
2346 }
2347  
2348 sub parse_primary {
2349 71215 ▶ my ($self) = @_;
Subroutine parse_primary: called CC=74 SCAR=46.2
Pod documented
2350  
2351 71215 my $t = $self->{tok};
2352  
2353 71215 ▶ if ($t->is_NUMBER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NUMBER) 6430 64785 71215
2354 6430 $self->{tok} = $self->{lexer}->next_token;
2355 6430 my $v = $t->value;
2356 6430 ▶ $v = ($v =~ /\./) ? 0.0 + $v : 0 + $v;
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /\./ ? : 72 6358 6430
2357  
2358 6430 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => $v);
2359 }
2360 64785 ▶ if ($t->is_STRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_STRING) 10798 53987 64785
2361 10798 $self->{tok} = $self->{lexer}->next_token;
2362  
2363 10798 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => $t->value);
2364 }
2365 53987 ▶ if ( $t->is_type('BINARY_STRING') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("BINARY_STRING")) 12 53975 53987
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 53975 ▶ if ( $t->is_type('TEMPLATE') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("TEMPLATE")) 374 53601 53975
2375 374 $self->{tok} = $self->{lexer}->next_token;
2376  
2377 374 return $self->_parse_template_expression($t);
2378 }
2379 53601 ▶ if ($t->is_REGEXP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_REGEXP) 324 53277 53601
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: 2 branches
BranchTrueFalseTotal
if (grep {ref $_ eq "HASH" and exists $_->{"expr"};} @{$parts;}) 0 324 324
ref $_ eq "HASH" and exists $_->{"expr"} 324 0 324
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 53277 ▶ if ($t->is_BOOL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_BOOL) 1963 51314 53277
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 51314 ▶ if ($t->is_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NULL) 1823 49491 51314
2416 1823 $self->{tok} = $self->{lexer}->next_token;
2417  
2418 1823 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => undef);
2419 }
2420 49491 ▶ if ($t->is_IDENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_IDENT) 42896 6595 49491
2421 42896 my $id = $self->_eat('IDENT');
2422 42896 my $name = $id->value;
2423 42896 my $info = $self->_lookup($name);
2424 my $is_named_arg_label
2425 = ( $self->{_invocation_arg_depth} // 0 )
2426 42896 ▶ and $self->{tok}->is_OP(':');
Branch: 1 branch
BranchTrueFalseTotal
my $is_named_arg_label = $self->{"_invocation_arg_depth"} // 0 and $self->{"tok"}->is_OP(":") 17133 25763 42896
Condition100%2/2
$self->{"_invocation_arg_depth"} // 0
l!l
413361560
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 42896 my $is_chain_placeholder = $name eq '^^';
2428 42896 ▶ 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 42860 42896
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
42860036
$info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
4267418636
$info or $is_chain_placeholder
l!l&&r!l&&!r
4263143222
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 42860 return Zuzu::AST::Expr::Var->new(file => $id->file, line => $id->line, name => $name);
2433 }
2434 6595 ▶ if ($t->is_KW('self')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("self")) 1920 4675 6595
2435 1920 my $id = $self->_eat('KW', 'self');
2436 1920 my $name = $id->value;
2437 1920 my $info = $self->_lookup($name);
2438 1920 ▶ $self->_err("Use of undeclared identifier '$name' (compile-time)", $id) if !$info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 1920 1920
2439  
2440 1920 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 "(") 1195 3443 4638
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
126821751195
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 1195 $self->_eat('OP', '(');
2452 1195 my $e = $self->parse_expression;
2453 1195 $self->_eat('OP', ')');
2454  
2455 1184 return $e;
2456 }
2457 3443 ▶ if ( $t->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("...")) 3 3440 3443
2458 3 $self->_err("Spread argument '...' is only valid in call argument lists", $t);
2459 }
2460 3440 ▶ if ( $t->is_OP('โŒŠ') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("\x{230a}")) 3 3437 3440
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 3437 ▶ if ( $t->is_OP('โŒˆ') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("\x{2308}")) 3 3434 3437
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 3434 ▶ if ($t->is_OP && $t->value eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "[") 1192 2242 3434
Condition100%3/3
$t->is_OP and $t->value eq "["
!ll&&!rl&&r
12689741192
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 2242 ▶ if ($t->is_OP('<<') or $t->is_OP('ยซ')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("<<") or $t->is_OP("\x{ab}")) 55 2187 2242
Condition100%3/3
$t->is_OP("<<") or $t->is_OP("\x{ab}")
l!l&&r!l&&!r
5412187
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 2187 ▶ if ($t->is_OP('<<<')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("<<<")) 43 2144 2187
2493  
2494 43 return $self->parse_bag_literal;
2495 }
2496 2144 ▶ if ($t->is_EMPTY_SET) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_EMPTY_SET) 3 2141 2144
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 2141 ▶ if ($t->is_OP && $t->value eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "{") 825 1316 2141
Condition100%3/3
$t->is_OP and $t->value eq "{"
!ll&&!rl&&r
126551825
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 1316 ▶ if ( $t->is_OP('{{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("{{")) 40 1276 1316
2510  
2511 40 return $self->parse_pairlist_literal;
2512 }
2513 1276 ▶ if ($t->is_KW('new')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("new")) 783 493 1276
2514 783 my $kw = $self->_eat('KW', 'new');
2515 783 my $class_expr = $self->parse_primary;
2516 774 while (1) {
2517 774 ▶ if ( $self->{tok}->is_OP('.') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP(".")) 0 774 774
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 774 ▶ if ( $self->{tok}->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("{")) 0 774 774
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 774 last;
2537 }
2538 774 my @traits;
2539 774 ▶ 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 771 774
Condition66%2/3
$self->{"tok"}->is_KW("with") or $self->{"tok"}->is_KW("but")
l!l&&r!l&&!r
30771
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 774 $self->_eat('OP', '(');
2547 773 my @args = $self->_parse_invocation_args;
2548 773 $self->_eat('OP', ')');
2549  
2550 773 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 sub _parse_template_expression {
2709 374 ▶ my ( $self, $tok ) = @_;
Subroutine _parse_template_expression: called CC=10 SCAR=24.7
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 sub _split_template_parts {
2752 0 ▶ my ( $self, $src, $tok ) = @_;
Subroutine _split_template_parts: not called CC=18 SCAR=58.3
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 sub _parse_embedded_expression {
2818 477 ▶ my ( $self, $src, $tok ) = @_;
Subroutine _parse_embedded_expression: called CC=2 SCAR=7.0
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 sub parse_postfix {
2836 70335 ▶ my ($self, $expr) = @_;
Subroutine parse_postfix: called CC=20 SCAR=30.0
Pod documented
2837  
2838 70335 while (1) {
2839 89504 my $t = $self->{tok};
2840  
2841 # function call
2842 89504 ▶ if ($t->is_OP && $t->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "(") 6604 82900 89504
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
5418774826604
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 6604 my $lp = $self->_eat('OP', '(');
2844 6604 my @args = $self->_parse_invocation_args;
2845 6602 $self->_eat('OP', ')');
2846 6602 $expr = Zuzu::AST::Expr::Call->new(file => $lp->file, line => $lp->line, callee => $expr, args => \@args);
2847 6602 next;
2848 }
2849  
2850 # member call: obj.method(...) or obj.method (no-arg call handled at runtime by allowing method without ())
2851 82900 ▶ if ($t->is_OP && $t->value eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq ".") 8304 74596 82900
Condition100%3/3
$t->is_OP and $t->value eq "."
!ll&&!rl&&r
5418691788304
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 8304 my $dot = $self->_eat('OP', '.');
2853 8304 ▶ if ( $self->_maybe('OP', '(') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "(")) 11 8293 8304
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 8293 my $method = $self->_eat_member_name;
2869 8293 my @args;
2870 8293 ▶ if ($self->{tok}->is_OP && $self->{tok}->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "(") 7833 460 8293
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "("
!ll&&!rl&&r
254357833
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 7833 $self->_eat('OP', '(');
2872 7833 @args = $self->_parse_invocation_args;
2873 7832 $self->_eat('OP', ')');
2874 }
2875 8292 $expr = Zuzu::AST::Expr::MemberCall->new(
2876 file => $dot->file, line => $dot->line,
2877 object => $expr, method => $method, args => \@args
2878 );
2879 8292 next;
2880 }
2881  
2882 # index: a[expr]
2883 74596 ▶ if ($t->is_OP && $t->value eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "[") 1130 73466 74596
Condition100%3/3
$t->is_OP and $t->value eq "["
!ll&&!rl&&r
5418680481130
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 73466 ▶ 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 "--") 681 72785 73466
Condition100%6/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
54186800642
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
6394267367
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
2915 681 my $op = $self->_eat('OP');
2916 681 $self->_assert_mutable_target($expr, $op);
2917 680 $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 680 next;
2925 }
2926  
2927 # dict access: d{expr} or d{ident}
2928 72785 ▶ if ($t->is_OP && $t->value eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "{") 2454 70331 72785
Condition100%3/3
$t->is_OP and $t->value eq "{"
!ll&&!rl&&r
5418649132454
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 2454 my $lb = $self->_eat('OP', '{');
2930 2454 my $key = $self->_parse_dict_key_expr;
2931 2454 $self->_eat('OP', '}');
2932 2454 $expr = Zuzu::AST::Expr::DictGet->new(file => $lb->file, line => $lb->line, dict => $expr, key => $key);
2933 2454 next;
2934 }
2935  
2936 70331 last;
2937 }
2938  
2939 70331 return $expr;
2940 }
2941  
2942 sub _parse_invocation_args {
2943 15221 ▶ my ( $self ) = @_;
Subroutine _parse_invocation_args: called CC=15 SCAR=27.8
2944  
2945 15221 my @args;
2946 15221 $self->{_invocation_arg_depth}++;
2947 15221 ▶ while ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 23284 15218 38502
2948 # ignore superfluous commas between arguments
2949 23284 ▶ if ( $self->_maybe('OP', ',') ) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 23284 23284
2950  
2951 23284 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 20 23264 23284
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 23264 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")) 1975 21289 23264
Condition100%6/6
$self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")
!ll&&!rl&&r
6734145551975
$self->{"tok"}->is_IDENT or $self->{"tok"}->is_KW
l!l&&r!l&&!r
157657656734
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 1975 my $name_tok = $self->{tok};
2974 1975 $self->{tok} = $self->{lexer}->next_token;
2975 1975 $self->_eat('OP', ':');
2976 1975 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 1 1974 1975
2977 1 $self->_err("Spread arguments cannot be named", $self->{tok});
2978 }
2979 1974 my $value_expr = $self->parse_expression;
2980 1974 push @args, [ $name_tok->value, $value_expr ];
2981 1974 $self->_maybe('OP', ',');
2982 1974 next;
2983 }
2984  
2985 21289 my $expr = $self->parse_expression;
2986 21288 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':')) { } 6 21282 21288
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 21282 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 1 21281 21282
3000 1 $self->_err("Range syntax '...' is only valid in collection literals", $self->{tok});
3001 }
3002 21281 push @args, [ undef, $expr ];
3003 }
3004 21287 $self->_maybe('OP', ',');
3005 }
3006 15218 $self->{_invocation_arg_depth}--;
3007  
3008 15218 return @args;
3009 }
3010  
3011 sub _assert_mutable_target {
3012 2930 ▶ my ( $self, $expr, $tok ) = @_;
Subroutine _assert_mutable_target: called CC=6 SCAR=18.2
3013  
3014 2930 ▶ 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") 237 2693 2930
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
02372693
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 2693 my $info = $self->_lookup($expr->name);
3017 2693 ▶ return if ! $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 2693 2693
3018 2693 ▶ return if ! exists $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $info->{"mutable"} 0 2693 2693
3019 2693 ▶ return if $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"mutable"} 2686 7 2693
3020  
3021 7 $self->_err("Cannot assign to const '".$expr->name."' (compile-time)", $tok);
3022 }
3023  
3024 sub _assert_reference_target {
3025 27 ▶ my ( $self, $expr, $tok ) = @_;
Subroutine _assert_reference_target: called CC=11 SCAR=28.2
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 sub _parse_dict_key_expr {
3050 4759 ▶ my ( $self ) = @_;
Subroutine _parse_dict_key_expr: called CC=3 SCAR=11.0
3051  
3052 4759 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 4479 280 4759
3053 4479 my $id = $self->_eat('IDENT');
3054  
3055 4479 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 sub parse_array_literal {
3075 1192 ▶ my ($self) = @_;
Subroutine parse_array_literal: called CC=5 SCAR=16.1
Pod documented
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 1687 ▶ 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 sub parse_dict_literal {
3103 825 ▶ my ($self) = @_;
Subroutine parse_dict_literal: called CC=4 SCAR=13.9
Pod documented
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 "}") 2238 820 3058
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "}"
!ll&&!rl&&r
22371820
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 2238 ▶ if ($self->_maybe('OP', ',')) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 2238 2238
3109 2238 my $key;
3110 2238 $key = $self->_parse_dict_key_expr;
3111 2236 $self->_eat('OP', ':');
3112 2235 my $val = $self->parse_expression;
3113 2233 push @pairs, [ $key, $val ];
3114 2233 $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 sub parse_pairlist_literal {
3122 40 ▶ my ( $self ) = @_;
Subroutine parse_pairlist_literal: called CC=3 SCAR=11.0
Pod undocumented
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 sub parse_set_literal {
3146 55 ▶ my ( $self ) = @_;
Subroutine parse_set_literal: called CC=6 SCAR=17.9
Pod documented
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 sub parse_bag_literal {
3183 43 ▶ my ( $self ) = @_;
Subroutine parse_bag_literal: called CC=4 SCAR=13.9
Pod documented
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 sub new {
3373 55 ▶ my ( $class, $parser ) = @_;
Subroutine new: called CC=1 SCAR=0.0
3374 55 return bless { parser => $parser }, $class;
3375 }
3376 sub DESTROY {
3377 55 ▶ my ( $self ) = @_;
Subroutine DESTROY: called CC=2 SCAR=7.1
3378 55 ▶ pop @{ $self->{parser}{_pending_set_closers} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$self->{"parser"}{"_pending_set_closers"} or [] 0 55 55
3379 }
3380 }
3381  
3382 78 1;
« blib/lib/Zuzu/Module/DNS.pm ↑ Summary blib/lib/Zuzu/Lexer.pm »