| 1 | package Jinja2::TT2::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use v5.20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # AST Node types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | NODE_ROOT => 'ROOT', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | NODE_TEXT => 'TEXT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | NODE_OUTPUT => 'OUTPUT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | NODE_COMMENT => 'COMMENT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | NODE_IF => 'IF', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | NODE_ELIF => 'ELIF', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | NODE_ELSE => 'ELSE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | NODE_FOR => 'FOR', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | NODE_BLOCK => 'BLOCK', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | NODE_EXTENDS => 'EXTENDS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | NODE_INCLUDE => 'INCLUDE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | NODE_IMPORT => 'IMPORT', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | NODE_FROM => 'FROM', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | NODE_SET => 'SET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | NODE_MACRO => 'MACRO', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | NODE_CALL => 'CALL', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | NODE_FILTER => 'FILTER', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | NODE_RAW => 'RAW', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | NODE_WITH => 'WITH', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | NODE_AUTOESCAPE => 'AUTOESCAPE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | NODE_EXPR => 'EXPR', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | my ($class, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | tokens => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | pos => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 65 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 65 | my ($self, $tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 65 | $self->{tokens} = $tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 65 | $self->{pos} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 65 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 65 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 71 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 71 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 65 | return { type => NODE_ROOT, body => \@body }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 100 | ▶ | sub _parse_node { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_node: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 100 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 100 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 100 | ▶ | return undef unless $token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 100 | ▶ | if ($token->{type} eq 'TEXT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 27 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 27 | return { type => NODE_TEXT, value => $token->{value} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 73 | ▶ | if ($token->{type} eq 'COMMENT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | return { type => NODE_COMMENT, value => $token->{value} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 71 | ▶ | if ($token->{type} eq 'VAR_START') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 46 | return $self->_parse_output(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 25 | ▶ | if ($token->{type} eq 'STMT_START') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 25 | return $self->_parse_statement(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # Skip unknown tokens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 46 | ▶ | sub _parse_output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_output: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 46 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 46 | my $start = $self->_expect('VAR_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 46 | my $expr = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 46 | my $end = $self->_expect('VAR_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | type => NODE_OUTPUT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | expr => $expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | strip_before => $start->{strip_before}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 46 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 25 | ▶ | sub _parse_statement { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_statement: called CC=19 SCAR=42.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 25 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 25 | my $start = $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 25 | my $strip_before = $start->{strip_before}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 25 | my $keyword = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 25 | ▶ | unless ($keyword && $keyword->{type} eq 'NAME') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$keyword and $keyword->{"type"} eq "NAME"
MC/DC0%0/2
$keyword and $keyword->{"type"} eq "NAME"
$keyword
$keyword->{"type"} eq "NAME"
Truth table33%1/3
A and B
A= $keywordB= $keyword->{"type"} eq "NAME"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | die "Expected statement keyword at position " . ($keyword->{pos} // 'unknown'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$keyword->{"pos"} // "unknown"
MC/DC0%0/1
$keyword->{"pos"} // "unknown"
$keyword->{"pos"}
Truth table0%0/2
A
A= $keyword->{"pos"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 25 | my $kw = $keyword->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 25 | ▶ | if ($kw eq 'if') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 15 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 13 | return $self->_parse_if($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif ($kw eq 'for') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | return $self->_parse_for($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif ($kw eq 'block') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | return $self->_parse_block($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } elsif ($kw eq 'extends') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $self->_parse_extends($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } elsif ($kw eq 'include') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | return $self->_parse_include($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } elsif ($kw eq 'import') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return $self->_parse_import($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } elsif ($kw eq 'from') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return $self->_parse_from($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } elsif ($kw eq 'set') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | return $self->_parse_set($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } elsif ($kw eq 'macro') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | return $self->_parse_macro($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } elsif ($kw eq 'call') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return $self->_parse_call_block($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } elsif ($kw eq 'filter') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return $self->_parse_filter_block($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } elsif ($kw eq 'raw') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $self->_parse_raw($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } elsif ($kw eq 'with') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return $self->_parse_with($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } elsif ($kw eq 'autoescape') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return $self->_parse_autoescape($strip_before); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } elsif ($kw =~ /^(endif|endfor|endblock|endmacro|endcall|endfilter|endraw|endwith|endautoescape|elif|else)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # These are handled by their parent parsers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | die "Unexpected '$kw' without matching opening tag"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | die "Unknown statement keyword '$kw'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 13 | ▶ | sub _parse_if { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_if: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 13 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | $self->_advance(); # consume 'if' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 13 | my $condition = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 13 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 13 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | my @branches; # For elif/else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 13 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # Check for elif, else, endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 36 | ▶ | if ($self->_is_stmt_keyword('elif')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $elif_start = $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | $self->_advance(); # consume 'elif' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | my $elif_cond = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | push @branches, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | type => NODE_ELIF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | condition => $elif_cond, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | body => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 34 | ▶ | if ($self->_is_stmt_keyword('else')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | my $else_start = $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | $self->_advance(); # consume 'else' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | push @branches, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | type => NODE_ELSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | body => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 29 | ▶ | if ($self->_is_stmt_keyword('endif')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 13 | my $endif_start = $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 13 | $self->_advance(); # consume 'endif' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 13 | my $endif_end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 13 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # Parse body content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 16 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 16 | ▶ | if ($node) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 16 | ▶ | if (@branches) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | push @{$branches[-1]{body}}, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 9 | push @body, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | type => NODE_IF, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | condition => $condition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | branches => \@branches, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 13 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | ▶ | sub _parse_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_for: called CC=16 SCAR=34.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | $self->_advance(); # consume 'for' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # Parse loop variable(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | my @loop_vars; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | push @loop_vars, $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | ▶ | while ($self->_check('COMMA')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | push @loop_vars, $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # Expect 'in' (tokenized as OPERATOR) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | my $in_token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | ▶ | if (!$in_token || ($in_token->{type} ne 'OPERATOR' && $in_token->{type} ne 'NAME') || $in_token->{value} ne 'in') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not $in_token or $in_token->{"type"} ne "OPERATOR" and $in_token->{"type"} ne "NAME" or $in_token->{"value"} ne "in"
not $in_token or $in_token->{"type"} ne "OPERATOR" and $in_token->{"type"} ne "NAME"
$in_token->{"type"} ne "OPERATOR" and $in_token->{"type"} ne "NAME"
MC/DC0%0/4
not $in_token or $in_token->{"type"} ne "OPERATOR" and $in_token->{"type"} ne "NAME" or $in_token->{"value"} ne "in"
not $in_token
$in_token->{"type"} ne "OPERATOR"
$in_token->{"type"} ne "NAME"
$in_token->{"value"} ne "in"
Truth table16%1/6
not(A) or B and C or D
A= not $in_tokenB= $in_token->{"type"} ne "OPERATOR"C= $in_token->{"type"} ne "NAME"D= $in_token->{"value"} ne "in"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | die "Expected 'in' in for loop, got " . ($in_token->{type} // 'EOF') . " '$in_token->{value}'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$in_token->{"type"} // "EOF"
MC/DC0%0/1
$in_token->{"type"} // "EOF"
$in_token->{"type"}
Truth table0%0/2
A
A= $in_token->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 5 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # Parse iterable expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 5 | my $iterable = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # Check for optional 'if' filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | my $filter_cond; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 5 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'if') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("NAME") and $self->_current->{"value"} eq "if"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "if"
$self->_check("NAME")
$self->_current->{"value"} eq "if"
Truth table33%1/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "if"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $filter_cond = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | # Check for 'recursive' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | my $recursive = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 5 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'recursive') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("NAME") and $self->_current->{"value"} eq "recursive"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "recursive"
$self->_check("NAME")
$self->_current->{"value"} eq "recursive"
Truth table33%1/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "recursive"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $recursive = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | my @else_body; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | my $in_else = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 14 | ▶ | if ($self->_is_stmt_keyword('else')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->_advance(); # consume 'else' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $in_else = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 14 | ▶ | if ($self->_is_stmt_keyword('endfor')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | $self->_advance(); # consume 'endfor' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 9 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 9 | ▶ | if ($node) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 9 | ▶ | if ($in_else) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | push @else_body, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 9 | push @body, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | type => NODE_FOR, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | loop_vars => \@loop_vars, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | iterable => $iterable, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | filter => $filter_cond, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | recursive => $recursive, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else_body => \@else_body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | ▶ | sub _parse_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_block: called CC=7 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 2 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 2 | $self->_advance(); # consume 'block' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 2 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Check for 'scoped' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | my $scoped = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'scoped') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("NAME") and $self->_current->{"value"} eq "scoped"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "scoped"
$self->_check("NAME")
$self->_current->{"value"} eq "scoped"
Truth table33%1/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "scoped"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $scoped = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | ▶ | if ($self->_is_stmt_keyword('endblock')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | $self->_advance(); # consume 'endblock' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Optional block name after endblock | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | ▶ | if ($self->_check('NAME')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | type => NODE_BLOCK, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | scoped => $scoped, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub _parse_extends { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_extends: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->_advance(); # consume 'extends' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $template = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | type => NODE_EXTENDS, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | template => $template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 2 | ▶ | sub _parse_include { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_include: called CC=11 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | $self->_advance(); # consume 'include' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | my $template = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | # Check for 'ignore missing' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | my $ignore_missing = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'ignore') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("NAME") and $self->_current->{"value"} eq "ignore"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "ignore"
$self->_check("NAME")
$self->_current->{"value"} eq "ignore"
Truth table33%1/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "ignore"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'missing') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("NAME") and $self->_current->{"value"} eq "missing"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "missing"
$self->_check("NAME")
$self->_current->{"value"} eq "missing"
Truth table0%0/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "missing"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $ignore_missing = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # Check for 'with context' or 'without context' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | my $with_context = 1; # default | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2 | ▶ | if ($self->_check('NAME')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $ctx = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if ($ctx eq 'with' || $ctx eq 'without') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctx eq "with" or $ctx eq "without"
MC/DC0%0/2
$ctx eq "with" or $ctx eq "without"
$ctx eq "with"
$ctx eq "without"
Truth table0%0/3
A or B
A= $ctx eq "with"B= $ctx eq "without"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'context') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("NAME") and $self->_current->{"value"} eq "context"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "context"
$self->_check("NAME")
$self->_current->{"value"} eq "context"
Truth table0%0/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "context"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $with_context = ($ctx eq 'with') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | type => NODE_INCLUDE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | template => $template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ignore_missing => $ignore_missing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | with_context => $with_context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub _parse_import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_import: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->_advance(); # consume 'import' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $template = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # Expect 'as' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->_expect_keyword('as'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $alias = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # Check for 'with context' or 'without context' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | my $with_context = 0; # default for import | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ($self->_check('NAME')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $ctx = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if ($ctx eq 'with' || $ctx eq 'without') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctx eq "with" or $ctx eq "without"
MC/DC0%0/2
$ctx eq "with" or $ctx eq "without"
$ctx eq "with"
$ctx eq "without"
Truth table0%0/3
A or B
A= $ctx eq "with"B= $ctx eq "without"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'context') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("NAME") and $self->_current->{"value"} eq "context"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "context"
$self->_check("NAME")
$self->_current->{"value"} eq "context"
Truth table0%0/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "context"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | $with_context = ($ctx eq 'with') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | type => NODE_IMPORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | template => $template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | alias => $alias, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | with_context => $with_context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | sub _parse_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_from: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $self->_advance(); # consume 'from' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $template = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # Expect 'import' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $self->_expect_keyword('import'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # Parse imported names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my @imports; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table0%0/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $alias = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'as') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("NAME") and $self->_current->{"value"} eq "as"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "as"
$self->_check("NAME")
$self->_current->{"value"} eq "as"
Truth table0%0/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "as"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $alias = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | push @imports, { name => $name, alias => $alias }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # Check for 'with context' or 'without context' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $with_context = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ($self->_check('NAME')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $ctx = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ($ctx eq 'with' || $ctx eq 'without') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ctx eq "with" or $ctx eq "without"
MC/DC0%0/2
$ctx eq "with" or $ctx eq "without"
$ctx eq "with"
$ctx eq "without"
Truth table0%0/3
A or B
A= $ctx eq "with"B= $ctx eq "without"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'context') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("NAME") and $self->_current->{"value"} eq "context"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "context"
$self->_check("NAME")
$self->_current->{"value"} eq "context"
Truth table0%0/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "context"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $with_context = ($ctx eq 'with') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | type => NODE_FROM, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | template => $template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | imports => \@imports, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | with_context => $with_context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | sub _parse_set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_set: called CC=6 SCAR=27.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 2 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 2 | $self->_advance(); # consume 'set' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Parse variable name(s) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 2 | my @names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | push @names, $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 2 | ▶ | while ($self->_check('COMMA')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | push @names, $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # Check if it's a block set or inline set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 2 | ▶ | if ($self->_check('ASSIGN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | my $value = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 2 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | type => NODE_SET, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | names => \@names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | strip_after => $end->{strip_after}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | # Block set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my $end = $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if ($self->_is_stmt_keyword('endset')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | $self->_advance(); # consume 'endset' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | type => NODE_SET, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | names => \@names, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | ▶ | sub _parse_macro { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_macro: called CC=8 SCAR=21.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 1 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | $self->_advance(); # consume 'macro' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Parse arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | $self->_expect('LPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 1 | ▶ | unless ($self->_check('RPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table33%1/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | my $arg_name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | my $default; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | ▶ | if ($self->_check('ASSIGN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $default = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | push @args, { name => $arg_name, default => $default }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 1 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 3 | ▶ | if ($self->_is_stmt_keyword('endmacro')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | $self->_advance(); # consume 'endmacro' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | type => NODE_MACRO, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | args => \@args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | sub _parse_call_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_call_block: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $self->_advance(); # consume 'call' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # Optional arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if ($self->_check('LPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | unless ($self->_check('RPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table0%0/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | push @args, $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # Parse the macro call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $call = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | if ($self->_is_stmt_keyword('endcall')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $self->_advance(); # consume 'endcall' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | type => NODE_CALL, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | args => \@args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | call => $call, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | sub _parse_filter_block { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_filter_block: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | $self->_advance(); # consume 'filter' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $filter = $self->_parse_filter_chain(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if ($self->_is_stmt_keyword('endfilter')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $self->_advance(); # consume 'endfilter' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | type => NODE_FILTER, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | filter => $filter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub _parse_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_raw: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $self->_advance(); # consume 'raw' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # Collect everything until {% endraw %} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $raw_text = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ($self->_is_stmt_keyword('endraw')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $self->_advance(); # consume 'endraw' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | $raw_text .= $token->{value} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$token->{"value"} // ""
MC/DC0%0/1
$token->{"value"} // ""
$token->{"value"}
Truth table0%0/2
A
A= $token->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | type => NODE_RAW, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | value => $raw_text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | sub _parse_with { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_with: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | $self->_advance(); # consume 'with' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # Parse variable assignments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my @assignments; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | unless ($self->_check('STMT_END')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table0%0/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $self->_expect('ASSIGN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $value = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | push @assignments, { name => $name, value => $value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ($self->_is_stmt_keyword('endwith')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $self->_advance(); # consume 'endwith' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | type => NODE_WITH, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | assignments => \@assignments, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | sub _parse_autoescape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_autoescape: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my ($self, $strip_before) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | $self->_advance(); # consume 'autoescape' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | my $enabled = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my @body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | while (!$self->_at_end()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | if ($self->_is_stmt_keyword('endautoescape')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $self->_expect('STMT_START'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $self->_advance(); # consume 'endautoescape' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | $self->_expect('STMT_END'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $node = $self->_parse_node(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | push @body, $node if $node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | type => NODE_AUTOESCAPE, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | enabled => $enabled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | body => \@body, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | strip_before => $strip_before, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | # Expression parsing with precedence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 85 | ▶ | sub _parse_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_expression: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 85 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 85 | return $self->_parse_ternary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 87 | ▶ | sub _parse_ternary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_ternary: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 87 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 87 | my $expr = $self->_parse_or(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | # Check for ternary: expr if condition else other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 87 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'if') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_check("NAME") and $self->_current->{"value"} eq "if"
MC/DC50%1/2
$self->_check("NAME") and $self->_current->{"value"} eq "if"
$self->_check("NAME")
$self->_current->{"value"} eq "if"
Truth table66%2/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "if"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 2 | my $condition = $self->_parse_or(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 2 | ▶ | if ($self->_check('NAME') && $self->_current()->{value} eq 'else') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("NAME") and $self->_current->{"value"} eq "else"
MC/DC0%0/2
$self->_check("NAME") and $self->_current->{"value"} eq "else"
$self->_check("NAME")
$self->_current->{"value"} eq "else"
Truth table33%1/3
A and B
A= $self->_check("NAME")B= $self->_current->{"value"} eq "else"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 2 | my $else_expr = $self->_parse_ternary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | type => 'TERNARY', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | true_val => $expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | condition => $condition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | false_val => $else_expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | # Short form: value if condition (no else) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | type => 'TERNARY', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | true_val => $expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | condition => $condition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | false_val => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 85 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 89 | ▶ | sub _parse_or { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_or: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 89 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 89 | my $left = $self->_parse_and(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 89 | ▶ | while ($self->_check('OPERATOR') && $self->_current()->{value} eq 'or') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_check("OPERATOR") and $self->_current->{"value"} eq "or"
MC/DC50%1/2
$self->_check("OPERATOR") and $self->_current->{"value"} eq "or"
$self->_check("OPERATOR")
$self->_current->{"value"} eq "or"
Truth table66%2/3
A and B
A= $self->_check("OPERATOR")B= $self->_current->{"value"} eq "or"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 2 | my $right = $self->_parse_and(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 2 | $left = { type => 'BINOP', op => 'or', left => $left, right => $right }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 89 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 91 | ▶ | sub _parse_and { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_and: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 91 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 91 | my $left = $self->_parse_not(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 91 | ▶ | while ($self->_check('OPERATOR') && $self->_current()->{value} eq 'and') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_check("OPERATOR") and $self->_current->{"value"} eq "and"
MC/DC100%2/2
$self->_check("OPERATOR") and $self->_current->{"value"} eq "and"
$self->_check("OPERATOR")
$self->_current->{"value"} eq "and"
Truth table100%3/3
A and B
A= $self->_check("OPERATOR")B= $self->_current->{"value"} eq "and"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 2 | my $right = $self->_parse_not(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 2 | $left = { type => 'BINOP', op => 'and', left => $left, right => $right }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 91 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 94 | ▶ | sub _parse_not { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_not: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 94 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 94 | ▶ | if ($self->_check('OPERATOR') && $self->_current()->{value} eq 'not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_check("OPERATOR") and $self->_current->{"value"} eq "not"
MC/DC50%1/2
$self->_check("OPERATOR") and $self->_current->{"value"} eq "not"
$self->_check("OPERATOR")
$self->_current->{"value"} eq "not"
Truth table66%2/3
A and B
A= $self->_check("OPERATOR")B= $self->_current->{"value"} eq "not"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 1 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1 | my $operand = $self->_parse_not(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | return { type => 'UNARYOP', op => 'not', operand => $operand }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 93 | return $self->_parse_comparison(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 93 | ▶ | sub _parse_comparison { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_comparison: called CC=9 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 93 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 93 | my $left = $self->_parse_additive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 93 | ▶ | while ($self->_check('OPERATOR')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 8 | my $op = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 8 | ▶ | if ($op =~ /^(==|!=|<|>|<=|>=|in|is)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 4 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | # Handle 'is not' and 'not in' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 4 | ▶ | if ($op eq 'is' && $self->_check('OPERATOR') && $self->_current()->{value} eq 'not') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$op eq "is" and $self->_check("OPERATOR") and $self->_current->{"value"} eq "not"
$op eq "is" and $self->_check("OPERATOR")
MC/DC0%0/3
$op eq "is" and $self->_check("OPERATOR") and $self->_current->{"value"} eq "not"
$op eq "is"
$self->_check("OPERATOR")
$self->_current->{"value"} eq "not"
Truth table25%1/4
A and B and C
A= $op eq "is"B= $self->_check("OPERATOR")C= $self->_current->{"value"} eq "not"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $op = 'is not'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | ▶ | } elsif ($op eq 'not' && $self->_check('OPERATOR') && $self->_current()->{value} eq 'in') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$op eq "not" and $self->_check("OPERATOR") and $self->_current->{"value"} eq "in"
$op eq "not" and $self->_check("OPERATOR")
MC/DC0%0/3
$op eq "not" and $self->_check("OPERATOR") and $self->_current->{"value"} eq "in"
$op eq "not"
$self->_check("OPERATOR")
$self->_current->{"value"} eq "in"
Truth table25%1/4
A and B and C
A= $op eq "not"B= $self->_check("OPERATOR")C= $self->_current->{"value"} eq "in"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | $op = 'not in'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 4 | my $right = $self->_parse_additive(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 4 | $left = { type => 'BINOP', op => $op, left => $left, right => $right }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 4 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 93 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 97 | ▶ | sub _parse_additive { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_additive: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 97 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 97 | my $left = $self->_parse_multiplicative(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 97 | ▶ | while ($self->_check('OPERATOR') || $self->_check('TILDE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_check("OPERATOR") or $self->_check("TILDE")
MC/DC100%2/2
$self->_check("OPERATOR") or $self->_check("TILDE")
$self->_check("OPERATOR")
$self->_check("TILDE")
Truth table100%3/3
A or B
A= $self->_check("OPERATOR")B= $self->_check("TILDE")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 10 | my $op = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 10 | ▶ | if ($op =~ /^[+\-~]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 2 | my $right = $self->_parse_multiplicative(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 2 | $left = { type => 'BINOP', op => $op, left => $left, right => $right }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 8 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 97 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 99 | ▶ | sub _parse_multiplicative { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_multiplicative: called CC=5 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 99 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 99 | my $left = $self->_parse_unary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 99 | ▶ | while ($self->_check('OPERATOR')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 9 | my $op = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 9 | ▶ | if ($op =~ /^[*\/%]$/ || $op eq '//' || $op eq '**') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$op =~ m[^[*/%]$]u or $op eq "//" or $op eq "**"
$op =~ m[^[*/%]$]u or $op eq "//"
MC/DC0%0/3
$op =~ m[^[*/%]$]u or $op eq "//" or $op eq "**"
$op =~ m[^[*/%]$]u
$op eq "//"
$op eq "**"
Truth table25%1/4
A or B or C
A= $op =~ m[^[*/%]$]uB= $op eq "//"C= $op eq "**"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $right = $self->_parse_unary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | $left = { type => 'BINOP', op => $op, left => $left, right => $right }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 9 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 99 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 99 | ▶ | sub _parse_unary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_unary: called CC=3 SCAR=15.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 99 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 99 | ▶ | if ($self->_check('OPERATOR') && $self->_current()->{value} =~ /^[+\-]$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("OPERATOR") and $self->_current->{"value"} =~ /^[+\-]$/u
MC/DC0%0/2
$self->_check("OPERATOR") and $self->_current->{"value"} =~ /^[+\-]$/u
$self->_check("OPERATOR")
$self->_current->{"value"} =~ /^[+\-]$/u
Truth table33%1/3
A and B
A= $self->_check("OPERATOR")B= $self->_current->{"value"} =~ /^[+\-]$/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $op = $self->_current()->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $operand = $self->_parse_unary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | return { type => 'UNARYOP', op => $op, operand => $operand }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 99 | return $self->_parse_filter_chain(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 99 | ▶ | sub _parse_filter_chain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_filter_chain: called CC=9 SCAR=25.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 99 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 99 | my $expr = $self->_parse_postfix(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 99 | ▶ | while ($self->_check('PIPE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 14 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 14 | my $filter_name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 14 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 14 | ▶ | if ($self->_check('LPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 2 | ▶ | unless ($self->_check('RPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 2 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table33%1/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | # Named argument? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 2 | ▶ | if ($self->_check('NAME') && $self->_peek() && $self->_peek()->{type} eq 'ASSIGN') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->_check("NAME") and $self->_peek and $self->_peek->{"type"} eq "ASSIGN"
$self->_check("NAME") and $self->_peek
MC/DC0%0/3
$self->_check("NAME") and $self->_peek and $self->_peek->{"type"} eq "ASSIGN"
$self->_check("NAME")
$self->_peek
$self->_peek->{"type"} eq "ASSIGN"
Truth table25%1/4
A and B and C
A= $self->_check("NAME")B= $self->_peekC= $self->_peek->{"type"} eq "ASSIGN"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | $self->_advance(); # consume = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | my $value = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 0 | push @args, { type => 'NAMED_ARG', name => $name, value => $value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 2 | push @args, $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 2 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 14 | $expr = { type => 'FILTER', name => $filter_name, expr => $expr, args => \@args }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 99 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 99 | ▶ | sub _parse_postfix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_postfix: called CC=10 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 99 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 99 | my $expr = $self->_parse_primary(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 99 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 110 | ▶ | if ($self->_check('DOT')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 8 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 8 | my $attr = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 8 | $expr = { type => 'GETATTR', expr => $expr, attr => $attr }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } elsif ($self->_check('LBRACKET')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 1 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 1 | my $index = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 1 | $self->_expect('RBRACKET'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 1 | $expr = { type => 'GETITEM', expr => $expr, index => $index }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } elsif ($self->_check('LPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 2 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | my @kwargs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 2 | ▶ | unless ($self->_check('RPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 2 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table33%1/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # Named argument? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 2 | ▶ | if ($self->_check('NAME') && $self->_peek() && $self->_peek()->{type} eq 'ASSIGN') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->_check("NAME") and $self->_peek and $self->_peek->{"type"} eq "ASSIGN"
$self->_check("NAME") and $self->_peek
MC/DC0%0/3
$self->_check("NAME") and $self->_peek and $self->_peek->{"type"} eq "ASSIGN"
$self->_check("NAME")
$self->_peek
$self->_peek->{"type"} eq "ASSIGN"
Truth table25%1/4
A and B and C
A= $self->_check("NAME")B= $self->_peekC= $self->_peek->{"type"} eq "ASSIGN"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 0 | my $name = $self->_expect('NAME')->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | $self->_advance(); # consume = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | my $value = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | push @kwargs, { name => $name, value => $value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 2 | push @args, $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 2 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 2 | $expr = { type => 'CALL', expr => $expr, args => \@args, kwargs => \@kwargs }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 99 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 99 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 99 | ▶ | sub _parse_primary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_primary: called CC=22 SCAR=38.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 99 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 99 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | # Name/identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 99 | ▶ | if ($token->{type} eq 'NAME') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 76 | my $name = $token->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 76 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | # Handle boolean/none literals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 76 | ▶ | if ($name =~ /^(true|True)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 2 | return { type => 'LITERAL', value => 1, subtype => 'BOOL' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | } elsif ($name =~ /^(false|False)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 2 | return { type => 'LITERAL', value => 0, subtype => 'BOOL' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } elsif ($name =~ /^(none|None)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | return { type => 'LITERAL', value => undef, subtype => 'NONE' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 72 | return { type => 'NAME', value => $name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | # Number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 23 | ▶ | if ($token->{type} eq 'NUMBER') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 13 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 13 | my $val = $token->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 13 | $val =~ s/_//g; # Remove underscores | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 13 | return { type => 'LITERAL', value => $val, subtype => 'NUMBER' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | # String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 10 | ▶ | if ($token->{type} eq 'STRING') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 6 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 6 | my $val = $token->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # Remove quotes and handle escapes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 6 | $val =~ s/^['"]|['"]$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 6 | $val =~ s/\\(['"])/$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 6 | $val =~ s/\\n/\n/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 6 | $val =~ s/\\t/\t/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 6 | $val =~ s/\\\\/\\/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 6 | return { type => 'LITERAL', value => $val, subtype => 'STRING' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # Parenthesized expression or tuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 4 | ▶ | if ($token->{type} eq 'LPAREN') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | ▶ | if ($self->_check('RPAREN')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | return { type => 'TUPLE', elements => [] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | my $expr = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | if ($self->_check('COMMA')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | # It's a tuple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | my @elements = ($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | while ($self->_check('COMMA')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | ▶ | last if $self->_check('RPAREN'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | push @elements, $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | return { type => 'TUPLE', elements => \@elements }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | $self->_expect('RPAREN'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | return $expr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # List | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 4 | ▶ | if ($token->{type} eq 'LBRACKET') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 2 | my @elements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 2 | ▶ | unless ($self->_check('RBRACKET')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 2 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_check("COMMA") and $self->_advance
MC/DC50%1/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table66%2/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 6 | push @elements, $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 2 | $self->_expect('RBRACKET'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 2 | return { type => 'LIST', elements => \@elements }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # Dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 2 | ▶ | if ($token->{type} eq 'LBRACE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 2 | $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 2 | my @pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 2 | ▶ | unless ($self->_check('RBRACE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 2 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_check("COMMA") and $self->_advance
MC/DC0%0/2
$self->_check("COMMA") and $self->_advance
$self->_check("COMMA")
$self->_advance
Truth table33%1/3
A and B
A= $self->_check("COMMA")B= $self->_advance
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 2 | my $key = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 2 | $self->_expect('COLON'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 2 | my $val = $self->_parse_expression(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 2 | push @pairs, { key => $key, value => $val }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } while ($self->_check('COMMA') && $self->_advance()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 2 | $self->_expect('RBRACE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 2 | return { type => 'DICT', pairs => \@pairs }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | die "Unexpected token: " . ($token->{type} // 'undef') . " at position " . ($token->{pos} // 'unknown'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$token->{"type"} // "undef"
$token->{"pos"} // "unknown"
MC/DC0%0/1
$token->{"type"} // "undef"
$token->{"type"}
MC/DC0%0/1
$token->{"pos"} // "unknown"
$token->{"pos"}
Truth table0%0/2
A
A= $token->{"type"}
Truth table0%0/2
A
A= $token->{"pos"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | # Helper methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 2187 | ▶ | sub _current { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_current: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 2187 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 2187 | return $self->{tokens}[$self->{pos}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | sub _peek { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_peek: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | return $self->{tokens}[$self->{pos} + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 482 | ▶ | sub _advance { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_advance: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 482 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 482 | my $token = $self->{tokens}[$self->{pos}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 482 | ▶ | $self->{pos}++ if $self->{pos} < @{$self->{tokens}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 482 | return $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 1347 | ▶ | sub _check { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 1347 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 1347 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 1347 | ▶ | return $token && $token->{type} eq $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$token && $token->{'type'} eq $type
MC/DC50%1/2
$token && $token->{'type'} eq $type
$token
$token->{'type'} eq $type
Truth table66%2/3
A && B
A= $tokenB= $token->{'type'} eq $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 246 | ▶ | sub _expect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expect: called CC=5 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 246 | my ($self, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 246 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 246 | ▶ | if (!$token || $token->{type} ne $type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $token or $token->{"type"} ne $type
MC/DC0%0/2
not $token or $token->{"type"} ne $type
not $token
$token->{"type"} ne $type
Truth table33%1/3
not(A) or B
A= not $tokenB= $token->{"type"} ne $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | die "Expected $type but got " . ($token->{type} // 'EOF') . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | " at position " . ($token->{pos} // 'unknown'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$token->{"type"} // "EOF"
$token->{"pos"} // "unknown"
MC/DC0%0/1
$token->{"type"} // "EOF"
$token->{"type"}
MC/DC0%0/1
$token->{"pos"} // "unknown"
$token->{"pos"}
Truth table0%0/2
A
A= $token->{"type"}
Truth table0%0/2
A
A= $token->{"pos"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 246 | return $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | sub _expect_keyword { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expect_keyword: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | my ($self, $keyword) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | if (!$token || $token->{type} ne 'NAME' || $token->{value} ne $keyword) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $token or $token->{"type"} ne "NAME" or $token->{"value"} ne $keyword
not $token or $token->{"type"} ne "NAME"
MC/DC0%0/3
not $token or $token->{"type"} ne "NAME" or $token->{"value"} ne $keyword
not $token
$token->{"type"} ne "NAME"
$token->{"value"} ne $keyword
Truth table0%0/4
not(A) or B or C
A= not $tokenB= $token->{"type"} ne "NAME"C= $token->{"value"} ne $keyword
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | die "Expected keyword '$keyword' but got " . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | ▶ | ($token->{value} // $token->{type} // 'EOF'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($token->{"value"} // $token->{"type"}) // "EOF"
$token->{"value"} // $token->{"type"}
MC/DC0%0/2
($token->{"value"} // $token->{"type"}) // "EOF"
$token->{"value"}
$token->{"type"}
Truth table0%0/3
A // B
A= $token->{"value"}B= $token->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | return $self->_advance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 193 | ▶ | sub _at_end { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_at_end: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 193 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 193 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 193 | ▶ | return !$token || $token->{type} eq 'EOF'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!$token || $token->{'type'} eq 'EOF'
MC/DC50%1/2
!$token || $token->{'type'} eq 'EOF'
!$token
$token->{'type'} eq 'EOF'
Truth table66%2/3
not(A) || B
A= !$tokenB= $token->{'type'} eq 'EOF'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 134 | ▶ | sub _is_stmt_keyword { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_stmt_keyword: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 134 | my ($self, $keyword) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 134 | my $token = $self->_current(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 134 | ▶ | return 0 unless $token && $token->{type} eq 'STMT_START'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$token and $token->{"type"} eq "STMT_START"
MC/DC50%1/2
$token and $token->{"type"} eq "STMT_START"
$token
$token->{"type"} eq "STMT_START"
Truth table66%2/3
A and B
A= $tokenB= $token->{"type"} eq "STMT_START"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 64 | my $next = $self->{tokens}[$self->{pos} + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 64 | ▶ | return $next && $next->{type} eq 'NAME' && $next->{value} eq $keyword; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$next && $next->{'type'} eq 'NAME' && $next->{'value'} eq $keyword
$next and $next->{"type"} eq "NAME"
MC/DC33%1/3
$next && $next->{'type'} eq 'NAME' && $next->{'value'} eq $keyword
$next
$next->{"type"} eq "NAME"
$next->{'value'} eq $keyword
Truth table50%2/4
A and B && C
A= $nextB= $next->{"type"} eq "NAME"C= $next->{'value'} eq $keyword
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||