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.007001';
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 202978 ▶ my ($self, $type, $value) = @_;
Subroutine _eat: called CC=5 SCAR=16.1
134  
135 202978 my $t = $self->{tok};
136 202978 ▶ $self->_err("Expected $type", $t) if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 41 202937 202978
137 202937 ▶ $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 202925 202937
Condition80%4/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
8373311919212
$t->value // ""
l!l
1192040
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 202925 $self->{tok} = $self->{lexer}->next_token;
139  
140 202924 return $t;
141 }
142  
143 sub _maybe {
144 926412 ▶ my ($self, $type, $value) = @_;
Subroutine _maybe: called CC=5 SCAR=16.2
145  
146 926412 my $t = $self->{tok};
147  
148 926412 ▶ return 0 if $t->type ne $type;
Branch: 1 branch
BranchTrueFalseTotal
if $t->type ne $type 86659 839753 926412
149  
150 839753 ▶ return 0 if defined($value) && (($t->value // '') ne $value);
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and ($t->value // "") ne $value 791157 48596 839753
Condition60%3/5
defined $value and ($t->value // "") ne $value
!ll&&!rl&&r
048596791157
$t->value // ""
l!l
8397530
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 48596 $self->{tok} = $self->{lexer}->next_token;
152  
153 48594 return $t;
154 }
155  
156 sub _peek_token {
157 16551 ▶ my ($self) = @_;
Subroutine _peek_token: called CC=1 SCAR=0.0
158  
159 16551 my $lexer = $self->{lexer};
160 16551 my ( $pos, $line, $col, $last ) = (
161 $lexer->pos,
162 $lexer->line,
163 $lexer->col,
164 $lexer->last_token,
165 );
166 16551 my $tok = $lexer->next_token;
167 16551 $lexer->pos($pos);
168 16551 $lexer->line($line);
169 16551 $lexer->col($col);
170 16551 $lexer->last_token($last);
171  
172 16551 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 13512 ▶sub _push_scope { push @{$_[0]->{scopes}}, {} }
Subroutine _push_scope: called CC=1 SCAR=0.0
188  
189 13488 ▶sub _pop_scope { pop @{$_[0]->{scopes}} }
Subroutine _pop_scope: called CC=1 SCAR=0.0
190  
191 sub _parse_block_in_async_context {
192 3270 ▶ my ( $self, $is_async, $decls, $imports ) = @_;
Subroutine _parse_block_in_async_context: called CC=3 SCAR=11.0
193  
194 3270 ▶ if ( $is_async ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_async) 47 3223 3270
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 3223 local $self->{_async_context_depth} = 0;
201 3223 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 13321 ▶ my ($self, $name, $info, $tok, $opts) = @_;
Subroutine _declare: called CC=8 SCAR=21.6
224  
225 13321 ▶ $tok //= $self->{tok};
Condition33%1/3
$tok //= $self->{"tok"}
l!l&&r!l&&!r
1332100
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 13321 ▶ $opts //= {};
Condition100%2/2
$opts //= {}
l!l
102612295
MC/DC100%1/1
$opts //= {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
227 13321 ▶ $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 13321 13321
228 13321 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 1 13320 13321
229 13320 my $scope = $self->{scopes}[-1];
230 13320 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 2 13318 13320
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 13318 $scope->{$name} = $info;
237 }
238  
239 sub _declare_function_name {
240 1525 ▶ my ( $self, $name, $tok, $is_predeclared ) = @_;
Subroutine _declare_function_name: called CC=7 SCAR=20.5
241  
242 1525 ▶ $self->_err("Keyword '$name' cannot be used as an identifier", $tok) if Zuzu::Util::is_keyword($name);
Branch: 1 branch
BranchTrueFalseTotal
if Zuzu::Util::is_keyword($name) 0 1525 1525
243 1525 ▶ $self->_err("'^^' is reserved for the chain placeholder", $tok) if $name eq '^^';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "^^" 0 1525 1525
244 1525 my $scope = $self->{scopes}[-1];
245 1525 ▶ if ( exists $scope->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $scope->{$name}) 32 1493 1525
246 32 my $existing = $scope->{$name};
247 32 ▶ if ( $is_predeclared or $existing->{kind} ne 'func_predecl' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_predeclared or $existing->{"kind"} ne "func_predecl") 0 32 32
Condition33%1/3
$is_predeclared or $existing->{"kind"} ne "func_predecl"
l!l&&r!l&&!r
0032
MC/DC0%0/2
$is_predeclared or $existing->{"kind"} ne "func_predecl"
$is_predeclared $existing->{"kind"} ne "func_predecl"
Truth table33%1/3
A or B
A= $is_predeclaredB= $existing->{"kind"} ne "func_predecl"
ABresult
1X1
011
000
248 0 $self->_err("Redeclaration of '$name' in the same scope", $tok);
249 }
250 32 $scope->{$name} = { kind => 'func', mutable => 0 };
251 32 return;
252 }
253  
254 1493 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$is_predeclared ? : 32 1461 1493
255 kind => $is_predeclared ? 'func_predecl' : 'func',
256 mutable => 0,
257 };
258 }
259  
260 sub _lookup {
261 47809 ▶ my ($self, $name) = @_;
Subroutine _lookup: called CC=3 SCAR=11.0
262  
263 47809 ▶ for (my $i = $#{$self->{scopes}}; $i >= 0; $i--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= 0) 93562 279 93841
264  
265 93562 ▶ return $self->{scopes}[$i]{$name} if exists $self->{scopes}[$i]{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"scopes"}[$i]{$name} 47530 46032 93562
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) 4188 751 4939
279 4188 $self->_eat_optional_statement_separators;
280 4188 ▶ last if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 4186 4188
281 4186 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 26325 ▶ my ( $self ) = @_;
Subroutine _eat_optional_statement_separators: called CC=2 SCAR=6.9
290  
291 26325 ▶ while ( $self->_maybe( 'OP', ';' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 5 26325 26330
292 # Consume no-op statement separators.
293 }
294  
295 26325 return;
296 }
297  
298 sub parse_statement {
299 26323 ▶ my ($self) = @_;
Subroutine parse_statement: called CC=27 SCAR=33.0
Pod documented
300  
301 26323 my $t = $self->{tok};
302  
303 26323 ▶ if ( $t->is_KW('let') or $t->is_KW('const') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("let") or $t->is_KW("const")) 5859 20464 26323
Condition100%3/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
548637320464
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 5859 return $self->parse_let;
306 }
307 20464 ▶ if ( $t->is_KW('function') or $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("function") or $t->is_KW("async")) 1541 18923 20464
Condition100%3/3
$t->is_KW("function") or $t->is_KW("async")
l!l&&r!l&&!r
14984318923
MC/DC100%2/2
$t->is_KW("function") or $t->is_KW("async")
$t->is_KW("function") $t->is_KW("async")
Truth table100%3/3
A or B
A= $t->is_KW("function")B= $t->is_KW("async")
ABresult
1X1
011
000
308  
309 1541 return $self->parse_function_def;
310 }
311 18923 ▶ if ( $t->is_KW('class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("class")) 307 18616 18923
312  
313 307 return $self->parse_class_def;
314 }
315 18616 ▶ if ( $t->is_KW('trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("trait")) 14 18602 18616
316  
317 14 return $self->parse_trait_def;
318 }
319 18602 ▶ if ( $t->is_KW('if') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("if")) 3528 15074 18602
320  
321 3528 return $self->parse_if;
322 }
323 15074 ▶ if ( $t->is_KW('while') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("while")) 498 14576 15074
324  
325 498 return $self->parse_while;
326 }
327 14576 ▶ if ( $t->is_KW('for') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("for")) 748 13828 14576
328  
329 748 return $self->parse_for;
330 }
331 13828 ▶ if ( $t->is_KW('switch') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("switch")) 31 13797 13828
332  
333 31 return $self->parse_switch;
334 }
335 13797 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 130 13667 13797
336  
337 130 return $self->parse_try;
338 }
339 13667 ▶ if ( $t->is_KW('return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("return")) 5298 8369 13667
340  
341 5298 return $self->parse_return;
342 }
343 8369 ▶ 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 8190 8204
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
167128190
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn") or $t->is_KW("debug")
l!l&&r!l&&!r
16528202
$t->is_KW("say") or $t->is_KW("print") or $t->is_KW("warn")
l!l&&r!l&&!r
15968204
$t->is_KW("say") or $t->is_KW("print")
l!l&&r!l&&!r
351248210
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 8190 ▶ if ( $t->is_KW('throw') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("throw")) 34 8156 8190
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 8156 ▶ if ( $t->is_KW('die') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("die")) 817 7339 8156
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 7339 ▶ if ( $t->is_KW('next') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("next")) 277 7062 7339
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 7062 ▶ if ( $t->is_KW('continue') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("continue")) 20 7042 7062
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 7042 ▶ if ( $t->is_KW('last') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("last")) 85 6957 7042
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 6957 ▶ if ( $t->is_KW('from') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("from")) 711 6246 6957
393  
394 711 return $self->parse_import;
395 }
396 6246 ▶ if ( $t->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP("{")) 19 6227 6246
397  
398 19 return $self->parse_block;
399 }
400  
401 # assignment or expr stmt
402 6227 my $expr = $self->parse_expression;
403  
404 6161 ▶ 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")) 2218 3943 6161
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Stmt::Assign")
!ll&&!rl&&r
039432218
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 2218 return $self->_finish_with_postfix_condition($expr);
406 }
407  
408 3943 my $stmt = Zuzu::AST::Stmt::Expr->new(file => $t->file, line => $t->line, expr => $expr);
409  
410 3943 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 12861 ▶ my ($self, $stmt) = @_;
Subroutine _finish_with_postfix_condition: called CC=5 SCAR=16.1
468  
469 12861 my $has_postfix = 0;
470 12861 my $negate = 0;
471 12861 ▶ if ( $self->{tok}->is_KW('if') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tok'}->is_KW('if')) { } 1116 11745 12861
elsif ($self->{'tok'}->is_KW('unless')) { } 94 11651 11745
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 12861 ▶ if ( $has_postfix ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($has_postfix) { } 1210 11651 12861
elsif ($self->{'tok'}->is_KW('for')) { } 9 11642 11651
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 12861 $self->_eat_statement_separator;
510  
511 12855 return $stmt;
512 }
513  
514 sub _eat_statement_separator {
515 19390 ▶ my ($self) = @_;
Subroutine _eat_statement_separator: called CC=4 SCAR=13.9
516  
517 19390 ▶ return if $self->_maybe('OP', ';');
Branch: 1 branch
BranchTrueFalseTotal
if $self->_maybe("OP", ";") 19370 18 19388
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 5842 ▶ my ($self) = @_;
Subroutine parse_block: called CC=4 SCAR=13.9
Pod documented
526  
527 5842 my $lb = $self->_eat('OP', '{');
528 5842 $self->_push_scope;
529 5842 my @stmts;
530 5842 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 11040 5831 16871
531 11040 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 6 11034 11040
532 11034 $self->_eat_optional_statement_separators;
533 11034 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 11034 11034
534 11034 push @stmts, $self->parse_statement;
535 }
536 5831 $self->_eat('OP', '}');
537 5831 $self->_pop_scope;
538  
539 5831 return Zuzu::AST::Block->new(file => $lb->file, line => $lb->line, statements => \@stmts);
540 }
541  
542 sub _parse_let_decl {
543 5860 ▶ my ( $self, $expect_semicolon ) = @_;
Subroutine _parse_let_decl: called CC=11 SCAR=24.2
544  
545 5860 my $kw = $self->_eat('KW');
546 5860 ▶ my $is_const = ($kw->value eq 'const') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$kw->value eq 'const' ? : 373 5487 5860
547  
548 5860 ▶ if ( $self->{tok}->is_OP('{') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("{")) 22 5838 5860
549 22 return $self->_parse_let_unpack_decl( $kw, $is_const, $expect_semicolon );
550 }
551  
552 5838 my ( $declared_type, $name, $name_tok ) = $self->_parse_typed_identifier;
553 5823 my $is_weak_storage = $self->_parse_optional_weak_modifier('declaration');
554  
555 # Detect forbidden "let x = 1"
556 5823 ▶ if ($self->{tok}->is_OP && $self->{tok}->value eq '=') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP and $self->{"tok"}->value eq "=") 0 5823 5823
Condition33%1/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "="
!ll&&!rl&&r
058230
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 5823 my $init;
561 5823 ▶ if ($self->_maybe('OP', ':=')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':=')) { } 5771 52 5823
562 5771 $init = $self->parse_expression;
563 5751 ▶ $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
045747
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 5803 ▶ $self->_eat_statement_separator if $expect_semicolon;
Branch: 1 branch
BranchTrueFalseTotal
if $expect_semicolon 5802 1 5803
568  
569 5802 ▶ $self->_declare(
Branch: 2 branches
BranchTrueFalseTotal
$is_const ? : 371 5431 5802
$is_const ? : 371 5431 5802
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 5800 ▶ return Zuzu::AST::Stmt::Let->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_storage ? : 8 5792 5800
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 5859 ▶ my ($self) = @_;
Subroutine parse_let: called CC=1 SCAR=0.0
Pod documented
718  
719 5859 return $self->_parse_let_decl(1);
720 }
721  
722 sub parse_function_def {
723 1541 ▶ my ($self) = @_;
Subroutine parse_function_def: called CC=15 SCAR=28.2
Pod documented
724  
725 1541 my $async_tok;
726 1541 ▶ if ( $self->{tok}->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_KW("async")) 43 1498 1541
727 43 $async_tok = $self->_eat('KW', 'async');
728 }
729 1541 my $kw = $self->_eat('KW', 'function');
730 1541 my $name_tok = $self->_eat('IDENT');
731 1525 my $name = $name_tok->value;
732  
733 1525 ▶ if ( $self->_maybe('OP', ';') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ";")) 32 1493 1525
734 32 $self->_declare_function_name( $name, $name_tok, 1 );
735 32 ▶ return Zuzu::AST::Stmt::Function->new(
Branch: 1 branch
BranchTrueFalseTotal
$async_tok ? : 0 32 32
Condition33%2/6
$async_tok // $kw
l!l&&r!l&&!r
0320
$async_tok // $kw
l!l&&r!l&&!r
0320
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
Truth table33%1/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
736 file => ( $async_tok // $kw )->file,
737 line => ( $async_tok // $kw )->line,
738 name => $name,
739 params => [],
740 is_async => $async_tok ? 1 : 0,
741 is_predeclared => 1,
742 );
743 }
744  
745 1493 $self->_declare_function_name( $name, $name_tok, 0 );
746  
747 1493 my ( $params, $vararg, $param_types, $vararg_type, $param_optional, $param_defaults, $named_vararg, $named_vararg_type ) = $self->_parse_param_list;
748 1492 my $return_type = $self->_parse_optional_return_type;
749  
750 my @arg_decls = map {
751 {
752 name => $_,
753 mutable => 0,
754 2264 ▶ declared_type => $param_types->{$_} // 'Any',
Condition50%1/2
$param_types->{$_} // "Any"
l!l
22640
MC/DC0%0/1
$param_types->{$_} // "Any"
$param_types->{$_}
Truth table50%1/2
A
A= $param_types->{$_}
Aresult
11
00
755 }
756 1492 ▶ } @{ $params // [] };
Condition50%1/2
$params // []
l!l
14920
MC/DC0%0/1
$params // []
$params
Truth table50%1/2
A
A= $params
Aresult
11
00
757 1492 ▶ if ( defined $vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $vararg) 28 1464 1492
758 28 ▶ push @arg_decls, {
Condition50%1/2
$vararg_type // "Any"
l!l
280
MC/DC0%0/1
$vararg_type // "Any"
$vararg_type
Truth table50%1/2
A
A= $vararg_type
Aresult
11
00
759 name => $vararg,
760 mutable => 0,
761 declared_type => $vararg_type // 'Any',
762 };
763 }
764 1492 ▶ if ( defined $named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $named_vararg) 64 1428 1492
765 64 ▶ push @arg_decls, {
Condition50%1/2
$named_vararg_type // "PairList"
l!l
640
MC/DC0%0/1
$named_vararg_type // "PairList"
$named_vararg_type
Truth table50%1/2
A
A= $named_vararg_type
Aresult
11
00
766 name => $named_vararg,
767 mutable => 0,
768 declared_type => $named_vararg_type // 'PairList',
769 };
770 }
771 1492 ▶ my $is_async = $async_tok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$async_tok ? : 43 1449 1492
772 1492 my $body = $self->_parse_block_in_async_context(
773 $is_async,
774 \@arg_decls,
775 [],
776 );
777  
778 1485 ▶ return Zuzu::AST::Stmt::Function->new(
Condition66%4/6
$async_tok // $kw
l!l&&r!l&&!r
4214430
$async_tok // $kw
l!l&&r!l&&!r
4214430
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
MC/DC0%0/2
$async_tok // $kw
$async_tok $kw
Truth table66%2/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $async_tokB= $kw
ABresult
1X1
011
000
779 file => ( $async_tok // $kw )->file,
780 line => ( $async_tok // $kw )->line,
781 name => $name,
782 params => $params,
783 vararg => $vararg,
784 body => $body,
785 param_types => $param_types,
786 vararg_type => $vararg_type,
787 named_vararg => $named_vararg,
788 named_vararg_type => $named_vararg_type,
789 param_optional => $param_optional,
790 param_defaults => $param_defaults,
791 return_type => $return_type,
792 is_async => $is_async,
793 );
794 }
795  
796 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 14674 ▶ my ( $self, $context ) = @_;
Subroutine _parse_optional_weak_modifier: called CC=6 SCAR=21.8
927  
928 14674 ▶ return 0 if not $self->{tok}->is_KW('but');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"tok"}->is_KW("but") 14616 58 14674
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 3270 ▶ my ( $self ) = @_;
Subroutine _parse_optional_return_type: called CC=3 SCAR=11.0
1299  
1300 3270 ▶ return 'Any' if ! $self->_maybe('OP', '->') and ! $self->_maybe('OP', 'โ†’');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}") 3251 19 3270
Condition100%3/3
$self->_maybe("OP", "->") or $self->_maybe("OP", "\x{2192}")
l!l&&r!l&&!r
1093251
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 3315 ▶ my ($self) = @_;
Subroutine _parse_param_list: called CC=18 SCAR=29.0
1308  
1309 3315 $self->_eat('OP', '(');
1310 3315 my @params;
1311 my $vararg;
1312 3315 my $named_vararg;
1313 3315 my %param_types;
1314 3315 my %param_optional;
1315 3315 my %param_defaults;
1316 3315 my $vararg_type = 'Any';
1317 3315 my $named_vararg_type = 'PairList';
1318 3315 my $seen_optional = 0;
1319 3315 $self->_push_scope;
1320 3315 ▶ if ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 2459 856 3315
1321 2459 while (1) {
1322 4990 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 130 4860 4990
1323 130 $self->_eat('OP', '...');
1324 130 while (1) {
1325 177 my ( $collector_type, $collector_name ) = $self->_parse_param_name;
1326 177 ▶ if ( $collector_type eq 'PairList' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($collector_type eq 'PairList') { } 115 62 177
1327 $self->_err("Only one PairList collector can follow '...'", $self->{tok})
1328 115 ▶ if defined $named_vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $named_vararg 0 115 115
1329 115 $named_vararg = $collector_name;
1330 115 $named_vararg_type = $collector_type;
1331 }
1332 else {
1333 $self->_err("Only one positional collector can follow '...'", $self->{tok})
1334 62 ▶ if defined $vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $vararg 0 62 62
1335 62 $vararg = $collector_name;
1336 62 ▶ $vararg_type = $collector_type eq 'Any' ? 'Array' : $collector_type;
Branch: 1 branch
BranchTrueFalseTotal
$collector_type eq 'Any' ? : 13 49 62
1337 }
1338 177 ▶ my $declared = $collector_type eq 'Any'
Branch: 2 branches
BranchTrueFalseTotal
$collector_type eq 'Any' ? : 13 164 177
$named_vararg eq $collector_name ? : 0 0 0
Condition33%1/3
defined $named_vararg and $named_vararg eq $collector_name ? "PairList" : "Array"
!ll&&!rl&&r
1300
MC/DC0%0/2
defined $named_vararg and $named_vararg eq $collector_name ? "PairList" : "Array"
defined $named_vararg $named_vararg eq $collector_name ? "PairList" : "Array"
Truth table33%1/3
A and B
A= defined $named_varargB= $named_vararg eq $collector_name ? "PairList" : "Array"
ABresult
0X0
100
111
1339 ? ( defined $named_vararg and $named_vararg eq $collector_name ? 'PairList' : 'Array' )
1340 : $collector_type;
1341 $self->_declare(
1342 $collector_name,
1343 {
1344 kind => 'local',
1345 mutable => 0,
1346 declared_type => $declared,
1347 },
1348 $self->{tok},
1349 177 );
1350 177 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 130 47 177
1351 47 $self->_eat('OP', ',');
1352 }
1353 130 last;
1354 }
1355  
1356 4860 my ( $type_name, $param_name ) = $self->_parse_param_name;
1357 4857 push @params, $param_name;
1358 4857 $param_types{$param_name} = $type_name;
1359 $self->_declare(
1360 $param_name,
1361 {
1362 kind => 'local',
1363 mutable => 0,
1364 declared_type => $type_name,
1365 },
1366 $self->{tok},
1367 4857 );
1368 4857 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_maybe('OP', '?')) { } 214 4643 4857
elsif ($self->_maybe('OP', ':=')) { } 174 4469 4643
elsif ($seen_optional) { } 1 4468 4469
1369 $self->_err("Optional parameter '$param_name' cannot also define a default value", $self->{tok})
1370 214 ▶ if $self->{tok}->is_OP(':=');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(":=") 0 214 214
1371 214 $param_optional{$param_name} = 1;
1372 214 $seen_optional = 1;
1373 }
1374 elsif ( $self->_maybe('OP', ':=') ) {
1375 174 $param_defaults{$param_name} = $self->parse_expression;
1376 174 $seen_optional = 1;
1377 }
1378 elsif ( $seen_optional ) {
1379 1 $self->_err("Required parameter '$param_name' cannot follow optional/default parameters", $self->{tok});
1380 }
1381  
1382 4856 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 2296 2560 4856
1383 2560 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 7 2553 2560
1384 7 next;
1385 }
1386 2553 $self->_eat('OP', ',');
1387 2553 ▶ last if $self->{tok}->is_OP(')');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP(")") 29 2524 2553
1388 }
1389 }
1390 3311 $self->_eat('OP', ')');
1391 3311 $self->_pop_scope;
1392  
1393 3311 return ( \@params, $vararg, \%param_types, $vararg_type, \%param_optional, \%param_defaults, $named_vararg, $named_vararg_type );
1394 }
1395  
1396 sub _parse_param_name {
1397 5187 ▶ my ( $self ) = @_;
Subroutine _parse_param_name: called CC=2 SCAR=6.9
1398  
1399 5187 my $first = $self->_eat('IDENT');
1400  
1401 5184 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 1563 3621 5184
1402 1563 my $name_tok = $self->_eat('IDENT');
1403 1563 return ( $first->value, $name_tok->value );
1404 }
1405  
1406 3621 return ( 'Any', $first->value );
1407 }
1408  
1409 sub _parse_typed_identifier {
1410 6317 ▶ my ( $self ) = @_;
Subroutine _parse_typed_identifier: called CC=2 SCAR=6.9
1411  
1412 6317 my $first = $self->_eat('IDENT');
1413 6302 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 207 6095 6302
1414 207 my $name_tok = $self->_eat('IDENT');
1415 207 return ( $first->value, $name_tok->value, $name_tok );
1416 }
1417  
1418 6095 return ( 'Any', $first->value, $first );
1419 }
1420  
1421 sub _parse_block_with_decls {
1422 3270 ▶ my ( $self, $decls, $extras ) = @_;
Subroutine _parse_block_with_decls: called CC=15 SCAR=27.7
1423  
1424 3270 my $lb = $self->_eat('OP', '{');
1425 3270 $self->_push_scope;
1426 3270 ▶ for my $n ( @{ $decls // [] }, @{ $extras // [] } ) {
Condition50%2/4
$decls // []
l!l
32700
$extras // []
l!l
32700
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 15610 ▶ next if ! defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 0 15610 15610
1428 15610 my ( $name, $mutable, $declared_type );
1429 15610 ▶ if ( ref($n) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $n eq 'HASH') { } 12596 3014 15610
1430 12596 $name = $n->{name};
1431 12596 ▶ $mutable = defined $n->{mutable} ? $n->{mutable} : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $n->{'mutable'} ? : 12596 0 12596
1432 12596 ▶ $declared_type = $n->{declared_type} // 'Any';
Condition50%1/2
$n->{"declared_type"} // "Any"
l!l
125960
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 15610 ▶ next if ! defined $name || $name eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $name or $name eq "" 0 15610 15610
Condition33%1/3
not defined $name or $name eq ""
l!l&&r!l&&!r
0015610
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 15610 my $scope = $self->{scopes}[-1];
1441 15610 ▶ next if exists $scope->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $scope->{$name} 2 15608 15610
1442 15608 ▶ $scope->{$name} = {
Branch: 1 branch
BranchTrueFalseTotal
$mutable ? : 10643 4965 15608
1443 kind => 'local',
1444 mutable => $mutable ? 1 : 0,
1445 declared_type => $declared_type,
1446 };
1447 }
1448 3270 my @stmts;
1449 3270 ▶ while ( ! $self->{tok}->is_OP('}') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP("}")) 10811 3263 14074
1450 10811 ▶ $self->_err("Unterminated block", $self->{tok}) if $self->{tok}->is_EOF;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_EOF 2 10809 10811
1451 10809 $self->_eat_optional_statement_separators;
1452 10809 ▶ last if $self->{tok}->is_OP('}');
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tok"}->is_OP("}") 0 10809 10809
1453 10809 push @stmts, $self->parse_statement;
1454 }
1455 3263 $self->_eat('OP', '}');
1456 3262 $self->_pop_scope;
1457  
1458 3262 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 498 ▶ my ($self) = @_;
Subroutine parse_while: called CC=1 SCAR=0.0
Pod documented
1487  
1488 498 my $kw = $self->_eat('KW', 'while');
1489 498 $self->_eat('OP', '(');
1490 498 my $cond = $self->parse_expression;
1491 497 $self->_eat('OP', ')');
1492 497 my $body = $self->parse_block;
1493  
1494 497 return Zuzu::AST::Stmt::While->new(file => $kw->file, line => $kw->line, cond => $cond, body => $body);
1495 }
1496  
1497 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 5298 ▶ my ($self) = @_;
Subroutine parse_return: called CC=6 SCAR=18.1
Pod documented
1805  
1806 5298 my $kw = $self->_eat('KW', 'return');
1807 5298 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 5298 ▶ 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") 5186 112 5298
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
11205186
$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
11205186
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}") or $self->{"tok"}->is_EOF
l!l&&r!l&&!r
11205186
$self->{"tok"}->is_OP(";") or $self->{"tok"}->is_OP("}")
l!l&&r!l&&!r
11115186
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 5298 my $stmt = Zuzu::AST::Stmt::Return->new(file => $kw->file, line => $kw->line, expr => $expr);
1816  
1817 5298 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 59631 ▶ my ($self) = @_;
Subroutine parse_expression: called CC=23 SCAR=31.4
Pod documented
1920  
1921 59631 my $cond = $self->parse_chain_expression;
1922  
1923 59531 ▶ 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
22261457291
$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
179343357305
$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
1789457738
$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
1788157742
$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
1783557743
$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
1782157748
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=") or $self->_maybe("OP", "*=")
l!l&&r!l&&!r
1777557749
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=") or $self->_maybe("OP", "-=")
l!l&&r!l&&!r
1771657754
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=") or $self->_maybe("OP", "+=")
l!l&&r!l&&!r
160516657760
$self->_maybe("OP", ":=") or $self->_maybe("OP", "~=")
l!l&&r!l&&!r
1597857926
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 59531 ▶ if ( $assign_op ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op) 2240 57291 59531
1935 2240 $self->_assert_mutable_target( $cond, $assign_op );
1936 2235 ▶ if ( $assign_op->value eq '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assign_op->value eq "~=") 8 2227 2235
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 2227 my $rhs = $self->parse_expression;
1955 2227 my $is_weak_write = $self->_parse_optional_weak_modifier('assignment');
1956 2227 ▶ if ( $is_weak_write and $assign_op->value ne ':=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_weak_write and $assign_op->value ne ":=") 3 2224 2227
Condition100%3/3
$is_weak_write and $assign_op->value ne ":="
!ll&&!rl&&r
2205193
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 2224 ▶ 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 2223 2224
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
221941
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary") and defined $cond->op
!ll&&!rl&&r
221905
$is_weak_write and builtin::blessed($cond) and $cond->isa("Zuzu::AST::Expr::Binary")
!ll&&!rl&&r
2205145
$is_weak_write and builtin::blessed($cond)
!ll&&!rl&&r
2205019
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 2223 ▶ return Zuzu::AST::Stmt::Assign->new(
Branch: 1 branch
BranchTrueFalseTotal
$is_weak_write ? : 18 2205 2223
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 57291 return $cond;
1980 }
1981  
1982 sub parse_ternary_expression {
1983 59661 ▶ my ($self) = @_;
Subroutine parse_ternary_expression: called CC=3 SCAR=11.0
Pod undocumented
1984  
1985 59661 my $cond = $self->_parse_prec(0);
1986  
1987 59561 ▶ if ( $self->_maybe('OP', '?') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?")) 576 58985 59561
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 58985 ▶ if ( $self->_maybe('OP', '?:') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", "?:")) 23 58962 58985
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 58962 return $cond;
2014 }
2015  
2016 sub _chain_direction {
2017 57896 ▶ my ( $self, $op ) = @_;
Subroutine _chain_direction: called CC=5 SCAR=16.1
2018  
2019 57896 ▶ return 'right' if $op eq 'โ–ท' or $op eq '|>';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25b7}" or $op eq "|>" 27 57869 57896
Condition100%3/3
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
19857869
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 57869 ▶ return 'left' if $op eq 'โ—' or $op eq '<|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25c1}" or $op eq "<|" 3 57866 57869
Condition66%2/3
$op eq "\x{25c1}" or $op eq "<|"
l!l&&r!l&&!r
0357866
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 57866 return undef;
2023 }
2024  
2025 sub parse_chain_expression {
2026 59631 ▶ my ($self) = @_;
Subroutine parse_chain_expression: called CC=11 SCAR=24.1
Pod undocumented
2027  
2028 59631 my $left = $self->parse_ternary_expression;
2029 59533 my $op_tok = $self->{tok};
2030 59533 ▶ return $left if !$op_tok->is_OP;
Branch: 1 branch
BranchTrueFalseTotal
unless $op_tok->is_OP 1668 57865 59533
2031  
2032 57865 my $direction = $self->_chain_direction( $op_tok->value );
2033 57865 ▶ return $left if !$direction;
Branch: 1 branch
BranchTrueFalseTotal
unless $direction 57850 15 57865
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 17841 ▶ my ($self, $op) = @_;
Subroutine _prec: called CC=104 SCAR=49.7
2099  
2100 17841 ▶ 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 16749 16766
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
1092016749
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?"
l!l&&r!l&&!r
10751716749
$op eq "or" or $op eq "\x{22c1}"
l!l&&r!l&&!r
1075016766
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 16749 ▶ 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 16749 16749
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
0016749
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
0016749
$op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
0016749
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 16749 ▶ 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 16739 16739
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
10016739
$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
10016739
$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
10016739
$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
10016739
$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
10016739
$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
10016739
$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
10016739
$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
10016739
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?"
l!l&&r!l&&!r
10016739
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?"
l!l&&r!l&&!r
10016739
$op eq "xor" or $op eq "\x{22bb}"
l!l&&r!l&&!r
8216739
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 16739 ▶ 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 14692 14692
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
2047014692
$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
2047014692
$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
2047014692
$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
2047014692
$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
2047014692
$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
2047014692
$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
2047014692
$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
2046114692
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?"
l!l&&r!l&&!r
2046014693
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?"
l!l&&r!l&&!r
2046014693
$op eq "and" or $op eq "\x{22c0}"
l!l&&r!l&&!r
2046014693
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 14692 ▶ return 5 if $op eq 'default';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "default" 18 14674 14692
2113  
2114 14674 ▶ 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 12345 12889
Condition100%9/9
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
l!l&&r!l&&!r
185247712345
$op eq "==" or $op eq "\x{2261}" or $op eq "!="
l!l&&r!l&&!r
17856712822
$op eq "==" or $op eq "\x{2261}"
l!l&&r!l&&!r
309147612889
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 12345 ▶ 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 8194 8194
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
415108194
$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
415108194
$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
415108194
$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
4130218194
$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
4114168215
$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
4087278231
$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
37952928258
$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
3746498550
$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
374248599
$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
27579858603
$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
275709588
$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
275529588
$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
275509590
$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
275329590
$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
275309592
$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
275039592
$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
274469595
$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
273689601
$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
26291079609
$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
262909716
$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
262909716
$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
262909716
$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
262909716
$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
262909716
$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
262909716
$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
262819716
$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
2591379717
$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
258749754
$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
258169758
$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
257839764
$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
257539767
$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
24391369770
$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
18156249906
$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
1815010530
$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
1814110530
$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
18021210531
$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
1797510543
$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
154725010548
$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
1545210798
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">" or $op eq "<="
l!l&&r!l&&!r
14757010800
$op eq "=" or $op eq "\x{2260}" or $op eq "<" or $op eq ">"
l!l&&r!l&&!r
109338210870
$op eq "=" or $op eq "\x{2260}" or $op eq "<"
l!l&&r!l&&!r
36073311252
$op eq "=" or $op eq "\x{2260}"
l!l&&r!l&&!r
357311985
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 8194 ▶ return 7 if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 8 8186 8194
2119  
2120 8186 ▶ return 8 if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 6 8180 8186
2121  
2122 8180 ▶ return 9 if $op eq '&';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "&" 21 8159 8180
2123  
2124 8159 ▶ 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 8157 8158
Condition77%7/9
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
l!l&&r!l&&!r
118157
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>"
l!l&&r!l&&!r
108158
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
018158
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 8157 ▶ 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 8136 8141
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
2018136
$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
1648137
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection" or $op eq "\x{22c2}"
l!l&&r!l&&!r
1608141
$op eq "union" or $op eq "\x{22c3}" or $op eq "intersection"
l!l&&r!l&&!r
1068141
$op eq "union" or $op eq "\x{22c3}"
l!l&&r!l&&!r
738147
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 8136 ▶ return 12 if $op eq '_' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "_" 2215 5921 8136
2129  
2130 5921 ▶ return 13 if $op eq '+' || $op eq '-' ;
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "+" or $op eq "-" 1164 4757 5921
Condition100%3/3
$op eq "+" or $op eq "-"
l!l&&r!l&&!r
7793854757
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 4757 ▶ 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 4509 4572
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
189594509
$op eq "*" or $op eq "/" or $op eq "\x{d7}" or $op eq "\x{f7}"
l!l&&r!l&&!r
18544568
$op eq "*" or $op eq "/" or $op eq "\x{d7}"
l!l&&r!l&&!r
165204572
$op eq "*" or $op eq "/"
l!l&&r!l&&!r
125404592
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 4509 ▶ return 15 if $op eq '**';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "**" 5 4504 4509
2135  
2136 4504 return 0;
2137 }
2138  
2139 sub _parse_prec {
2140 70620 ▶ my ($self, $min_prec) = @_;
Subroutine _parse_prec: called CC=24 SCAR=31.8
2141  
2142 70620 my $t = $self->{tok};
2143 70620 my $left = $self->parse_prefix;
2144  
2145 70520 while (1) {
2146 81511 my $op_tok = $self->{tok};
2147 81511 my $op;
2148  
2149 81511 ▶ if ($op_tok->is_OP || $op_tok->is_KW) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op_tok->is_OP or $op_tok->is_KW) { } 81020 491 81511
Condition100%3/3
$op_tok->is_OP or $op_tok->is_KW
l!l&&r!l&&!r
746096411491
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 81020 $op = $op_tok->value;
2151 } else {
2152 491 last;
2153 }
2154  
2155 # stop at statement terminators / closers
2156 81020 ▶ 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 ":" 17358 17891 35249
Condition100%18/18
$op_tok->is_OP and $op eq ";" || $op eq ")" || $op eq "]" || $op eq "}" || $op eq "," || $op eq ":"
!ll&&!rl&&r
6411714783131
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq "," or $op eq ":"
l!l&&r!l&&!r
62101102811480
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}" or $op eq ","
l!l&&r!l&&!r
457711633012508
$op eq ";" or $op eq ")" or $op eq "]" or $op eq "}"
l!l&&r!l&&!r
4531146028838
$op eq ";" or $op eq ")" or $op eq "]"
l!l&&r!l&&!r
43635167629298
$op eq ";" or $op eq ")"
l!l&&r!l&&!r
208442279130974
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 11480 ▶ && @{ $self->{_pending_set_closers} || [] }
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_pending_set_closers"} or [] 11308 172 11480
2162 17891 ▶ && $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 17841 17891
Condition100%6/6
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];} and $op eq $self->{"_pending_set_closers"}[-1]
!ll&&!rl&&r
17838350
$op_tok->is_OP and @{$self->{"_pending_set_closers"} or [];}
!ll&&!rl&&r
64111142753
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 17841 my $prec = $self->_prec($op);
2165 17841 ▶ last if $prec < $min_prec || $prec == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $prec < $min_prec or $prec == 0 6850 10991 17841
Condition100%3/3
$prec < $min_prec or $prec == 0
l!l&&r!l&&!r
2709414110991
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 10991 ▶ 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
5010986
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
5010986
$op eq "**" or $op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
5010986
$op eq "**" or $op eq "onlyif"
l!l&&r!l&&!r
5010986
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 10991 ▶ my $next_min = $right_assoc ? $prec : ($prec + 1);
Branch: 1 branch
BranchTrueFalseTotal
$right_assoc ? : 5 10986 10991
2173  
2174 10991 $self->{tok} = $self->{lexer}->next_token; # consume op
2175 10991 my $right;
2176 10991 ▶ 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 10959 10991
Condition83%5/6
$op eq "can" and $self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW
!ll&&!rl&&r
109421732
$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 10959 $right = $self->_parse_prec($next_min);
2187 }
2188  
2189 10991 $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 70520 return $left;
2196 }
2197  
2198 sub parse_prefix {
2199 72482 ▶ my ($self) = @_;
Subroutine parse_prefix: called CC=41 SCAR=37.2
Pod documented
2200  
2201 72482 my $t = $self->{tok};
2202  
2203 72482 ▶ 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 72476 72482
Condition100%6/6
$t->is_OP and $t->value eq "->" || $t->value eq "\x{2192}"
!ll&&!rl&&r
6896335163
$t->value eq "->" or $t->value eq "\x{2192}"
l!l&&r!l&&!r
333513
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 72476 ▶ 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 72338 72365
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
68963348627
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#" or $t->value eq "\x{221a}" or $t->value eq "\\"
l!l&&r!l&&!r
111273375
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#" or $t->value eq "\x{221a}"
l!l&&r!l&&!r
11103402
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~" or $t->value eq "#"
l!l&&r!l&&!r
72393402
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}" or $t->value eq "~"
l!l&&r!l&&!r
6393441
$t->value eq "+" or $t->value eq "-" or $t->value eq "!" or $t->value eq "\x{ac}"
l!l&&r!l&&!r
6303450
$t->value eq "+" or $t->value eq "-" or $t->value eq "!"
l!l&&r!l&&!r
6123450
$t->value eq "+" or $t->value eq "-"
l!l&&r!l&&!r
1603452
MC/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 72338 ▶ if ( $t->is_KW and $t->value eq 'not' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW and $t->value eq "not") 1000 71338 72338
Condition100%3/3
$t->is_KW and $t->value eq "not"
!ll&&!rl&&r
6726240761000
MC/DC100%2/2
$t->is_KW and $t->value eq "not"
$t->is_KW $t->value eq "not"
Truth table100%3/3
A and B
A= $t->is_KWB= $t->value eq "not"
ABresult
0X0
100
111
2256 1000 $self->{tok} = $self->{lexer}->next_token;
2257 1000 my $expr = $self->parse_prefix;
2258  
2259 998 return Zuzu::AST::Expr::Unary->new(file => $t->file, line => $t->line, op => 'not', expr => $expr);
2260 }
2261 71338 ▶ 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 71337 71338
Condition66%2/3
$t->is_KW("let") or $t->is_KW("const")
l!l&&r!l&&!r
1071337
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 71337 ▶ if ( $t->is_KW('try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("try")) 23 71314 71337
2265 23 return $self->parse_try;
2266 }
2267 71314 ▶ if ( $t->is_KW('await') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("await")) 112 71202 71314
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 71202 ▶ if ( $t->is_KW('spawn') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("spawn")) 17 71185 71202
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 71185 ▶ if ( $t->is_KW('do') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("do")) 8 71177 71185
2290 8 $self->_eat( 'KW', 'do' );
2291  
2292 8 return $self->parse_block;
2293 }
2294 71177 ▶ if ( $t->is_KW('async') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("async")) 7 71170 71177
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 71170 ▶ 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 70456 70938
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
67262380999
$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 70456 ▶ 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 70445 70456
Condition66%4/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
6708133750
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
1103364
MC/DC66%2/3
$t->is_OP and $t->value eq "++" || $t->value eq "--"
$t->is_OP $t->value eq "++" $t->value eq "--"
Truth table75%3/4
A and B or C
A= $t->is_OPB= $t->value eq "++"C= $t->value eq "--"
ABCresult
0XX0
1000
11X1
1011
2330 11 $self->{tok} = $self->{lexer}->next_token;
2331 11 my $target = $self->parse_prefix;
2332 11 $self->_assert_mutable_target($target, $t);
2333  
2334 10 return Zuzu::AST::Expr::IncDec->new(
2335 file => $t->file,
2336 line => $t->line,
2337 op => $t->value,
2338 target => $target,
2339 postfix => 0,
2340 );
2341 }
2342  
2343 70445 my $prim = $self->parse_primary;
2344  
2345 70354 return $self->parse_postfix($prim);
2346 }
2347  
2348 sub parse_primary {
2349 71241 ▶ my ($self) = @_;
Subroutine parse_primary: called CC=74 SCAR=46.2
Pod documented
2350  
2351 71241 my $t = $self->{tok};
2352  
2353 71241 ▶ if ($t->is_NUMBER) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NUMBER) 6436 64805 71241
2354 6436 $self->{tok} = $self->{lexer}->next_token;
2355 6436 my $v = $t->value;
2356 6436 ▶ $v = ($v =~ /\./) ? 0.0 + $v : 0 + $v;
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /\./ ? : 72 6364 6436
2357  
2358 6436 return Zuzu::AST::Expr::Literal->new(file => $t->file, line => $t->line, value => $v);
2359 }
2360 64805 ▶ if ($t->is_STRING) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_STRING) 10798 54007 64805
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 54007 ▶ if ( $t->is_type('BINARY_STRING') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("BINARY_STRING")) 12 53995 54007
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 53995 ▶ if ( $t->is_type('TEMPLATE') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_type("TEMPLATE")) 374 53621 53995
2375 374 $self->{tok} = $self->{lexer}->next_token;
2376  
2377 374 return $self->_parse_template_expression($t);
2378 }
2379 53621 ▶ if ($t->is_REGEXP) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_REGEXP) 324 53297 53621
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 53297 ▶ if ($t->is_BOOL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_BOOL) 1963 51334 53297
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 51334 ▶ if ($t->is_NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_NULL) 1823 49511 51334
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 49511 ▶ if ($t->is_IDENT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_IDENT) 42918 6593 49511
2421 42918 my $id = $self->_eat('IDENT');
2422 42918 my $name = $id->value;
2423 42918 my $info = $self->_lookup($name);
2424 my $is_named_arg_label
2425 = ( $self->{_invocation_arg_depth} // 0 )
2426 42918 ▶ and $self->{tok}->is_OP(':');
Branch: 1 branch
BranchTrueFalseTotal
my $is_named_arg_label = $self->{"_invocation_arg_depth"} // 0 and $self->{"tok"}->is_OP(":") 17139 25779 42918
Condition100%2/2
$self->{"_invocation_arg_depth"} // 0
l!l
413581560
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 42918 my $is_chain_placeholder = $name eq '^^';
2428 42918 ▶ 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 42882 42918
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
42882036
$info or $is_chain_placeholder or $self->_has_wildcard_import_in_scope
l!l&&r!l&&!r
4269618636
$info or $is_chain_placeholder
l!l&&r!l&&!r
4265343222
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 42882 return Zuzu::AST::Expr::Var->new(file => $id->file, line => $id->line, name => $name);
2433 }
2434 6593 ▶ if ($t->is_KW('self')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("self")) 1920 4673 6593
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 4673 ▶ if ($t->is_KW('super')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_KW("super")) 37 4636 4673
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 4636 ▶ if ($t->is_OP && $t->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "(") 1193 3443 4636
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
126821751193
MC/DC100%2/2
$t->is_OP and $t->value eq "("
$t->is_OP $t->value eq "("
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "("
ABresult
0X0
100
111
2451 1193 $self->_eat('OP', '(');
2452 1193 my $e = $self->parse_expression;
2453 1193 $self->_eat('OP', ')');
2454  
2455 1182 return $e;
2456 }
2457 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 70361 ▶ my ($self, $expr) = @_;
Subroutine parse_postfix: called CC=20 SCAR=30.0
Pod documented
2837  
2838 70361 while (1) {
2839 89536 my $t = $self->{tok};
2840  
2841 # function call
2842 89536 ▶ if ($t->is_OP && $t->value eq '(') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "(") 6608 82928 89536
Condition100%3/3
$t->is_OP and $t->value eq "("
!ll&&!rl&&r
5418775106608
MC/DC100%2/2
$t->is_OP and $t->value eq "("
$t->is_OP $t->value eq "("
Truth table100%3/3
A and B
A= $t->is_OPB= $t->value eq "("
ABresult
0X0
100
111
2843 6608 my $lp = $self->_eat('OP', '(');
2844 6608 my @args = $self->_parse_invocation_args;
2845 6606 $self->_eat('OP', ')');
2846 6606 $expr = Zuzu::AST::Expr::Call->new(file => $lp->file, line => $lp->line, callee => $expr, args => \@args);
2847 6606 next;
2848 }
2849  
2850 # member call: obj.method(...) or obj.method (no-arg call handled at runtime by allowing method without ())
2851 82928 ▶ if ($t->is_OP && $t->value eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq ".") 8304 74624 82928
Condition100%3/3
$t->is_OP and $t->value eq "."
!ll&&!rl&&r
5418692068304
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 74624 ▶ if ($t->is_OP && $t->value eq '[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "[") 1130 73494 74624
Condition100%3/3
$t->is_OP and $t->value eq "["
!ll&&!rl&&r
5418680761130
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 73494 ▶ if ($t->is_OP && ($t->value eq '++' || $t->value eq '--')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "++" || $t->value eq "--") 683 72811 73494
Condition100%6/6
$t->is_OP and $t->value eq "++" || $t->value eq "--"
!ll&&!rl&&r
54186803442
$t->value eq "++" or $t->value eq "--"
l!l&&r!l&&!r
6414267393
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 683 my $op = $self->_eat('OP');
2916 683 $self->_assert_mutable_target($expr, $op);
2917 682 $expr = Zuzu::AST::Expr::IncDec->new(
2918 file => $op->file,
2919 line => $op->line,
2920 op => $op->value,
2921 target => $expr,
2922 postfix => 1,
2923 );
2924 682 next;
2925 }
2926  
2927 # dict access: d{expr} or d{ident}
2928 72811 ▶ if ($t->is_OP && $t->value eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->is_OP and $t->value eq "{") 2454 70357 72811
Condition100%3/3
$t->is_OP and $t->value eq "{"
!ll&&!rl&&r
5418649392454
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 70357 last;
2937 }
2938  
2939 70357 return $expr;
2940 }
2941  
2942 sub _parse_invocation_args {
2943 15225 ▶ my ( $self ) = @_;
Subroutine _parse_invocation_args: called CC=15 SCAR=27.8
2944  
2945 15225 my @args;
2946 15225 $self->{_invocation_arg_depth}++;
2947 15225 ▶ while ( ! $self->{tok}->is_OP(')') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"tok"}->is_OP(")")) 23292 15222 38514
2948 # ignore superfluous commas between arguments
2949 23292 ▶ if ( $self->_maybe('OP', ',') ) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 23292 23292
2950  
2951 23292 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 20 23272 23292
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 23272 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")) 1975 21297 23272
Condition100%6/6
$self->{"tok"}->is_IDENT || $self->{"tok"}->is_KW and $self->_peek_token->is_OP(":")
!ll&&!rl&&r
6736145611975
$self->{"tok"}->is_IDENT or $self->{"tok"}->is_KW
l!l&&r!l&&!r
157717656736
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 21297 my $expr = $self->parse_expression;
2986 21296 ▶ if ( $self->_maybe('OP', ':') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe('OP', ':')) { } 6 21290 21296
2987 6 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 0 6 6
2988 0 $self->_err("Spread arguments cannot be named", $self->{tok});
2989 }
2990 6 my $value_expr = $self->parse_expression;
2991 6 ▶ if ( $expr and blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr and builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var')) { } 0 6 6
Condition33%2/6
$expr and builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
060
$expr and builtin::blessed($expr)
!ll&&!rl&&r
006
MC/DC0%0/3
$expr and builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
$expr builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table25%1/4
A and B and C
A= $exprB= builtin::blessed($expr)C= $expr->isa("Zuzu::AST::Expr::Var")
ABCresult
0XX0
10X0
1100
1111
2992 0 push @args, [ $expr->name, $value_expr ];
2993 }
2994 else {
2995 6 push @args, [ $expr, $value_expr, 1 ];
2996 }
2997 }
2998 else {
2999 21290 ▶ if ( $self->{tok}->is_OP('...') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_OP("...")) 1 21289 21290
3000 1 $self->_err("Range syntax '...' is only valid in collection literals", $self->{tok});
3001 }
3002 21289 push @args, [ undef, $expr ];
3003 }
3004 21295 $self->_maybe('OP', ',');
3005 }
3006 15222 $self->{_invocation_arg_depth}--;
3007  
3008 15222 return @args;
3009 }
3010  
3011 sub _assert_mutable_target {
3012 2934 ▶ my ( $self, $expr, $tok ) = @_;
Subroutine _assert_mutable_target: called CC=6 SCAR=18.2
3013  
3014 2934 ▶ 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 2697 2934
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
02372697
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Var")
ABresult
0X0
100
111
3015  
3016 2697 my $info = $self->_lookup($expr->name);
3017 2697 ▶ return if ! $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 0 2697 2697
3018 2697 ▶ return if ! exists $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $info->{"mutable"} 0 2697 2697
3019 2697 ▶ return if $info->{mutable};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"mutable"} 2690 7 2697
3020  
3021 7 $self->_err("Cannot assign to const '".$expr->name."' (compile-time)", $tok);
3022 }
3023  
3024 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 4761 ▶ my ( $self ) = @_;
Subroutine _parse_dict_key_expr: called CC=3 SCAR=11.0
3051  
3052 4761 ▶ if ( $self->{tok}->is_IDENT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tok"}->is_IDENT) 4481 280 4761
3053 4481 my $id = $self->_eat('IDENT');
3054  
3055 4481 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 "}") 2240 820 3060
Condition100%3/3
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "}"
!ll&&!rl&&r
22391820
MC/DC100%2/2
$self->{"tok"}->is_OP and $self->{"tok"}->value eq "}"
$self->{"tok"}->is_OP $self->{"tok"}->value eq "}"
Truth table100%3/3
A and B
A= $self->{"tok"}->is_OPB= $self->{"tok"}->value eq "}"
ABresult
0X0
100
111
3108 2240 ▶ if ($self->_maybe('OP', ',')) { next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_maybe("OP", ",")) 0 2240 2240
3109 2240 my $key;
3110 2240 $key = $self->_parse_dict_key_expr;
3111 2238 $self->_eat('OP', ':');
3112 2237 my $val = $self->parse_expression;
3113 2235 push @pairs, [ $key, $val ];
3114 2235 $self->_maybe('OP', ',');
3115 }
3116 820 $self->_eat('OP', '}');
3117  
3118 820 return Zuzu::AST::Expr::Dict->new(file => $lb->file, line => $lb->line, pairs => \@pairs);
3119 }
3120  
3121 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 »