| 1 | package Business::UDC::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Business::UDC::Grammar qw(can_follow_operator can_follow_primary can_precede_number | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 10 | is_operator_token is_primary_token is_valid_operator); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Business::UDC::Tokenizer qw(tokenize); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use Error::Pure qw(err); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use List::Util 1.33 qw(any); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 10 | Readonly::Array our @EXPORT_OK => qw(parse); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 10 | our $VERSION = 0.12; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 142 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 142 | my $input = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 142 | ▶ | if (! defined $input) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | err 'No input provided.'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 139 | ▶ | if ($input !~ /\S/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | err 'Empty input.'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 137 | my $tokens_ar = tokenize($input); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 113 | _check_parentheses($tokens_ar, length($input)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 99 | my $has_alpha_spec = _has_alpha_spec($tokens_ar); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 99 | my $normalized_tokens_ar = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 99 | foreach my $tok_hr (@{$tokens_ar}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 321 | my %parse_tok = %{$tok_hr}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 321 | _check_whitespace_token(\%parse_tok, $has_alpha_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 307 | _check_apos_aux_tokens(\%parse_tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 302 | _check_aux_time_tokens(\%parse_tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 299 | _check_number_token(\%parse_tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 296 | _check_aux_group_token(\%parse_tok, 0, $has_alpha_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 293 | _normalize_alpha_spec_token(\%parse_tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 293 | push @{$normalized_tokens_ar}, \%parse_tok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 71 | my $state_hr = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 'tokens' => $normalized_tokens_ar, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'pos' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 71 | my $ast = _parse_expression($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 53 | ▶ | if ($state_hr->{'pos'} < @{$state_hr->{'tokens'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | my $tok = $state_hr->{'tokens'}[$state_hr->{'pos'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | err "Unexpected token '$tok->{'value'}'.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | 'position' => $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 51 | 'tokens' => $tokens_ar, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'ast' => $ast, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 113 | ▶ | sub _check_parentheses { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_parentheses: called CC=34 SCAR=35.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 113 | my ($tokens_ar, $input_length) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 113 | my (@left, $previous, $has_operator_after_left, $operator_position, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | $has_alpha_after_left, $has_time_after_left, $time_position); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 113 | foreach my $tok (@{$tokens_ar}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 436 | ▶ | if ($tok->{'type'} eq 'LPAREN') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 12 | push @left, $tok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 12 | $previous = $tok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 12 | $has_operator_after_left = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | $operator_position = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 12 | $has_alpha_after_left = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | $has_time_after_left = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | $time_position = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 424 | ▶ | if ($tok->{'type'} eq 'RPAREN') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | if (! @left) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | return if $tokens_ar->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | && $tokens_ar->[0]{'type'} eq 'OP'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tokens_ar->[0] and $tokens_ar->[0]{"type"} eq "OP"
MC/DC50%1/2
$tokens_ar->[0] and $tokens_ar->[0]{"type"} eq "OP"
$tokens_ar->[0]
$tokens_ar->[0]{"type"} eq "OP"
Truth table66%2/3
A and B
A= $tokens_ar->[0]B= $tokens_ar->[0]{"type"} eq "OP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | my $missing_opening = ! $previous || $previous->{'type'} ne 'AUX_GROUP'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!$previous || $previous->{'type'} ne 'AUX_GROUP'
MC/DC50%1/2
!$previous || $previous->{'type'} ne 'AUX_GROUP'
!$previous
$previous->{'type'} ne 'AUX_GROUP'
Truth table66%2/3
not(A) || B
A= !$previousB= $previous->{'type'} ne 'AUX_GROUP'
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | my $message = $missing_opening | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ? "Missing opening parenthesis '('." | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | : "Extra closing parenthesis ')'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | err $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | 'position' => $missing_opening ? $tokens_ar->[0]{'pos'} : $tok->{'pos'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 'character' => $missing_opening ? '(' : ')', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | pop @left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 420 | ▶ | if (@left && $tok->{'type'} eq 'OP') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@left and $tok->{"type"} eq "OP"
MC/DC100%2/2
@left and $tok->{"type"} eq "OP"
@left
$tok->{"type"} eq "OP"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "OP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $has_operator_after_left = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | if (! defined $operator_position) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $operator_position = $tok->{'pos'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 420 | ▶ | if (@left && $tok->{'type'} eq 'ALPHA_SPEC' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@left and $tok->{"type"} eq "ALPHA_SPEC" and $tok->{"value"} =~ m[([+:/])]
@left and $tok->{"type"} eq "ALPHA_SPEC"
MC/DC100%3/3
@left and $tok->{"type"} eq "ALPHA_SPEC" and $tok->{"value"} =~ m[([+:/])]
@left
$tok->{"type"} eq "ALPHA_SPEC"
$tok->{"value"} =~ m[([+:/])]
Truth table100%4/4
A and B and C
A= @leftB= $tok->{"type"} eq "ALPHA_SPEC"C= $tok->{"value"} =~ m[([+:/])]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | && $tok->{'value'} =~ /([+:\/])/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | $has_operator_after_left = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | $operator_position = $tok->{'pos'} + index($tok->{'value'}, $1) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | if ! defined $operator_position; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 420 | ▶ | $has_alpha_after_left = 1 if @left && $tok->{'type'} eq 'ALPHA_SPEC'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@left and $tok->{"type"} eq "ALPHA_SPEC"
MC/DC100%2/2
@left and $tok->{"type"} eq "ALPHA_SPEC"
@left
$tok->{"type"} eq "ALPHA_SPEC"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "ALPHA_SPEC"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $has_time_after_left = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 420 | ▶ | if @left && $tok->{'type'} eq 'AUX_TIME'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@left and $tok->{"type"} eq "AUX_TIME"
MC/DC100%2/2
@left and $tok->{"type"} eq "AUX_TIME"
@left
$tok->{"type"} eq "AUX_TIME"
Truth table100%3/3
A and B
A= @leftB= $tok->{"type"} eq "AUX_TIME"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 420 | ▶ | $time_position = $tok->{'pos'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$has_time_after_left and not defined $time_position
MC/DC100%2/2
$has_time_after_left and not defined $time_position
$has_time_after_left
not defined $time_position
Truth table100%3/3
A and not(B)
A= $has_time_after_leftB= not defined $time_position
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | if $has_time_after_left && ! defined $time_position; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 420 | $previous = $tok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 109 | ▶ | if (@left) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 11 | my $left = $left[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 11 | ▶ | my $missing_closing = $has_operator_after_left || $has_time_after_left; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$has_operator_after_left || $has_time_after_left
MC/DC100%2/2
$has_operator_after_left || $has_time_after_left
$has_operator_after_left
$has_time_after_left
Truth table100%3/3
A || B
A= $has_operator_after_leftB= $has_time_after_left
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | my $extra_opening = @left > 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | || ! $missing_closing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 11 | ▶ | && $previous && $previous->{'type'} eq 'AUX_GROUP'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
@left > 1 || !$missing_closing && $previous && $previous->{'type'} eq 'AUX_GROUP'
not $missing_closing and $previous and $previous->{"type"} eq "AUX_GROUP"
not $missing_closing and $previous
MC/DC75%3/4
@left > 1 || !$missing_closing && $previous && $previous->{'type'} eq 'AUX_GROUP'
@left > 1
not $missing_closing
$previous
$previous->{"type"} eq "AUX_GROUP"
Truth table80%4/5
A || not(B) and C and D
A= @left > 1B= not $missing_closingC= $previousD= $previous->{"type"} eq "AUX_GROUP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 11 | ▶ | my $message = $extra_opening | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ? "Extra opening parenthesis '('." | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | : "Missing closing parenthesis ')'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | err $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 'position' => $extra_opening | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 11 | ▶ | ? $left->{'pos'} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | : defined $time_position ? $time_position | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | : defined $operator_position ? $operator_position | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | : $input_length, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 'character' => $extra_opening ? '(' : ')', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 98 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 323 | ▶ | sub _check_whitespace_token { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_whitespace_token: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 323 | my ($tok, $has_alpha_spec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 323 | ▶ | if ($tok->{'type'} ne 'WHITESPACE') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 307 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 16 | ▶ | my $message = $has_alpha_spec | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ? 'Whitespace is not allowed in UDC string with alphabetical specification.' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | : 'Whitespace is not allowed in UDC string.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | err $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 'position' => $tok->{'pos'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | 'character' => substr($tok->{'value'}, 0, 1), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 174 | ▶ | sub _has_alpha_spec { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_alpha_spec: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 174 | my $tokens_ar = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 174 | foreach my $token (@{$tokens_ar}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 452 | ▶ | return 1 if $token->{'type'} eq 'ALPHA_SPEC'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 426 | ▶ | if ($token->{'tokens'} && _has_alpha_spec($token->{'tokens'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$token->{"tokens"} and _has_alpha_spec($token->{"tokens"})
MC/DC0%0/2
$token->{"tokens"} and _has_alpha_spec($token->{"tokens"})
$token->{"tokens"}
_has_alpha_spec($token->{"tokens"})
Truth table66%2/3
A and B
A= $token->{"tokens"}B= _has_alpha_spec($token->{"tokens"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 144 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 299 | ▶ | sub _check_aux_group_token { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_aux_group_token: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 299 | my ($tok, $position_offset, $has_alpha_spec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 299 | ▶ | $position_offset //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$position_offset //= 0
MC/DC0%0/1
$position_offset //= 0
$position_offset
Truth table50%1/2
A
A= $position_offset
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 299 | ▶ | if ($tok->{'type'} ne 'AUX_GROUP') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 257 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 42 | my $inner_tokens = $tok->{'tokens'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 42 | my $inner_position_offset = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 42 | ▶ | $has_alpha_spec ||= _has_alpha_spec($inner_tokens); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$has_alpha_spec ||= _has_alpha_spec($inner_tokens)
MC/DC50%1/2
$has_alpha_spec ||= _has_alpha_spec($inner_tokens)
$has_alpha_spec
_has_alpha_spec($inner_tokens)
Truth table66%2/3
A ||= B
A= $has_alpha_specB= _has_alpha_spec($inner_tokens)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 42 | foreach my $inner_tok (@{$inner_tokens}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 61 | ▶ | if ($inner_tok->{'type'} eq 'WHITESPACE') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | _check_whitespace_token($inner_tok, $has_alpha_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 59 | ▶ | if ($inner_tok->{'type'} eq 'AUX_GROUP') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 3 | _check_aux_group_token($inner_tok, $inner_position_offset, $has_alpha_spec); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 56 | _check_aux_time_tokens($inner_tok, $inner_position_offset); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 56 | _check_number_token($inner_tok, $inner_position_offset); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 39 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 307 | ▶ | sub _check_apos_aux_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_apos_aux_tokens: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 307 | my $tok = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 307 | ▶ | if ($tok->{'type'} ne 'APOS_AUX') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 286 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 21 | ▶ | if (substr($tok->{'value'}, 0, 1) eq "'") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 16 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | my ($character) = $tok->{'value'} =~ /^('|.)/us; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | err 'Bad apostrophe character.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 'character' => $character, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 5 | 'position' => $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 358 | ▶ | sub _check_aux_time_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_aux_time_tokens: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 358 | my ($tok, $position_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 358 | ▶ | $position_offset //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$position_offset //= 0
MC/DC100%1/1
$position_offset //= 0
$position_offset
Truth table100%2/2
A
A= $position_offset
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 358 | ▶ | if ($tok->{'type'} ne 'AUX_TIME') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 348 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 10 | my ($left, $left_length) = _time_quote_at_start($tok->{'value'}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 10 | ▶ | if ($left ne '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | err 'Bad quotation mark character.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 'character' => $left, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | 'position' => $position_offset + $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 8 | my ($right, $right_length) = _time_quote_at_end($tok->{'value'}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 8 | ▶ | if ($right ne '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | err 'Bad quotation mark character.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 'character' => $right, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 1 | 'position' => $position_offset + $tok->{'pos'} + length($tok->{'value'}) - $right_length, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 355 | ▶ | sub _check_number_token { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_number_token: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 355 | my ($tok, $position_offset) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 355 | ▶ | $position_offset //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$position_offset //= 0
MC/DC100%1/1
$position_offset //= 0
$position_offset
Truth table100%2/2
A
A= $position_offset
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 355 | ▶ | if ($tok->{'type'} ne 'NUMBER' && $tok->{'type'} ne 'FORM') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tok->{"type"} ne "NUMBER" and $tok->{"type"} ne "FORM"
MC/DC100%2/2
$tok->{"type"} ne "NUMBER" and $tok->{"type"} ne "FORM"
$tok->{"type"} ne "NUMBER"
$tok->{"type"} ne "FORM"
Truth table100%3/3
A and B
A= $tok->{"type"} ne "NUMBER"B= $tok->{"type"} ne "FORM"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 162 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 193 | ▶ | if ($tok->{'value'} !~ /,/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 189 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | err 'Bad dot character in number.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | 'position' => $position_offset + $tok->{'pos'} + index($tok->{'value'}, ','), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 'character' => ',', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 10 | ▶ | sub _time_quote_at_start { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_time_quote_at_start: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 10 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 10 | ▶ | if (substr($value, 0, 2) eq "''") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | return ("''", 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | return (substr($value, 0, 1), 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | ▶ | sub _time_quote_at_end { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_time_quote_at_end: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | ▶ | if (substr($value, -2) eq "''") { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | return ("''", 2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 7 | return (substr($value, -1), 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 207 | ▶ | sub _consume { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_consume: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 207 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 207 | return $state_hr->{'tokens'}[$state_hr->{'pos'}++]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | sub _expect { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expect: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | my ($state_hr, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | my $tok = _peek($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | if (! $tok) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | err "Expected '$type' but reached end of input."; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | ▶ | if ($tok->{'type'} ne $type) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | err "Expected $type but got $tok->{'type'} ('$tok->{'value'}').", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | 'position' => $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 4 | return _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 75 | ▶ | sub _parse_expression { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_expression: called CC=18 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 75 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 75 | my $left = _parse_term($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 65 | ▶ | while (my $tok = _peek($state_hr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 44 | ▶ | if (! is_operator_token($tok->{'type'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 9 | ▶ | if ($tok->{'type'} eq 'NUMBER') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 3 | ▶ | if (_term_ends_with_auxiliary($left)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | err 'Missing operator.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 3 | 'position' => $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 35 | ▶ | if (! is_valid_operator($tok->{'value'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 35 | my $op = _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 35 | ▶ | my $next = _peek($state_hr) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | or err "Expected term after operator '$op->{'value'}'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | err "Token '$next->{'value'}' is not allowed after operator '$op->{'value'}'." | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | if $next->{'type'} ne 'LBRACK' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 34 | ▶ | && ! can_follow_operator($op->{'value'}, $next->{'type'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$next->{"type"} ne "LBRACK" and not can_follow_operator($op->{"value"}, $next->{"type"})
MC/DC100%2/2
$next->{"type"} ne "LBRACK" and not can_follow_operator($op->{"value"}, $next->{"type"})
$next->{"type"} ne "LBRACK"
not can_follow_operator($op->{"value"}, $next->{"type"})
Truth table100%3/3
A and not(B)
A= $next->{"type"} ne "LBRACK"B= not can_follow_operator($op->{"value"}, $next->{"type"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 32 | my $right = _parse_term_after_operator($state_hr, $op->{'value'}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 32 | ▶ | if ($op->{'value'} eq '/' && $right->{'type'} eq 'APOS_AUX') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op->{"value"} eq "/" and $right->{"type"} eq "APOS_AUX"
MC/DC100%2/2
$op->{"value"} eq "/" and $right->{"type"} eq "APOS_AUX"
$op->{"value"} eq "/"
$right->{"type"} eq "APOS_AUX"
Truth table100%3/3
A and B
A= $op->{"value"} eq "/"B= $right->{"type"} eq "APOS_AUX"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 5 | my ($base, $from) = _split_trailing_apos_aux($left); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 5 | ▶ | if (! $from) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | err "Apostrophe auxiliary range shorthand '$op->{'value'}$right->{'value'}' ". | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | "requires apostrophe auxiliary on the left side.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | 'position' => $op->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | my $range = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | type => 'APOS_RANGE', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | base => $base, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | from => $from->{'value'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | to => $right->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | ▶ | if (my $modifier = _peek($state_hr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | ▶ | if ($modifier->{'type'} eq 'FORM') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | $range->{'modifiers'} = [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | type => $modifier->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | value => $modifier->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | }]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 3 | $left = $range; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | $left = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | type => 'BINARY_OP', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 27 | operator => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | left => $left, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | right => $right, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 27 | ▶ | if ($op->{'value'} eq '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 9 | my @modifiers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | my $current_type = 'NUMBER'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 9 | my $current_value = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 9 | ▶ | while (my $next_tok = _peek($state_hr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | ▶ | if (! can_follow_primary( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | $next_tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | $next_tok->{'value'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | $current_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | $current_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | push @modifiers, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | type => $next_tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | value => $next_tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | $current_type = $next_tok->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | $current_value = $next_tok->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 9 | ▶ | if (@modifiers) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | $left = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | type => 'TERM', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | primary => $left, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | modifiers => \@modifiers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 57 | return $left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | sub _term_ends_with_auxiliary { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_term_ends_with_auxiliary: called CC=9 SCAR=25.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | ▶ | while ($node && $node->{'type'} eq 'BINARY_OP') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node and $node->{"type"} eq "BINARY_OP"
MC/DC50%1/2
$node and $node->{"type"} eq "BINARY_OP"
$node
$node->{"type"} eq "BINARY_OP"
Truth table66%2/3
A and B
A= $nodeB= $node->{"type"} eq "BINARY_OP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | $node = $node->{'right'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | ▶ | return if ! $node || $node->{'type'} ne 'TERM'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $node or $node->{"type"} ne "TERM"
MC/DC0%0/2
not $node or $node->{"type"} ne "TERM"
not $node
$node->{"type"} ne "TERM"
Truth table33%1/3
not(A) or B
A= not $nodeB= $node->{"type"} ne "TERM"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | return if ! $node->{'modifiers'} || ! @{$node->{'modifiers'}} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
MC/DC0%0/2
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME"
$node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
Truth table66%2/3
A and B
A= $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME"B= $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | || $node->{'modifiers'}[-1]{'type'} ne 'AUX_TIME' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | && $node->{'modifiers'}[-1]{'type'} ne 'AUX_GROUP'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not $node->{"modifiers"} && @{$node->{"modifiers"};} or $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
$node->{'modifiers'} && @{$node->{'modifiers'};}
MC/DC33%1/3
not $node->{"modifiers"} && @{$node->{"modifiers"};} or $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
$node->{'modifiers'}
@{$node->{'modifiers'};}
$node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
Truth table50%2/4
not(A && B) or C
A= $node->{'modifiers'}B= @{$node->{'modifiers'};}C= $node->{"modifiers"}[-1]{"type"} ne "AUX_TIME" and $node->{"modifiers"}[-1]{"type"} ne "AUX_GROUP"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 99 | ▶ | sub _parse_primary { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_primary: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 99 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 99 | ▶ | my $tok = _peek($state_hr) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | or err 'Expected term but reached end of input.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 99 | ▶ | if ($tok->{'type'} eq 'LBRACK') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | return _parse_subgroup($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 95 | ▶ | if (is_primary_token($tok->{'type'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 85 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 'type' => $tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 85 | 'value' => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 10 | ▶ | if ($tok->{'type'} eq 'ALPHA_SPEC') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | err "Alphabetical specification cannot appear standalone.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 'position' => $tok->{'pos'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 3 | 'value' => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 7 | ▶ | if ($tok->{'type'} eq 'APOS_AUX') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | err "Apostrophe auxiliary '$tok->{'value'}' must follow a valid UDC notation."; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | err "Expected NUMBER, subgroup, or standalone auxiliary but got $tok->{'type'} ('$tok->{'value'}').", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 6 | 'position' => $tok->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 4 | ▶ | sub _parse_subgroup { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_subgroup: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 4 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 4 | my $lbrack = _expect($state_hr, 'LBRACK'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 4 | my $expr = _parse_expression($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 4 | my $end = _peek($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 4 | ▶ | if (! $end) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | err "Unclosed subgroup '['.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | 'position' => $lbrack->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 4 | ▶ | if ($end->{'type'} ne 'RBRACK') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | err "Expected closing ']' for subgroup but got '$end->{'value'}'.", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | 'position' => $end->{'pos'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 4 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 4 | 'type' => 'SUBGROUP', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 'expression' => $expr, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 98 | ▶ | sub _parse_term { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_term: called CC=15 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 98 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 98 | my $primary = _parse_primary($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 88 | ▶ | if ($primary->{'type'} ne 'NUMBER') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 13 | my $next = _peek($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 13 | ▶ | if ($next && $next->{'type'} eq 'NUMBER') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$next and $next->{"type"} eq "NUMBER"
MC/DC100%2/2
$next and $next->{"type"} eq "NUMBER"
$next
$next->{"type"} eq "NUMBER"
Truth table100%3/3
A and B
A= $nextB= $next->{"type"} eq "NUMBER"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | ▶ | if (! can_precede_number($primary->{'type'}, $primary->{'value'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $what = defined $primary->{'value'} ? $primary->{'value'} : $primary->{'type'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | err "NUMBER cannot follow '$what'."; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 4 | my $number = _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | my @modifiers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 4 | my $current_type = 'NUMBER'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 4 | my $current_value = $number->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 4 | my $has_main_number = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 4 | ▶ | while (my $tok = _peek($state_hr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | ▶ | if (any { $tok->{'type'} eq $_ } qw(APOS_AUX AUX_DOT)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | if (! $has_main_number) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } elsif (! can_follow_primary( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | $tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | $tok->{'value'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | $current_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | $current_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | push @modifiers, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 'type' => $tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | 'value' => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 1 | $current_type = $tok->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 1 | $current_value = $tok->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 'type' => 'TERM', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 'prefixes' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 'type' => $primary->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 'value' => $primary->{'value'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 'primary' => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 'type' => 'NUMBER', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 4 | 'value' => $number->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 'modifiers' => \@modifiers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 84 | my @modifiers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 84 | my $current_type = $primary->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 84 | my $current_value = $primary->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 84 | ▶ | my $allow_dot_aux = any { $primary->{'type'} eq $_ } qw(NUMBER SUBGROUP); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 84 | ▶ | while (my $tok = _peek($state_hr)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 106 | ▶ | if ($tok->{'type'} eq 'LBRACK') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | my $subgroup = _parse_primary($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 1 | push @modifiers, $subgroup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 1 | $current_type = $subgroup->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | $current_value = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 105 | ▶ | if ($tok->{'type'} eq 'AUX_DOT') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 4 | ▶ | if (! $allow_dot_aux) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 104 | ▶ | if (! can_follow_primary( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | $tok->{'value'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | $current_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | $current_value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 42 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | push @modifiers, { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 'type' => $tok->{'type'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 62 | 'value' => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 62 | $current_type = $tok->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 62 | $current_value = $tok->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 62 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 84 | 'type' => 'TERM', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 'primary' => $primary, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 'modifiers' => \@modifiers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 32 | ▶ | sub _parse_term_after_operator { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_term_after_operator: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 32 | my ($state_hr, $op) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 32 | ▶ | my $tok = _peek($state_hr) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | or err "Expected term after operator '$op'."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 32 | ▶ | if ($op eq '/' && $tok->{'type'} eq 'AUX_DOT') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "AUX_DOT"
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "AUX_DOT"
$op eq "/"
$tok->{"type"} eq "AUX_DOT"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "AUX_DOT"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 3 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | type => 'PARTIAL_NUMBER', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3 | value => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 29 | ▶ | if ($op eq '/' && $tok->{'type'} eq 'FORM') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "FORM"
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "FORM"
$op eq "/"
$tok->{"type"} eq "FORM"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "FORM"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 1 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | type => 'PARTIAL_FORM', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | value => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 28 | ▶ | if ($op eq '/' && $tok->{'type'} eq 'APOS_AUX') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op eq "/" and $tok->{"type"} eq "APOS_AUX"
MC/DC100%2/2
$op eq "/" and $tok->{"type"} eq "APOS_AUX"
$op eq "/"
$tok->{"type"} eq "APOS_AUX"
Truth table100%3/3
A and B
A= $op eq "/"B= $tok->{"type"} eq "APOS_AUX"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | _consume($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | type => 'APOS_AUX', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 5 | value => $tok->{'value'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 23 | return _parse_term($state_hr); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 448 | ▶ | sub _peek { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_peek: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 448 | my $state_hr = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 448 | return $state_hr->{'tokens'}[$state_hr->{'pos'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 293 | ▶ | sub _normalize_alpha_spec_token { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_alpha_spec_token: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 293 | my $tok = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 293 | ▶ | if ($tok->{'type'} ne 'ALPHA_SPEC') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 273 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 20 | my ($value, $pos) = _trim_alpha_spec_value($tok); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 20 | $tok->{'pos'} = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 20 | $tok->{'value'} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 20 | ▶ | sub _trim_alpha_spec_value { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim_alpha_spec_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 20 | my $tok = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 20 | my $value = $tok->{'value'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 20 | my $pos = $tok->{'pos'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 20 | ▶ | if ($value =~ s/^(\s+)//) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 9 | $pos += length($1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 20 | $value =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 20 | return ($value, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 5 | ▶ | sub _split_trailing_apos_aux { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_trailing_apos_aux: called CC=8 SCAR=22.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | my $node = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | ▶ | if (! defined $node) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 5 | ▶ | if ($node->{'type'} ne 'TERM') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 4 | ▶ | if (! $node->{'modifiers'} || ! @{$node->{'modifiers'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node->{"modifiers"} and @{$node->{"modifiers"};}
MC/DC50%1/2
$node->{"modifiers"} and @{$node->{"modifiers"};}
$node->{"modifiers"}
@{$node->{"modifiers"};}
Truth table66%2/3
A and B
A= $node->{"modifiers"}B= @{$node->{"modifiers"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 3 | my @modifiers = @{$node->{'modifiers'}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 3 | my $last = $modifiers[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 3 | ▶ | if (! defined $last || $last->{'type'} ne 'APOS_AUX') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $last or $last->{"type"} ne "APOS_AUX"
MC/DC0%0/2
not defined $last or $last->{"type"} ne "APOS_AUX"
not defined $last
$last->{"type"} ne "APOS_AUX"
Truth table33%1/3
not(A) or B
A= not defined $lastB= $last->{"type"} ne "APOS_AUX"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 3 | pop @modifiers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | my $base = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | type => 'TERM', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 3 | primary => $node->{'primary'}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | modifiers => \@modifiers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 3 | ▶ | if (exists $node->{'prefixes'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $base->{'prefixes'} = [ @{$node->{'prefixes'}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 3 | return ($base, $last); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||