| 1 | # Copyright 2022 Jeffrey Kegler | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # This file is part of Marpa::R2. Marpa::R2 is free software: you can | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # redistribute it and/or modify it under the terms of the GNU Lesser | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # General Public License as published by the Free Software Foundation, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # either version 3 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Marpa::R2 is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # You should have received a copy of the GNU Lesser | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # General Public License along with Marpa::R2. If not, see | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # http://www.gnu.org/licenses/. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | package Marpa::R2::Value; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 150 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 150 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 150 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 150 | ▶ | use vars qw($VERSION $STRING_VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 150 | $VERSION = '14.000000'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 150 | $STRING_VERSION = $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 150 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | package Marpa::R2::Internal::Value; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 150 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 150 | ▶ | use constant SKIP => -1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub Marpa::R2::show_rank_ref { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_rank_ref: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my ($rank_ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return 'undef' if not defined $rank_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return 'SKIP' if $rank_ref == Marpa::R2::Internal::Value::SKIP; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return ${$rank_ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } ## end sub Marpa::R2::show_rank_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | package Marpa::R2::Internal::Value; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # Given the grammar and an action name, resolve it to a closure, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # or return undef | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 31554 | ▶ | sub Marpa::R2::Internal::Recognizer::resolve_action { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_action: called CC=29 SCAR=40.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 31554 | my ( $recce, $closure_name, $p_error ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 31554 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 31554 | my $closures = $recce->[Marpa::R2::Internal::Recognizer::CLOSURES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 31554 | my $trace_actions = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_ACTIONS]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # A reserved closure name; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 31554 | ▶ | return [ q{}, undef, '::!default' ] if not defined $closure_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 30535 | ▶ | if ( $closure_name eq q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | ${$p_error} = q{The action string cannot be the empty string} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if defined $p_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 30535 | ▶ | return [ q{}, \undef, $closure_name ] if $closure_name eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 30519 | ▶ | if ( substr( $closure_name, 0, 2 ) eq q{::} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
substr($closure_name, 0, 2) eq "::" or substr($closure_name, 0, 1) eq "["
MC/DC100%2/2
substr($closure_name, 0, 2) eq "::" or substr($closure_name, 0, 1) eq "["
substr($closure_name, 0, 2) eq "::"
substr($closure_name, 0, 1) eq "["
Truth table100%3/3
A or B
A= substr($closure_name, 0, 2) eq "::"B= substr($closure_name, 0, 1) eq "["
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | or substr( $closure_name, 0, 1 ) eq '[' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 25951 | return [ q{}, undef, $closure_name ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4568 | ▶ | if ( my $closure = $closures->{$closure_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2994 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | qq{Resolved "$closure_name" to explicit closure\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2994 | return [ $closure_name, $closure, '::array' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } ## end if ( my $closure = $closures->{$closure_name} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1574 | my $fully_qualified_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1574 | ▶ | if ( $closure_name =~ /([:][:])|[']/xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 810 | $fully_qualified_name = $closure_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1574 | ▶ | if ( not $fully_qualified_name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 764 | my $resolve_package = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 764 | ▶ | if ( not defined $resolve_package ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | say STDERR | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | say STDERR | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ${$p_error} = Marpa::R2::Internal::X->new( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { message => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | qq{Could not fully qualify "$closure_name": no resolve package}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | name => 'NO RESOLVE PACKAGE' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } ## end if ( not defined $resolve_package ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 764 | $fully_qualified_name = $resolve_package . q{::} . $closure_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } ## end if ( not $fully_qualified_name ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1574 | my $closure; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | my $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | TYPE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 150 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1574 | $closure = *{$fully_qualified_name}{'CODE'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 150 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1574 | ▶ | if ( defined $closure ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1410 | $type = 'CODE'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1410 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 150 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 164 | $closure = *{$fully_qualified_name}{'SCALAR'}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 150 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # Currently $closure is always defined, but this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # behavior is said to be subject to change in perlref | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 164 | ▶ | if ( defined $closure and defined ${$closure} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $closure and defined ${$closure;}
MC/DC50%1/2
defined $closure and defined ${$closure;}
defined $closure
defined ${$closure;}
Truth table66%2/3
A and B
A= defined $closureB= defined ${$closure;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 35 | $type = 'SCALAR'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 35 | last TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Re other symbol tables entries: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # We ignore ARRAY and HASH because they anything | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # we resolve to is a potential array entry, something | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # that not possible for arrays and hashes except | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # indirectly, via references. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # FORMAT is deprecated. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # IO and GLOB seem too abstruse at the moment. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 129 | $closure = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } ## end TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1574 | ▶ | if ( defined $closure ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1445 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | qq{Successful resolution of action "$closure_name" as $type }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 'to ', $fully_qualified_name, "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } ## end if ($trace_actions) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1445 | return [ $fully_qualified_name, $closure, '::array' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } ## end if ( defined $closure ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 129 | ▶ | if ( $trace_actions or defined $p_error ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trace_actions or defined $p_error
MC/DC0%0/2
$trace_actions or defined $p_error
$trace_actions
defined $p_error
Truth table33%1/3
A or B
A= $trace_actionsB= defined $p_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 129 | for my $slot (qw(ARRAY HASH IO FORMAT)) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 150 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 516 | ▶ | if ( defined *{$fully_qualified_name}{$slot} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $error = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | qq{Failed resolution of action "$closure_name" to $fully_qualified_name\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | . qq{ $fully_qualified_name is present as a $slot, but a $slot is not an acceptable resolution\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} $error | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | ${$p_error} = $error if defined $p_error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } ## end if ( defined *{$fully_qualified_name}{$slot} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } ## end for my $slot (qw(ARRAY HASH IO FORMAT)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } ## end if ( $trace_actions or defined $p_error ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 129 | my $error = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | qq{Failed resolution of action "$closure_name" to $fully_qualified_name\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 129 | ▶ | ${$p_error} = $error if defined $p_error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 129 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} $error | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 129 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } ## end sub Marpa::R2::Internal::Recognizer::resolve_action | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # Find the semantics for a lexeme. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 43429 | ▶ | sub Marpa::R2::Internal::Recognizer::lexeme_semantics_find { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexeme_semantics_find: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 43429 | my ( $recce, $lexeme_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 43429 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 43429 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 43429 | my $symbol = $symbols->[$lexeme_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 43429 | my $semantics = $symbol->[Marpa::R2::Internal::Symbol::LEXEME_SEMANTICS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 43429 | ▶ | return '::!default' if not defined $semantics; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4139 | return $semantics; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } ## end sub Marpa::R2::Internal::Recognizer::lexeme_semantics_find | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Find the blessing for a rule. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 32794 | ▶ | sub Marpa::R2::Internal::Recognizer::rule_blessing_find { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rule_blessing_find: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 32794 | my ( $recce, $rule_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 32794 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 32794 | my $rules = $grammar->[Marpa::R2::Internal::Grammar::RULES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 32794 | my $rule = $rules->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 32794 | my $blessing = $rule->[Marpa::R2::Internal::Rule::BLESSING]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 32794 | ▶ | $blessing = '::undef' if not defined $blessing; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 32794 | ▶ | return $blessing if $blessing eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 23583 | my $bless_package = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | $grammar->[Marpa::R2::Internal::Grammar::BLESS_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 23583 | ▶ | if ( not defined $bless_package ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | qq{A blessed rule is in a grammar with no bless_package\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | . qq{ The rule was blessed as "$blessing"\n} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 23583 | return join q{}, $bless_package, q{::}, $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } ## end sub Marpa::R2::Internal::Recognizer::rule_blessing_find | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # Find the blessing for a lexeme. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 43429 | ▶ | sub Marpa::R2::Internal::Recognizer::lexeme_blessing_find { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lexeme_blessing_find: called CC=6 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 43429 | my ( $recce, $lexeme_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 43429 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 43429 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 43429 | my $symbol = $symbols->[$lexeme_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 43429 | my $blessing = $symbol->[Marpa::R2::Internal::Symbol::BLESSING]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 43429 | ▶ | return '::undef' if not defined $blessing; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 3890 | ▶ | return '::undef' if $blessing eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3890 | ▶ | if ( $blessing =~ m/\A [:][:] /xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $lexeme_name = $tracer->symbol_name($lexeme_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $recce->[Marpa::R2::Internal::Recognizer::ERROR_MESSAGE] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | qq{Symbol "$lexeme_name" has unknown blessing: "$blessing"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } ## end if ( $blessing =~ m/\A [:][:] /xms ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 3890 | ▶ | if ( $blessing =~ m/ [:][:] /xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3890 | my $bless_package = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $grammar->[Marpa::R2::Internal::Grammar::BLESS_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3890 | ▶ | if ( not defined $bless_package ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $lexeme_name = $tracer->symbol_name($lexeme_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $recce->[Marpa::R2::Internal::Recognizer::ERROR_MESSAGE] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | qq{Symbol "$lexeme_name" needs a blessing package, but grammar has none\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | . qq{ The blessing for "$lexeme_name" was "$blessing"\n}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } ## end if ( not defined $bless_package ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 3890 | return $bless_package . q{::} . $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } ## end sub Marpa::R2::Internal::Recognizer::lexeme_blessing_find | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # For diagnostics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub Marpa::R2::Internal::Recognizer::brief_rule_list { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
brief_rule_list: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my ( $recce, $rule_ids ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my @brief_rules = map { $grammar->brief_rule($_) } @{$rule_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | return join q{}, map { q{ } . $_ . "\n" } @brief_rules; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } ## end sub Marpa::R2::Internal::Recognizer::brief_rule_list | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 150 | our $CONTEXT_EXCEPTION_CLASS = __PACKAGE__ . '::Context_Exception'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | ▶ | sub Marpa::R2::Context::bail { ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bail: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | ▶ | if ( scalar @_ == 1 and ref $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @_ == 1 and ref $_[0]
MC/DC50%1/2
scalar @_ == 1 and ref $_[0]
scalar @_ == 1
ref $_[0]
Truth table66%2/3
A and B
A= scalar @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | die bless { exception_object => $_[0] }, $CONTEXT_EXCEPTION_CLASS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my $error_string = join q{}, @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | my ( $package, $filename, $line ) = caller; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | chomp $error_string; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | die bless { message => qq{User bailed at line $line in file "$filename"\n} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | . $error_string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | . "\n" }, $CONTEXT_EXCEPTION_CLASS; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } ## end sub Marpa::R2::Context::bail | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | sub Marpa::R2::Context::location { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
location: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 2 | my $valuator = $Marpa::R2::Internal::Context::VALUATOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 'Marpa::R2::Context::location called outside of a valuation context') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | if not defined $valuator; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | return $valuator->location(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } ## end sub Marpa::R2::Context::location | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 10 | ▶ | sub code_problems { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code_problems: called CC=22 SCAR=31.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 10 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 10 | my $grammar; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | my $fatal_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 10 | my $warnings = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 10 | my $where = '?where?'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 10 | my $long_where; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 10 | my @msg = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 10 | my $eval_value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 10 | my $eval_given = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | push @msg, q{=} x 60, "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 10 | ARG: for my $arg ( keys %{$args} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 60 | my $value = $args->{$arg}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 60 | ▶ | if ( $arg eq 'fatal_error' ) { $fatal_error = $value; next ARG } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 50 | ▶ | if ( $arg eq 'grammar' ) { $grammar = $value; next ARG } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 40 | ▶ | if ( $arg eq 'where' ) { $where = $value; next ARG } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 30 | ▶ | if ( $arg eq 'long_where' ) { $long_where = $value; next ARG } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 20 | ▶ | if ( $arg eq 'warnings' ) { $warnings = $value; next ARG } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 10 | ▶ | if ( $arg eq 'eval_ok' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 10 | $eval_value = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 10 | $eval_given = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 10 | next ARG; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | push @msg, "Unknown argument to code_problems: $arg"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } ## end ARG: for my $arg ( keys %{$args} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | GIVEN_FATAL_ERROR_REF_TYPE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 10 | my $fatal_error_ref_type = ref $fatal_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 10 | ▶ | last GIVEN_FATAL_ERROR_REF_TYPE if not $fatal_error_ref_type; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 4 | ▶ | if ( $fatal_error_ref_type eq $CONTEXT_EXCEPTION_CLASS ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | my $exception_object = $fatal_error->{exception_object}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 4 | ▶ | die $exception_object if defined $exception_object; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | my $exception_message = $fatal_error->{message}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | die $exception_message if defined $exception_message; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | die "Internal error: bad $CONTEXT_EXCEPTION_CLASS object"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } ## end if ( $fatal_error_ref_type eq $CONTEXT_EXCEPTION_CLASS) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $fatal_error = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | "Exception thrown as object inside Marpa closure\n" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | . ( q{ } x 4 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | . "This is not allowed\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | . ( q{ } x 4 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | . qq{Exception as string is "$fatal_error"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } ## end GIVEN_FATAL_ERROR_REF_TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | my @problem_line = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 6 | my $max_problem_line = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 6 | for my $warning_data ( @{$warnings} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | my ( $warning, $package, $filename, $problem_line ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | @{$warning_data}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | $problem_line[$problem_line] = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 4 | $max_problem_line = List::Util::max $problem_line, $max_problem_line; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } ## end for my $warning_data ( @{$warnings} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | ▶ | $long_where //= $where; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$long_where //= $where
MC/DC0%0/2
$long_where //= $where
$long_where
$where
Truth table33%1/3
A //= B
A= $long_whereB= $where
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 6 | my $warnings_count = scalar @{$warnings}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 6 | my @problems; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | ▶ | my $false_eval = $eval_given && !$eval_value && !$fatal_error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$eval_given && !$eval_value && !$fatal_error
$eval_given and not $eval_value
MC/DC0%0/3
$eval_given && !$eval_value && !$fatal_error
$eval_given
not $eval_value
!$fatal_error
Truth table50%2/4
A and not(B) && not(C)
A= $eval_givenB= not $eval_valueC= !$fatal_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 6 | ▶ | if ($false_eval) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | push @problems, '* THE MARPA SEMANTICS RETURNED A PERL FALSE', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 'Marpa::R2 requires its semantics to return a true value'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 6 | ▶ | if ($fatal_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 4 | push @problems, '* THE MARPA SEMANTICS PRODUCED A FATAL ERROR'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 6 | ▶ | if ($warnings_count) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 2 | push @problems, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | "* THERE WERE $warnings_count WARNING(S) IN THE MARPA SEMANTICS:", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 'Marpa treats warnings as fatal errors'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 6 | ▶ | if ( not scalar @problems ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | push @msg, '* THERE WAS A FATAL PROBLEM IN THE MARPA SEMANTICS'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 6 | push @msg, ( join "\n", @problems ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 6 | push @msg, "* THIS IS WHAT MARPA WAS DOING WHEN THE PROBLEM OCCURRED:\n" | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | . $long_where . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 6 | for my $warning_ix ( 0 .. ( $warnings_count - 1 ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 4 | push @msg, "* WARNING MESSAGE NUMBER $warning_ix:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 4 | my $warning_message = $warnings->[$warning_ix]->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 4 | $warning_message =~ s/\n*\z/\n/xms; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | push @msg, $warning_message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } ## end for my $warning_ix ( 0 .. ( $warnings_count - 1 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 6 | ▶ | if ($fatal_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | push @msg, "* THIS WAS THE FATAL ERROR MESSAGE:\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 4 | my $fatal_error_message = $fatal_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | $fatal_error_message =~ s/\n*\z/\n/xms; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | push @msg, $fatal_error_message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } ## end if ($fatal_error) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 6 | Marpa::R2::exception(@msg); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # this is to keep perlcritic happy | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } ## end sub code_problems | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Dump semantics for diagnostics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub show_semantics { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_semantics: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my (@ops) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my @op_descs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $op_ix = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | OP: while ( $op_ix < scalar @ops ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $op = $ops[ $op_ix++ ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $op_name = Marpa::R2::Thin::op_name($op); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | push @op_descs, $op_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if ( $op_name eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | push @op_descs, q{"} . $ops[$op_ix] . q{"}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | if ( $op_name eq 'push_constant' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if ( $op_name eq 'push_one' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if ( $op_name eq 'result_is_rhs_n' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ( $op_name eq 'result_is_n_of_sequence' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if ( $op_name eq 'result_is_constant' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ( $op_name eq 'alternative' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | push @op_descs, $ops[$op_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $op_ix++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } ## end if ( $op_name eq 'alternative' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } ## end OP: while ( $op_ix < scalar @ops ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return join q{ }, @op_descs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } ## end sub show_semantics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | # Return false if no ordering was created, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # otherwise return the ordering. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1440 | ▶ | sub Marpa::R2::Recognizer::ordering_get { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ordering_get: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1440 | my ($recce) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1440 | ▶ | return if $recce->[Marpa::R2::Internal::Recognizer::NO_PARSE]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1440 | my $ordering = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1440 | ▶ | return $ordering if $ordering; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1208 | my $parse_set_arg = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | $recce->[Marpa::R2::Internal::Recognizer::END_OF_PARSE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1208 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1208 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1208 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1208 | $grammar_c->throw_set(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1208 | ▶ | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C] = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$parse_set_arg // -1
MC/DC100%1/1
$parse_set_arg // -1
$parse_set_arg
Truth table100%2/2
A
A= $parse_set_arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | Marpa::R2::Thin::B->new( $recce_c, ( $parse_set_arg // -1 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1208 | $grammar_c->throw_set(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1208 | ▶ | if ( not $bocage ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 20 | $recce->[Marpa::R2::Internal::Recognizer::NO_PARSE] = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1188 | $ordering = $recce->[Marpa::R2::Internal::Recognizer::O_C] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | Marpa::R2::Thin::O->new($bocage); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | GIVEN_RANKING_METHOD: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1188 | my $ranking_method = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | $recce->[Marpa::R2::Internal::Recognizer::RANKING_METHOD]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1188 | ▶ | if ( $ranking_method eq 'high_rule_only' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 95 | do_high_rule_only($recce); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 95 | last GIVEN_RANKING_METHOD; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1093 | ▶ | if ( $ranking_method eq 'rule' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 8 | do_rank_by_rule($recce); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 8 | last GIVEN_RANKING_METHOD; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } ## end GIVEN_RANKING_METHOD: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 1188 | return $ordering; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } ## end sub Marpa::R2::Recognizer::ordering_get | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 32795 | ▶ | sub resolve_rule_by_id { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_rule_by_id: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 32795 | my ( $recce, $rule_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 32795 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 32795 | my $rules = $grammar->[Marpa::R2::Internal::Grammar::RULES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 32795 | my $rule = $rules->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 32795 | my $action_name = $rule->[Marpa::R2::Internal::Rule::ACTION_NAME]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 32795 | my $resolve_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 32795 | ▶ | return if not defined $action_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 30157 | my $resolution = Marpa::R2::Internal::Recognizer::resolve_action( $recce, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | $action_name, \$resolve_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 30157 | ▶ | if ( not $resolution ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | my $rule_desc = rule_describe( $grammar, $rule_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$resolve_error // "Failed to resolve action"
MC/DC0%0/1
$resolve_error // "Failed to resolve action"
$resolve_error
Truth table50%1/2
A
A= $resolve_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | "Could not resolve rule action named '$action_name'\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | " Rule was $rule_desc\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | q{ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | ( $resolve_error // 'Failed to resolve action' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } ## end if ( not $resolution ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 30156 | return $resolution; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } ## end sub resolve_rule_by_id | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # For error messages -- checks if it is called in context with | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # SLR defined | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | ▶ | sub rule_describe { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rule_describe: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | my ( $grammar, $rule_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | ▶ | return $Marpa::R2::Context::slr->rule_show($rule_id) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | if $Marpa::R2::Context::slr; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return $grammar->rule_describe($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } ## end sub rule_describe | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1188 | ▶ | sub resolve_recce { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_recce: called CC=36 SCAR=42.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1188 | my ( $recce, $per_parse_arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 1188 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 1188 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1188 | my $rules = $grammar->[Marpa::R2::Internal::Grammar::RULES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1188 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1188 | ▶ | my $trace_actions = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce->[16] // 0
MC/DC0%0/1
$recce->[16] // 0
$recce->[16]
Truth table50%1/2
A
A= $recce->[16]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_ACTIONS] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1188 | my $trace_file_handle = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 1188 | my $package_source = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1188 | ▶ | if ( not defined $package_source | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $package_source and defined $per_parse_arg and my $arg_blessing = builtin::blessed($per_parse_arg)
not defined $package_source and defined $per_parse_arg
MC/DC66%2/3
not defined $package_source and defined $per_parse_arg and my $arg_blessing = builtin::blessed($per_parse_arg)
not defined $package_source
defined $per_parse_arg
my $arg_blessing = builtin::blessed($per_parse_arg)
Truth table75%3/4
not(A) and B and C
A= not defined $package_sourceB= defined $per_parse_argC= my $arg_blessing = builtin::blessed($per_parse_arg)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | and defined $per_parse_arg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | and ( my $arg_blessing = Scalar::Util::blessed $per_parse_arg) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 80 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | $arg_blessing; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 80 | $package_source = 'arg'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } ## end if ( not defined $package_source and defined $per_parse_arg...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 1188 | ▶ | $package_source //= 'semantics_package'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$package_source //= "semantics_package"
MC/DC100%1/1
$package_source //= "semantics_package"
$package_source
Truth table100%2/2
A
A= $package_source
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 1188 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | $package_source; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 1188 | ▶ | if ( $package_source eq 'legacy' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # RESOLVE_PACKAGE is already set if not 'legacy' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 247 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE] = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$grammar->[5] // $grammar->[15]
MC/DC100%2/2
$grammar->[5] // $grammar->[15]
$grammar->[5]
$grammar->[15]
Truth table100%3/3
A // B
A= $grammar->[5]B= $grammar->[15]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | $grammar->[Marpa::R2::Internal::Grammar::ACTIONS] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | // $grammar->[Marpa::R2::Internal::Grammar::ACTION_OBJECT]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } ## end if ( $package_source eq 'legacy' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | FIND_CONSTRUCTOR: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1188 | ▶ | my $constructor_package = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ( $package_source eq 'legacy' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ? $grammar->[Marpa::R2::Internal::Grammar::ACTION_OBJECT] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | : $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1188 | ▶ | last FIND_CONSTRUCTOR if not defined $constructor_package; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 199 | my $constructor_name = $constructor_package . q{::new}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 199 | my $resolve_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 199 | my $resolution = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | Marpa::R2::Internal::Recognizer::resolve_action( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | $constructor_name, \$resolve_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 199 | ▶ | if ($resolution) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 71 | $recce->[ Marpa::R2::Internal::Recognizer::PER_PARSE_CONSTRUCTOR ] | |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | = $resolution->[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 71 | last FIND_CONSTRUCTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 128 | ▶ | last FIND_CONSTRUCTOR if $package_source ne 'legacy'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$resolve_error // "Failed to resolve action"
MC/DC0%0/1
$resolve_error // "Failed to resolve action"
$resolve_error
Truth table0%0/2
A
A= $resolve_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | qq{Could not find constructor "$constructor_name"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | q{ }, ( $resolve_error // 'Failed to resolve action' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } ## end FIND_CONSTRUCTOR: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1188 | my $resolve_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 1188 | my $default_action = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | $grammar->[Marpa::R2::Internal::Grammar::DEFAULT_ACTION]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1188 | my $default_action_resolution = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | Marpa::R2::Internal::Recognizer::resolve_action( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | $default_action, \$resolve_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1188 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$resolve_error // "Failed to resolve action"
MC/DC0%0/1
$resolve_error // "Failed to resolve action"
$resolve_error
Truth table0%0/2
A
A= $resolve_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | "Could not resolve default action named '$default_action'\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | q{ }, ( $resolve_error // 'Failed to resolve action' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | if not $default_action_resolution; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1188 | my $default_empty_action = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | $grammar->[Marpa::R2::Internal::Grammar::DEFAULT_EMPTY_ACTION]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1188 | my $default_empty_action_resolution; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1188 | ▶ | if ($default_empty_action) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 10 | $default_empty_action_resolution = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | Marpa::R2::Internal::Recognizer::resolve_action( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | $default_empty_action, \$resolve_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 10 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$resolve_error // "Failed to resolve action"
MC/DC0%0/1
$resolve_error // "Failed to resolve action"
$resolve_error
Truth table0%0/2
A
A= $resolve_error
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | "Could not resolve default empty rule action named '$default_empty_action'", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | q{ }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | ( $resolve_error // 'Failed to resolve action' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ) if not $default_empty_action_resolution; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } ## end if ($default_empty_action) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1188 | my $rule_resolutions = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1188 | RULE: for my $rule_id ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 32795 | my $rule_resolution = resolve_rule_by_id( $recce, $rule_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 32794 | ▶ | if ( not defined $rule_resolution | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not defined $rule_resolution and $default_empty_action and $grammar_c->rule_length($rule_id) == 0
not defined $rule_resolution and $default_empty_action
MC/DC100%3/3
not defined $rule_resolution and $default_empty_action and $grammar_c->rule_length($rule_id) == 0
not defined $rule_resolution
$default_empty_action
$grammar_c->rule_length($rule_id) == 0
Truth table100%4/4
not(A) and B and C
A= not defined $rule_resolutionB= $default_empty_actionC= $grammar_c->rule_length($rule_id) == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | and $default_empty_action | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | and $grammar_c->rule_length($rule_id) == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 13 | $rule_resolution = $default_empty_action_resolution; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } ## end if ( not defined $rule_resolution and $default_empty_action...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 32794 | ▶ | $rule_resolution //= $default_action_resolution; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$rule_resolution //= $default_action_resolution
MC/DC0%0/2
$rule_resolution //= $default_action_resolution
$rule_resolution
$default_action_resolution
Truth table66%2/3
A //= B
A= $rule_resolutionB= $default_action_resolution
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 32794 | ▶ | if ( not $rule_resolution ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $rule_desc = rule_describe( $grammar, $rule_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $message = "Could not resolve action\n Rule was $rule_desc\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $rule = $rules->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $action = $rule->[Marpa::R2::Internal::Rule::ACTION_NAME]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | $message .= qq{ Action was specified as "$action"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | if defined $action; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $recce_error = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | $recce->[Marpa::R2::Internal::Recognizer::ERROR_MESSAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | $message .= q{ } . $recce_error if defined $recce_error; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | Marpa::R2::exception($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } ## end if ( not $rule_resolution ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | DETERMINE_BLESSING: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 32794 | my $blessing = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | Marpa::R2::Internal::Recognizer::rule_blessing_find( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | $rule_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 32794 | my ( $closure_name, $closure, $semantics ) = @{$rule_resolution}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 32794 | ▶ | if ( $blessing ne '::undef' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 23583 | ▶ | $semantics = '::array' if $semantics eq '::!default'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | CHECK_SEMANTICS: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 23583 | ▶ | last CHECK_SEMANTICS if $semantics eq '::array'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | last CHECK_SEMANTICS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 23489 | ▶ | if ( substr $semantics, 0, 1 ) eq '['; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | qq{Attempt to bless, but improper semantics: "$semantics"} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } ## end CHECK_SEMANTICS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } ## end if ( $blessing ne '::undef' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | $rule_resolution = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 32794 | [ $closure_name, $closure, $semantics, $blessing ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } ## end DETERMINE_BLESSING: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 32794 | $rule_resolutions->[$rule_id] = $rule_resolution; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } ## end RULE: for my $rule_id ( $grammar->rule_ids() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1187 | ▶ | if ( $trace_actions >= 2 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | RULE: for my $rule_id ( 0 .. $#{$rules} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | my ( $resolution_name, $closure ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | @{ $rule_resolutions->[$rule_id] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | say {$trace_file_handle} 'Rule ', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | qq{ resolves to "$resolution_name"} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } ## end RULE: for my $rule_id ( 0 .. $#{$rules} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } ## end if ( $trace_actions >= 2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1187 | my @lexeme_resolutions = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1187 | SYMBOL: for my $lexeme_id ( 0 .. $#{$symbols} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 43429 | my $semantics = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | Marpa::R2::Internal::Recognizer::lexeme_semantics_find( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | $lexeme_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 43429 | ▶ | if ( not defined $semantics ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $message = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | "Could not determine lexeme's semantics\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | . q{ Lexeme was } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | . $grammar->symbol_name($lexeme_id) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $message | |||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | .= q{ } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | . $recce->[Marpa::R2::Internal::Recognizer::ERROR_MESSAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | Marpa::R2::exception($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } ## end if ( not defined $semantics ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 43429 | my $blessing = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | Marpa::R2::Internal::Recognizer::lexeme_blessing_find( $recce, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | $lexeme_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 43429 | ▶ | if ( not defined $blessing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my $message = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | "Could not determine lexeme's blessing\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | . q{ Lexeme was } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | . $grammar->symbol_name($lexeme_id) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $message | |||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | .= q{ } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | . $recce->[Marpa::R2::Internal::Recognizer::ERROR_MESSAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | Marpa::R2::exception($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } ## end if ( not defined $blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 43429 | $lexeme_resolutions[$lexeme_id] = [ $semantics, $blessing ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } ## end SYMBOL: for my $lexeme_id ( 0 .. $#{$symbols} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 1187 | return ( $rule_resolutions, \@lexeme_resolutions ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } ## end sub resolve_recce | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 1139 | ▶ | sub registration_init { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registration_init: called CC=109 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 1139 | my ( $recce, $per_parse_arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 1139 | my $trace_file_handle = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 1139 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 1139 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 1139 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 1139 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 1139 | ▶ | my $trace_actions = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce->[16] // 0
MC/DC0%0/1
$recce->[16] // 0
$recce->[16]
Truth table50%1/2
A
A= $recce->[16]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_ACTIONS] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1139 | my $rules = $grammar->[Marpa::R2::Internal::Grammar::RULES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 1139 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 1139 | my @closure_by_rule_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1139 | my @semantics_by_rule_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 1139 | my @blessing_by_rule_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1139 | my ( $rule_resolutions, $lexeme_resolutions ) = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | resolve_recce( $recce, $per_parse_arg ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | # Set the arrays, and perform various checks on the resolutions | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # we received | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | # ::whatever is deprecated and has been removed from the docs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | # it is now equivalent to ::undef | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1138 | RULE: | |||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 1138 | for my $rule_id ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | my ( $new_resolution, $closure, $semantics, $blessing ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 32426 | @{ $rule_resolutions->[$rule_id] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 32426 | my $lhs_id = $grammar_c->rule_lhs($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | REFINE_SEMANTICS: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 32426 | ▶ | if ('[' eq substr $semantics, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
"[" eq substr($semantics, 0, 1) and "]" eq substr($semantics, -1, 1)
MC/DC50%1/2
"[" eq substr($semantics, 0, 1) and "]" eq substr($semantics, -1, 1)
"[" eq substr($semantics, 0, 1)
"]" eq substr($semantics, -1, 1)
Truth table66%2/3
A and B
A= "[" eq substr($semantics, 0, 1)B= "]" eq substr($semantics, -1, 1)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0, 1 and ']' eq substr $semantics, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | -1, 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # Normalize array semantics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 24064 | $semantics =~ s/ //gxms; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 24064 | last REFINE_SEMANTICS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } ## end if ( '[' eq substr $semantics, 0, 1 and ']' eq ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | state $allowed_semantics = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 8362 | map { ; ( $_, 1 ) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | qw(::array ::undef ::first ::whatever ::!default), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | q{} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 8362 | ▶ | last REFINE_SEMANTICS if $allowed_semantics->{$semantics}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | last REFINE_SEMANTICS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | if $semantics =~ m/ \A rhs \d+ \z /xms; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | q{Unknown semantics for rule }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | qq{ Semantics were specified as "$semantics"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | } ## end REFINE_SEMANTICS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 32426 | $semantics_by_rule_id[$rule_id] = $semantics; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 32426 | $blessing_by_rule_id[$rule_id] = $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 32426 | $closure_by_rule_id[$rule_id] = $closure; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | CHECK_BLESSING: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 32426 | ▶ | last CHECK_BLESSING if $blessing eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 23463 | ▶ | if ($closure) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my $ref_type = Scalar::Util::reftype $closure; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | if ( $ref_type eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | # The constant's dump might be long so I repeat the error message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | qq{Fatal error: Attempt to bless a rule that resolves to a scalar constant\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | qq{ Scalar constant is }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | Data::Dumper::Dumper($closure), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | qq{ Blessing is "$blessing"\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | q{ Rule is: }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | qq{ Cannot bless rule when it resolves to a scalar constant}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } ## end if ( $ref_type eq 'SCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | last CHECK_BLESSING; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } ## end if ($closure) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 23463 | ▶ | last CHECK_BLESSING if $semantics eq '::array'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 23369 | ▶ | last CHECK_BLESSING if ( substr $semantics, 0, 1 ) eq '['; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | qq{Cannot bless rule when the semantics are "$semantics"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | q{ Rule is: }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | qq{ Blessing is "$blessing"\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | qq{ Semantics are "$semantics"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } ## end CHECK_BLESSING: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } ## end RULE: for my $rule_id ( $grammar->rule_ids() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } ## end CHECK_FOR_WHATEVER_CONFLICT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # A LHS can be nullable via more than one rule, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # and that means more than one semantics might be specified for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # the nullable symbol. This logic deals with that. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 1138 | my @nullable_rule_ids_by_lhs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 1138 | RULE: for my $rule_id ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 32426 | my $lhs_id = $grammar_c->rule_lhs($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 32426 | ▶ | push @{ $nullable_rule_ids_by_lhs[$lhs_id] }, $rule_id | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | if $grammar_c->rule_is_nullable($rule_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 1138 | my @null_symbol_closures; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | LHS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1138 | ▶ | for ( my $lhs_id = 0; $lhs_id <= $#nullable_rule_ids_by_lhs; $lhs_id++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 33278 | my $rule_ids = $nullable_rule_ids_by_lhs[$lhs_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 33278 | my $resolution_rule; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # No nullable rules for this LHS? No problem. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 33278 | ▶ | next LHS if not defined $rule_ids; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 2192 | my $rule_count = scalar @{$rule_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # I am not sure if this test is necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 2192 | ▶ | next LHS if $rule_count <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | # Just one nullable rule? Then that's our semantics. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 2192 | ▶ | if ( $rule_count == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 2182 | $resolution_rule = $rule_ids->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | my ( $resolution_name, $closure ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2182 | @{ $rule_resolutions->[$resolution_rule] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2182 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $lhs_name = $grammar->symbol_name($lhs_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | qq{Nulled symbol "$lhs_name" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | qq{ resolved to "$resolution_name" from rule }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | $grammar->brief_rule($resolution_rule) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } ## end if ($trace_actions) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 2182 | $null_symbol_closures[$lhs_id] = $resolution_rule; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 2182 | next LHS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } ## end if ( $rule_count == 1 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | # More than one rule? Are any empty? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # If so, use the semantics of the empty rule | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | my @empty_rules = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 10 | grep { $grammar_c->rule_length($_) <= 0 } @{$rule_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 10 | ▶ | if ( scalar @empty_rules ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 9 | $resolution_rule = $empty_rules[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | my ( $resolution_name, $closure ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 9 | @{ $rule_resolutions->[$resolution_rule] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 9 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | my $lhs_name = $grammar->symbol_name($lhs_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | qq{Nulled symbol "$lhs_name" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | qq{ resolved to "$resolution_name" from rule }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | $grammar->brief_rule($resolution_rule) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } ## end if ($trace_actions) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 9 | $null_symbol_closures[$lhs_id] = $resolution_rule; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 9 | next LHS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } ## end if ( scalar @empty_rules ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | # Multiple rules, none of them empty. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | my ( $first_resolution, @other_resolutions ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 1 | map { $rule_resolutions->[$_] } @{$rule_ids}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | # Do they have more than one semantics? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | # If so, just call it an error and let the user sort it out. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | my ( $first_closure_name, undef, $first_semantics, $first_blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 1 | = @{$first_resolution}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 1 | OTHER_RESOLUTION: for my $other_resolution (@other_resolutions) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | my ( $other_closure_name, undef, $other_semantics, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | $other_blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 1 | = @{$other_resolution}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 1 | ▶ | if ( $first_closure_name ne $other_closure_name | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$first_closure_name ne $other_closure_name or $first_semantics ne $other_semantics or $first_blessing ne $other_blessing
$first_closure_name ne $other_closure_name or $first_semantics ne $other_semantics
MC/DC0%0/3
$first_closure_name ne $other_closure_name or $first_semantics ne $other_semantics or $first_blessing ne $other_blessing
$first_closure_name ne $other_closure_name
$first_semantics ne $other_semantics
$first_blessing ne $other_blessing
Truth table25%1/4
A or B or C
A= $first_closure_name ne $other_closure_nameB= $first_semantics ne $other_semanticsC= $first_blessing ne $other_blessing
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | or $first_semantics ne $other_semantics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | or $first_blessing ne $other_blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 'When nulled, symbol ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | $grammar->symbol_name($lhs_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | qq{ can have more than one semantics\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | qq{ Marpa needs there to be only one semantics\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | qq{ The rules involved are:\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | Marpa::R2::Internal::Recognizer::brief_rule_list( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | $recce, $rule_ids | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } ## end if ( $first_closure_name ne $other_closure_name or ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } ## end OTHER_RESOLUTION: for my $other_resolution (@other_resolutions) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | # Multiple rules, but they all have one semantics. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | # So (obviously) use that semantics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 1 | $resolution_rule = $rule_ids->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | my ( $resolution_name, $closure ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1 | @{ $rule_resolutions->[$resolution_rule] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1 | ▶ | if ($trace_actions) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | my $lhs_name = $grammar->symbol_name($lhs_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | qq{Nulled symbol "$lhs_name" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | qq{ resolved to "$resolution_name" from rule }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | $grammar->brief_rule($resolution_rule) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | } ## end if ($trace_actions) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 1 | $null_symbol_closures[$lhs_id] = $resolution_rule; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | } ## end LHS: for ( my $lhs_id = 0; $lhs_id <= $#nullable_rule_ids_by_lhs...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | # Do consistency checks | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | # Set the object values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 1138 | $recce->[Marpa::R2::Internal::Recognizer::NULL_VALUES] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | \@null_symbol_closures; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 1138 | my @semantics_by_lexeme_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 1138 | my @blessing_by_lexeme_id = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | # Check the lexeme semantics | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | # ::whatever is deprecated and has been removed from the docs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # it is now equivalent to ::undef | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 1138 | LEXEME: for my $lexeme_id ( 0 .. $#{$symbols} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | my ( $semantics, $blessing ) = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 43005 | @{ $lexeme_resolutions->[$lexeme_id] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | CHECK_SEMANTICS: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 43005 | ▶ | if ( not $semantics ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $semantics = '::!default'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | last CHECK_SEMANTICS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 43005 | ▶ | if ( ( substr $semantics, 0, 1 ) eq '[' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 4113 | $semantics =~ s/ //gxms; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 4113 | last CHECK_SEMANTICS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | state $allowed_semantics = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 38892 | { map { ; ( $_, 1 ) } qw(::array ::undef ::!default ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 38892 | ▶ | if ( not $allowed_semantics->{$semantics} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | q{Unknown semantics for lexeme }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | $grammar->symbol_name($lexeme_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | qq{ Semantics were specified as "$semantics"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } ## end if ( not $allowed_semantics->{$semantics} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | } ## end CHECK_SEMANTICS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | CHECK_BLESSING: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 43005 | ▶ | if ( not $blessing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | $blessing = '::undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | last CHECK_BLESSING; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 43005 | ▶ | last CHECK_BLESSING if $blessing eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | last CHECK_BLESSING | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 3866 | ▶ | if $blessing =~ /\A [[:alpha:]] [:\w]* \z /xms; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | q{Unknown blessing for lexeme }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | $grammar->symbol_name($lexeme_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | qq{ Blessing as specified as "$blessing"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } ## end CHECK_BLESSING: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 43005 | $semantics_by_lexeme_id[$lexeme_id] = $semantics; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 43005 | $blessing_by_lexeme_id[$lexeme_id] = $blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | } ## end LEXEME: for my $lexeme_id ( 0 .. $#{$symbols} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 1138 | my $null_values = $recce->[Marpa::R2::Internal::Recognizer::NULL_VALUES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 1138 | state $op_bless = Marpa::R2::Thin::op('bless'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 1138 | state $op_callback = Marpa::R2::Thin::op('callback'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 1138 | state $op_push_constant = Marpa::R2::Thin::op('push_constant'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 1138 | state $op_push_g1_length = Marpa::R2::Thin::op('push_g1_length'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 1138 | state $op_push_g1_len = Marpa::R2::Thin::op('push_g1_len'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 1138 | state $op_push_length = Marpa::R2::Thin::op('push_length'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 1138 | state $op_push_undef = Marpa::R2::Thin::op('push_undef'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 1138 | state $op_push_one = Marpa::R2::Thin::op('push_one'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 1138 | state $op_push_sequence = Marpa::R2::Thin::op('push_sequence'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 1138 | state $op_push_g1_start = Marpa::R2::Thin::op('push_g1_start'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 1138 | state $op_push_start_location = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | Marpa::R2::Thin::op('push_start_location'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 1138 | state $op_push_values = Marpa::R2::Thin::op('push_values'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 1138 | state $op_result_is_array = Marpa::R2::Thin::op('result_is_array'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 1138 | state $op_result_is_constant = Marpa::R2::Thin::op('result_is_constant'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 1138 | state $op_result_is_n_of_sequence = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | Marpa::R2::Thin::op('result_is_n_of_sequence'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 1138 | state $op_result_is_rhs_n = Marpa::R2::Thin::op('result_is_rhs_n'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 1138 | state $op_result_is_token_value = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | Marpa::R2::Thin::op('result_is_token_value'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 1138 | state $op_result_is_undef = Marpa::R2::Thin::op('result_is_undef'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 1138 | my @nulling_symbol_by_semantic_rule; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 1138 | NULLING_SYMBOL: for my $nulling_symbol ( 0 .. $#{$null_values} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 33278 | my $semantic_rule = $null_values->[$nulling_symbol]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 33278 | ▶ | next NULLING_SYMBOL if not defined $semantic_rule; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 2192 | $nulling_symbol_by_semantic_rule[$semantic_rule] = $nulling_symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } ## end NULLING_SYMBOL: for my $nulling_symbol ( 0 .. $#{$null_values} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 1138 | my @work_list = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 1138 | RULE: for my $rule_id ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 32426 | my $semantics = $semantics_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 32426 | my $blessing = $blessing_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 32426 | ▶ | $semantics = '::undef' if $semantics eq '::!default'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 32426 | ▶ | $semantics = '[values]' if $semantics eq '::array'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 32426 | ▶ | $semantics = '::undef' if $semantics eq '::whatever'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 32426 | ▶ | $semantics = '::rhs0' if $semantics eq '::first'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 32426 | push @work_list, [ $rule_id, undef, $semantics, $blessing ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | } ## end RULE: for my $rule_id ( $grammar->rule_ids() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 1138 | RULE: for my $lexeme_id ( 0 .. $#{$symbols} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 43005 | my $semantics = $semantics_by_lexeme_id[$lexeme_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 43005 | my $blessing = $blessing_by_lexeme_id[$lexeme_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 43005 | ▶ | $semantics = '::value' if $semantics eq '::!default'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 43005 | ▶ | $semantics = '[value]' if $semantics eq '::array'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 43005 | push @work_list, [ undef, $lexeme_id, $semantics, $blessing ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } ## end RULE: for my $lexeme_id ( 0 .. $#{$symbols} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # Registering operations is postponed to this point, because | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # the valuator must exist for this to happen. In the future, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | # it may be best to have a separate semantics object. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 1138 | my @nulling_closures = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 1138 | my @registrations = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 1138 | my $top_nulling_ops; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 1138 | WORK_ITEM: for my $work_item (@work_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 75431 | my ( $rule_id, $lexeme_id, $semantics, $blessing ) = @{$work_item}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 75431 | my ( $closure, $rule, $rule_length, $is_sequence_rule, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | $is_discard_sequence_rule, $nulling_symbol_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 75431 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 32426 | $nulling_symbol_id = $nulling_symbol_by_semantic_rule[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 32426 | $closure = $closure_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 32426 | $rule = $rules->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 32426 | $rule_length = $grammar_c->rule_length($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 32426 | $is_sequence_rule = defined $grammar_c->sequence_min($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 32426 | ▶ | $is_discard_sequence_rule = $is_sequence_rule | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$is_sequence_rule && $rule->[2]
MC/DC100%2/2
$is_sequence_rule && $rule->[2]
$is_sequence_rule
$rule->[2]
Truth table100%3/3
A && B
A= $is_sequence_ruleB= $rule->[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | && $rule->[Marpa::R2::Internal::Rule::DISCARD_SEPARATION]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } ## end if ( defined $rule_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | # Determine the "fate" of the array of child values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 75431 | my $array_fate; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | ARRAY_FATE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 75431 | ▶ | if ( defined $closure and ref $closure eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $closure and ref $closure eq "CODE"
MC/DC100%2/2
defined $closure and ref $closure eq "CODE"
defined $closure
ref $closure eq "CODE"
Truth table100%3/3
A and B
A= defined $closureB= ref $closure eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 4889 | $array_fate = $op_callback; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 4889 | last ARRAY_FATE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 70542 | ▶ | if ( ( substr $semantics, 0, 1 ) eq '[' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 28640 | $array_fate = $op_result_is_array; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 28640 | last ARRAY_FATE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } ## end ARRAY_FATE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 75431 | my @ops = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | SET_OPS: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 75431 | ▶ | if ( $semantics eq '::undef' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 1768 | @ops = ($op_result_is_undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 1768 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | DO_CONSTANT: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 73663 | ▶ | last DO_CONSTANT if not defined $rule_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 30658 | my $thingy_ref = $closure_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 30658 | ▶ | last DO_CONSTANT if not defined $thingy_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 4924 | my $ref_type = Scalar::Util::reftype $thingy_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 4924 | ▶ | if ( $ref_type eq q{} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | my $rule_desc = rule_describe( $grammar, $rule_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | qq{An action resolved to a scalar.\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | qq{ This is not allowed.\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | qq{ A constant action must be a reference.\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | qq{ Rule was $rule_desc\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | } ## end if ( $ref_type eq q{} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 4924 | ▶ | if ( $ref_type eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | # Set the nulling closure if this is the nulling symbol of a rule | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 4889 | ▶ | $nulling_closures[$nulling_symbol_id] = $thingy_ref | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $nulling_symbol_id and defined $rule_id
MC/DC50%1/2
defined $nulling_symbol_id and defined $rule_id
defined $nulling_symbol_id
defined $rule_id
Truth table66%2/3
A and B
A= defined $nulling_symbol_idB= defined $rule_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | if defined $nulling_symbol_id | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | and defined $rule_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 4889 | last DO_CONSTANT; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | } ## end if ( $ref_type eq 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 35 | ▶ | if ( $ref_type eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 30 | my $thingy = ${$thingy_ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 30 | ▶ | if ( not defined $thingy ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 0 | @ops = ($op_result_is_undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 30 | @ops = ( $op_result_is_constant, $thingy_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 30 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | } ## end if ( $ref_type eq 'SCALAR' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | # No test for 'ARRAY' or 'HASH' -- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | # The ref is currenly only to scalar and code slots in the symbol table, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | # and therefore cannot be to (among other things) an ARRAY or HASH | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 5 | ▶ | if ( $ref_type eq 'REF' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 5 | @ops = ( $op_result_is_constant, $thingy_ref ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 5 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $rule_desc = rule_describe( $grammar, $rule_id ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | qq{Constant action is not of an allowed type.\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | qq{ It was of type reference to $ref_type.\n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | qq{ Rule was $rule_desc\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } ## end DO_CONSTANT: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | # After this point, any closure will be a ref to 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 73628 | ▶ | if ( defined $lexeme_id and $semantics eq '::value' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $lexeme_id and $semantics eq "::value"
MC/DC100%2/2
defined $lexeme_id and $semantics eq "::value"
defined $lexeme_id
$semantics eq "::value"
Truth table100%3/3
A and B
A= defined $lexeme_idB= $semantics eq "::value"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 38892 | @ops = ($op_result_is_token_value); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 38892 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | PROCESS_SINGLETON_RESULT: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 34736 | ▶ | last PROCESS_SINGLETON_RESULT if not defined $rule_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 30623 | my $singleton; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 30623 | ▶ | if ( $semantics =~ m/\A [:][:] rhs (\d+) \z/xms ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 1242 | $singleton = $1 + 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 30623 | ▶ | last PROCESS_SINGLETON_RESULT if not defined $singleton; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 1242 | my $singleton_element = $singleton; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 1242 | ▶ | if ($is_discard_sequence_rule) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | @ops = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | ( $op_result_is_n_of_sequence, $singleton_element ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 1242 | ▶ | if ($is_sequence_rule) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 0 | @ops = ( $op_result_is_rhs_n, $singleton_element ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 1242 | my $mask = $rule->[Marpa::R2::Internal::Rule::MASK]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | my @elements = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 1242 | grep { $mask->[$_] } 0 .. ( $rule_length - 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 1242 | ▶ | if ( not scalar @elements ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | my $original_semantics = $semantics_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | q{Impossible semantics for empty rule: }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | qq{ Semantics were specified as "$original_semantics"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } ## end if ( not scalar @elements ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 1242 | $singleton_element = $elements[$singleton]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 1242 | ▶ | if ( not defined $singleton_element ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | my $original_semantics = $semantics_by_rule_id[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | q{Impossible semantics for rule: }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | qq{ Semantics were specified as "$original_semantics"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } ## end if ( not defined $singleton_element ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 1242 | @ops = ( $op_result_is_rhs_n, $singleton_element ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 1242 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } ## end PROCESS_SINGLETON_RESULT: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 33494 | ▶ | if ( not defined $array_fate ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | @ops = ($op_result_is_undef); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | last SET_OPS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | # if here, $array_fate is defined | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 33494 | my @bless_ops = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 33494 | ▶ | if ( $blessing ne '::undef' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 27329 | push @bless_ops, $op_bless, \$blessing; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 33494 | ▶ | Marpa::R2::exception(qq{Unknown semantics: "$semantics"}) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | if ( substr $semantics, 0, 1 ) ne '['; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 33494 | my @push_ops = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 33494 | my $array_descriptor = substr $semantics, 1, -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 33494 | $array_descriptor =~ s/^\s*|\s*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | RESULT_DESCRIPTOR: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 33494 | for my $result_descriptor ( split /[,]\s*/xms, $array_descriptor ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 90089 | $result_descriptor =~ s/^\s*|\s*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 90089 | ▶ | if ( $result_descriptor eq 'g1start' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 562 | push @push_ops, $op_push_g1_start; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 562 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 89527 | ▶ | if ( $result_descriptor eq 'g1len' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 562 | push @push_ops, $op_push_g1_len; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 562 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 88965 | ▶ | if ( $result_descriptor eq 'g1length' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 4 | push @push_ops, $op_push_g1_length; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 4 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 88961 | ▶ | if ( $result_descriptor eq 'start' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 27378 | push @push_ops, $op_push_start_location; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 27378 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 61583 | ▶ | if ( $result_descriptor eq 'length' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 27378 | push @push_ops, $op_push_length; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 27378 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 34205 | ▶ | if ( $result_descriptor eq 'lhs' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 9 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 5 | my $lhs_id = $grammar_c->rule_lhs($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 5 | push @push_ops, $op_push_constant, \$lhs_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 5 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 4 | ▶ | if ( defined $lexeme_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 4 | push @push_ops, $op_push_constant, \$lexeme_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 4 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | push @push_ops, $op_push_undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | } ## end if ( $result_descriptor eq 'lhs' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 34196 | ▶ | if ( $result_descriptor eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 705 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 654 | my $name = $grammar->rule_name($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 654 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 654 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 51 | ▶ | if ( defined $lexeme_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 51 | my $name = $tracer->symbol_name($lexeme_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 51 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 51 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | ▶ | if ( defined $nulling_symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | my $name = $tracer->symbol_name($nulling_symbol_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | push @push_ops, $op_push_undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | } ## end if ( $result_descriptor eq 'name' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 33491 | ▶ | if ( $result_descriptor eq 'symbol' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 5 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 3 | my $lhs_id = $grammar_c->rule_lhs($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 3 | my $name = $tracer->symbol_name($lhs_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 3 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 3 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } ## end if ( defined $rule_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 2 | ▶ | if ( defined $lexeme_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 2 | my $name = $tracer->symbol_name($lexeme_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 2 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 2 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | ▶ | if ( defined $nulling_symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 0 | my $name = $tracer->symbol_name($nulling_symbol_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | push @push_ops, $op_push_constant, \$name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | push @push_ops, $op_push_undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | } ## end if ( $result_descriptor eq 'symbol' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 33486 | ▶ | if ( $result_descriptor eq 'rule' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 5 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 3 | push @push_ops, $op_push_constant, \$rule_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 3 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 2 | push @push_ops, $op_push_undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 2 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | } ## end if ( $result_descriptor eq 'rule' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 33481 | ▶ | if ( $result_descriptor eq 'values' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result_descriptor eq "values" or $result_descriptor eq "value"
MC/DC0%0/2
$result_descriptor eq "values" or $result_descriptor eq "value"
$result_descriptor eq "values"
$result_descriptor eq "value"
Truth table66%2/3
A or B
A= $result_descriptor eq "values"B= $result_descriptor eq "value"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | or $result_descriptor eq 'value' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 33481 | ▶ | if ( defined $lexeme_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 4113 | push @push_ops, $op_push_values; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 4113 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 29368 | ▶ | if ($is_sequence_rule) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 1547 | ▶ | my $push_op = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | $is_discard_sequence_rule | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | ? $op_push_sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | : $op_push_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 1547 | push @push_ops, $push_op; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 1547 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | } ## end if ($is_sequence_rule) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 27821 | my $mask = $rule->[Marpa::R2::Internal::Rule::MASK]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 27821 | ▶ | if ( $rule_length > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | push @push_ops, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 27000 | ▶ | map { $mask->[$_] ? ( $op_push_one, $_ ) : () } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 .. $rule_length - 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 27821 | next RESULT_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | } ## end if ( $result_descriptor eq 'values' or ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | qq{Unknown result descriptor: "$result_descriptor"\n}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | qq{ The full semantics were "$semantics"} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } ## end RESULT_DESCRIPTOR: for my $result_descriptor ( split /[,]\s*/xms, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 33494 | @ops = ( @push_ops, @bless_ops, $array_fate ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | } ## end SET_OPS: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 75431 | ▶ | if ( defined $rule_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 32426 | push @registrations, [ 'rule', $rule_id, @ops ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 75431 | ▶ | if ( defined $nulling_symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 2192 | push @registrations, [ 'nulling', $nulling_symbol_id, @ops ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | } ## end if ( defined $nulling_symbol_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 75431 | ▶ | if ( defined $lexeme_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 43005 | push @registrations, [ 'token', $lexeme_id, @ops ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | } ## end WORK_ITEM: for my $work_item (@work_list) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | SLR_NULLING_GRAMMAR_HACK: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 1138 | ▶ | last SLR_NULLING_GRAMMAR_HACK if not $Marpa::R2::Context::slr; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | # A hack for nulling SLR grammars -- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | # the nulling semantics of the start symbol should | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | # be those of the symbol on the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | # RHS of the start rule -- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | # so copy them. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 891 | my $start_symbol_id = $tracer->symbol_by_name('[:start]'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | last SLR_NULLING_GRAMMAR_HACK | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 891 | ▶ | if not $grammar_c->symbol_is_nullable($start_symbol_id); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 326 | my $start_rhs_symbol_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 326 | RULE: for my $rule_id ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 848 | my ( $lhs, $rhs0 ) = $tracer->rule_expand($rule_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 848 | ▶ | if ( $start_symbol_id == $lhs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 326 | $start_rhs_symbol_id = $rhs0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 326 | last RULE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | } ## end RULE: for my $rule_id ( $grammar->rule_ids() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 326 | REGISTRATION: for my $registration (@registrations) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 704 | my ( $type, $nulling_symbol_id ) = @{$registration}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 704 | ▶ | if ( $nulling_symbol_id == $start_rhs_symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 326 | my ( undef, undef, @ops ) = @{$registration}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 326 | push @registrations, [ 'nulling', $start_symbol_id, @ops ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 326 | $nulling_closures[$start_symbol_id] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | $nulling_closures[$start_rhs_symbol_id]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 326 | last REGISTRATION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | } ## end if ( $nulling_symbol_id == $start_rhs_symbol_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | } ## end REGISTRATION: for my $registration (@registrations) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | } ## end SLR_NULLING_GRAMMAR_HACK: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 1138 | $recce->[Marpa::R2::Internal::Recognizer::REGISTRATIONS] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | \@registrations; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 1138 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_SYMBOL_ID] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | \@nulling_closures; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 1138 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_RULE_ID] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | \@closure_by_rule_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | } ## end sub registration_init | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # Returns false if no parse | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 8102 | ▶ | sub Marpa::R2::Recognizer::value { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=76 SCAR=53.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 8102 | my ( $recce, $slr, $per_parse_arg ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 8102 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 8102 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 8102 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 8102 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 8102 | ▶ | my $trace_actions = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce->[16] // 0
MC/DC0%0/1
$recce->[16] // 0
$recce->[16]
Truth table50%1/2
A
A= $recce->[16]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_ACTIONS] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 8102 | ▶ | my $trace_values = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$recce->[22] // 0
MC/DC100%1/1
$recce->[22] // 0
$recce->[22]
Truth table100%2/2
A
A= $recce->[22]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_VALUES] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 8102 | my $trace_file_handle = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 8102 | local $Marpa::R2::Internal::TRACE_FH = $trace_file_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 8102 | my $rules = $grammar->[Marpa::R2::Internal::Grammar::RULES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 8102 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 8102 | ▶ | if ( scalar @_ != 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 5742 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 'Too many arguments to Marpa::R2::Recognizer::value') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | if ref $slr ne 'Marpa::R2::Scanless::R'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 8102 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::TREE_MODE] //= 'tree'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$recce->[5] //= "tree"
MC/DC100%1/1
$recce->[5] //= "tree"
$recce->[5]
Truth table100%2/2
A
A= $recce->[5]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 8102 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TREE_MODE] ne 'tree' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | "value() called when recognizer is not in tree mode\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | ' The current mode is "', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | $recce->[Marpa::R2::Internal::Recognizer::TREE_MODE], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | qq{"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | } ## end if ( $recce->[Marpa::R2::Internal::Recognizer::TREE_MODE...]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 8102 | my $furthest_earleme = $recce_c->furthest_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 8102 | my $last_completed_earleme = $recce_c->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 8102 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | "Attempt to evaluate incompletely recognized parse:\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | " Last token ends at location $furthest_earleme\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | " Recognition done only as far as location $last_completed_earleme\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | ) if $furthest_earleme > $last_completed_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 8102 | my $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 8102 | ▶ | if ($tree) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | # On second and later calls to value() in a parse series, we need | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | # to check the per-parse arg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | CHECK_ARG: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 6944 | my $package_source = $recce | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | ->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | last CHECK_ARG | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 6944 | ▶ | if $package_source eq 'semantics_package'; # Anything is OK | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 2114 | ▶ | if ( $package_source eq 'legacy' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 2114 | ▶ | if ( defined $per_parse_arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | "value() called with an argument while incompatible options are in use.\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | " Often this means that the discouraged 'action_object' named argument was used,\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | " and that 'semantics_package' should be used instead.\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } ## end if ( defined $per_parse_arg ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 2114 | last CHECK_ARG; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | } ## end if ( $package_source eq 'legacy' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | # If here the resolve package source is 'arg' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 0 | ▶ | if ( not defined $per_parse_arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | "No value() arg, when one is required to resolve semantics.\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | " Once value() has been called with a argument whose blessing is used to\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | " find the parse's semantics closures, it must always be called with an arg\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | " that is blessed in the same package\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | q{ In this case, the package was "}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | $recce | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | ->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | qq{"\n"} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | } ## end if ( not defined $per_parse_arg ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | my $arg_blessing = Scalar::Util::blessed $per_parse_arg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | ▶ | if ( not defined $arg_blessing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | "value() arg is not blessed when required for the semantics.\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | " Once value() has been called with a argument whose blessing is used to\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | " find the parse's semantics closures, it must always be called with an arg\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | " that is blessed in the same package\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | q{ In this case, the original package was "}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | $recce | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | ->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | qq{"\n"}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | qq{ and the blessing in this call was "$arg_blessing"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } ## end if ( not defined $arg_blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | my $required_blessing = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | ▶ | if ( $arg_blessing ne $required_blessing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | "value() arg is blessed into the wrong package.\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | " Once value() has been called with a argument whose blessing is used to\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | " find the parse's semantics closures, it must always be called with an arg\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | " that is blessed in the same package\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | qq{ In this case, the original package was "$required_blessing" and \n}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | qq{ and the blessing in this call was "$arg_blessing"\n} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | } ## end if ( $arg_blessing ne $required_blessing ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | } ## end CHECK_ARG: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | # If we have a bocage, we are initialized | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 6944 | ▶ | if ( not $tree ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | # No tree means we are in ASF mode | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 0 | Marpa::R2::exception('value() called for recognizer in ASF mode'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 6944 | my $max_parses = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | $recce->[Marpa::R2::Internal::Recognizer::MAX_PARSES]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 6944 | my $parse_count = $tree->parse_count(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 6944 | ▶ | if ( $max_parses and $parse_count > $max_parses ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$max_parses and $parse_count > $max_parses
MC/DC0%0/2
$max_parses and $parse_count > $max_parses
$max_parses
$parse_count > $max_parses
Truth table66%2/3
A and B
A= $max_parsesB= $parse_count > $max_parses
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | "Maximum parse count ($max_parses) exceeded"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | } ## end if ($tree) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | # No tree, therefore not initialized | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 1158 | my $order = $recce->ordering_get(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 1158 | ▶ | return if not $order; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 1138 | $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C] = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | Marpa::R2::Thin::T->new($order); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | } ## end else [ if ($tree) ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | 8082 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_AND_NODES] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 0 | ▶ | print {$trace_file_handle} 'AND_NODES: ', $recce->show_and_nodes() | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 8082 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_OR_NODES] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 0 | ▶ | print {$trace_file_handle} 'OR_NODES: ', $recce->show_or_nodes() | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 8082 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_BOCAGE] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | print {$trace_file_handle} 'BOCAGE: ', $recce->show_bocage() | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | 8082 | ▶ | return if not defined $tree->next(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | 7973 | local $Marpa::R2::Context::grammar = $grammar; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 7973 | local $Marpa::R2::Context::rule = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 7973 | local $Marpa::R2::Context::slr = $slr; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 7973 | ▶ | local $Marpa::R2::Context::slg = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | $slr->[Marpa::R2::Internal::Scanless::R::GRAMMAR] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | if defined $slr; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 7973 | ▶ | if ( not $recce->[Marpa::R2::Internal::Recognizer::REGISTRATIONS] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 1138 | registration_init( $recce, $per_parse_arg ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 7972 | my $semantics_arg0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | RUN_CONSTRUCTOR: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | # Do not run the constructor if there is a per-parse arg | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 7972 | ▶ | last RUN_CONSTRUCTOR if defined $per_parse_arg; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | 7924 | my $per_parse_constructor = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | $recce->[Marpa::R2::Internal::Recognizer::PER_PARSE_CONSTRUCTOR]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | # Do not run the constructor if there isn't one | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 7924 | ▶ | last RUN_CONSTRUCTOR if not defined $per_parse_constructor; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 17 | my $constructor_arg0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | 17 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | eq 'legacy' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | 14 | $constructor_arg0 = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | $grammar->[Marpa::R2::Internal::Grammar::ACTION_OBJECT]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | } ## end if ( $recce->[...]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 3 | $constructor_arg0 = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 17 | my @warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | my $eval_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | 17 | my $fatal_error; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | DO_EVAL: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 17 | local $EVAL_ERROR = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | local $SIG{__WARN__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | push @warnings, [ $_[0], ( caller 0 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 17 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 17 | $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 17 | $semantics_arg0 = $per_parse_constructor->($constructor_arg0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 17 | $fatal_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | } ## end DO_EVAL: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | 17 | ▶ | if ( not $eval_ok or @warnings ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $eval_ok or @warnings
MC/DC0%0/2
not $eval_ok or @warnings
not $eval_ok
@warnings
Truth table33%1/3
not(A) or B
A= not $eval_okB= @warnings
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | code_problems( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | { fatal_error => $fatal_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | grammar => $grammar, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | eval_ok => $eval_ok, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | warnings => \@warnings, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | where => 'constructing action object', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | } ## end if ( not $eval_ok or @warnings ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | } ## end RUN_CONSTRUCTOR: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 7972 | ▶ | $semantics_arg0 //= $per_parse_arg // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$semantics_arg0 //= $per_parse_arg // {}
$per_parse_arg // {}
MC/DC100%1/1
$semantics_arg0 //= $per_parse_arg // {}
$semantics_arg0
Truth table100%2/2
A
A= $semantics_arg0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 7972 | my $value = Marpa::R2::Thin::V->new($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 7972 | ▶ | if ($slr) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 5691 | $value->slr_set( $slr->thin() ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 2281 | my $token_values = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | $recce->[Marpa::R2::Internal::Recognizer::TOKEN_VALUES]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 2281 | $value->valued_force(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | TOKEN_IX: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 2281 | ▶ | for ( my $token_ix = 2; $token_ix <= $#{$token_values}; $token_ix++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 15201 | my $token_value = $token_values->[$token_ix]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 15201 | ▶ | $value->token_value_set( $token_ix, $token_value ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | if defined $token_value; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | } ## end TOKEN_IX: for ( my $token_ix = 2; $token_ix <= $#{...}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | } ## end else [ if ($slr) ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 7972 | local $Marpa::R2::Internal::Context::VALUATOR = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | 7972 | ▶ | value_trace( $value, $trace_values ? 1 : 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | 7972 | $value->trace_values($trace_values); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 7972 | $value->stack_mode_set(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | 7972 | my $null_values = $recce->[Marpa::R2::Internal::Recognizer::NULL_VALUES]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 7972 | my $nulling_closures = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_SYMBOL_ID]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 7972 | my $rule_closures = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_RULE_ID]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | REGISTRATION: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 7972 | for my $registration ( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 7972 | @{ $recce->[Marpa::R2::Internal::Recognizer::REGISTRATIONS] } ) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | 193206 | my ( $type, $id, @raw_ops ) = @{$registration}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 193206 | my @ops = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | PRINT_TRACES: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | 193206 | ▶ | last PRINT_TRACES if $trace_values <= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 0 | ▶ | if ( $type eq 'nulling' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | 0 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | "Registering semantics for nulling symbol: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | $grammar->symbol_name($id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | "\n", ' Semantics are ', show_semantics(@raw_ops) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | Marpa::R2::exception('Cannot say to trace file handle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 0 | last PRINT_TRACES; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | } ## end if ( $type eq 'nulling' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | "Registering semantics for $type: ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | $grammar->symbol_name($id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | "\n", ' Semantics are ', show_semantics(@raw_ops) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | or Marpa::R2::exception('Cannot say to trace file handle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | } ## end PRINT_TRACES: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 193206 | OP: for my $raw_op (@raw_ops) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 531776 | ▶ | if ( ref $raw_op ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | 29416 | push @ops, $value->constant_register( ${$raw_op} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 29416 | next OP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | 502360 | push @ops, $raw_op; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | } ## end OP: for my $raw_op (@raw_ops) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 193206 | ▶ | if ( $type eq 'token' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 96156 | $value->token_register( $id, @ops ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 96156 | next REGISTRATION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | 97050 | ▶ | if ( $type eq 'nulling' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 7371 | $value->nulling_symbol_register( $id, @ops ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 7371 | next REGISTRATION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | 89679 | ▶ | if ( $type eq 'rule' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | 89679 | $value->rule_register( $id, @ops ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 89679 | next REGISTRATION; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | 0 | 'Registration: with unknown type: ', | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | Data::Dumper::Dumper($registration) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | } ## end REGISTRATION: for my $registration ( @{ $recce->[...]}) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | 7972 | STEP: while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | 136504 | my ( $value_type, @value_data ) = $value->stack_step(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 136504 | ▶ | if ($trace_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | 100 | EVENT: while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | 114 | my $event = $value->event(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 114 | ▶ | last EVENT if not defined $event; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | 14 | my ( $event_type, @event_data ) = @{$event}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 14 | ▶ | if ( $event_type eq 'MARPA_STEP_TOKEN' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | 14 | my ( $token_id, $token_value_ix, $token_value ) = @event_data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | 14 | trace_token_evaluation( $recce, $value, $token_id, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | $token_value ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 14 | next EVENT; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | } ## end if ( $event_type eq 'MARPA_STEP_TOKEN' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | say {$trace_file_handle} join q{ }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 'value event:', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | map { $_ // 'undef' } $event_type, @event_data | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_ // "undef"
MC/DC0%0/1
$_ // "undef"
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | or Marpa::R2::exception('say to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | } ## end EVENT: while (1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | 100 | ▶ | if ( $trace_values >= 9 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | for my $i ( reverse 0 .. $value->highest_index ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | 0 | ▶ | printf {$trace_file_handle} "Stack position %3d:\n", $i, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | 0 | ▶ | print {$trace_file_handle} q{ }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | Data::Dumper->new( [ \$value->absolute($i) ] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | ->Terse(1)->Dump | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | or | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | } ## end for my $i ( reverse 0 .. $value->highest_index ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | } ## end if ( $trace_values >= 9 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | } ## end if ($trace_values) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | 136504 | ▶ | last STEP if not defined $value_type; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 128542 | ▶ | next STEP if $value_type eq 'trace'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | 128512 | ▶ | if ( $value_type eq 'MARPA_STEP_NULLING_SYMBOL' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | 1334 | my ($token_id) = @value_data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 1334 | my $value_ref = $nulling_closures->[$token_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 1334 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | my @warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 1334 | my $eval_ok; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | DO_EVAL: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | 1334 | ▶ | local $SIG{__WARN__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | push @warnings, [ $_[0], ( caller 0 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | 1334 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | 1334 | $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 1334 | local $Marpa::R2::Context::rule = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | $null_values->[$token_id]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 1334 | $result = $value_ref->($semantics_arg0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | 1334 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | } ## end DO_EVAL: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 1334 | ▶ | if ( not $eval_ok or @warnings ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $eval_ok or @warnings
MC/DC0%0/2
not $eval_ok or @warnings
not $eval_ok
@warnings
Truth table33%1/3
not(A) or B
A= not $eval_okB= @warnings
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | my $fatal_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | code_problems( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | { fatal_error => $fatal_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | grammar => $grammar, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | eval_ok => $eval_ok, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | warnings => \@warnings, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | where => 'computing value', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | long_where => 'Computing value for null symbol: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | . $grammar->symbol_name($token_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | } ## end if ( not $eval_ok or @warnings ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | 1334 | $value->result_set($result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 1334 | ▶ | trace_token_evaluation( $recce, $value, $token_id, \$result ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | if $trace_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | 1334 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | } ## end if ( $value_type eq 'MARPA_STEP_NULLING_SYMBOL' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 127178 | ▶ | if ( $value_type eq 'MARPA_STEP_RULE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 127129 | my ( $rule_id, $values ) = @value_data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 127129 | my $closure = $rule_closures->[$rule_id]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 127129 | ▶ | next STEP if not defined $closure; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | 127129 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 127129 | ▶ | if ( ref $closure eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 127129 | my @warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | my $eval_ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | DO_EVAL: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 127129 | ▶ | local $SIG{__WARN__} = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | 4 | push @warnings, [ $_[0], ( caller 0 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 127129 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 127129 | local $Marpa::R2::Context::rule = $rule_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 127129 | ▶ | if ( Scalar::Util::blessed($values) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | $result = $closure->( $semantics_arg0, $values ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | 0 | last DO_EVAL; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | } ## end if ( Scalar::Util::blessed($values) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 127129 | $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | 127129 | $result = $closure->( $semantics_arg0, @{$values} ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 127121 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | } ## end DO_EVAL: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | 127129 | ▶ | if ( not $eval_ok or @warnings ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $eval_ok or @warnings
MC/DC100%2/2
not $eval_ok or @warnings
not $eval_ok
@warnings
Truth table100%3/3
not(A) or B
A= not $eval_okB= @warnings
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 10 | my $fatal_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 10 | code_problems( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | { fatal_error => $fatal_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | grammar => $grammar, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | eval_ok => $eval_ok, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | warnings => \@warnings, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | where => 'computing value', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | long_where => 'Computing value for rule: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | . $grammar->brief_rule($rule_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | } ## end if ( not $eval_ok or @warnings ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | } ## end if ( ref $closure eq 'CODE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | $result = ${$closure}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | 127119 | $value->result_set($result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 127119 | ▶ | if ($trace_values) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | 18 | ▶ | say {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | trace_stack_1( $grammar, $recce, $value, $values, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | $rule_id ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 18 | ▶ | print {$trace_file_handle} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | 'Calculated and pushed value: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | Data::Dumper->new( [$result] )->Terse(1)->Dump | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | } ## end if ($trace_values) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | 127119 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | } ## end if ( $value_type eq 'MARPA_STEP_RULE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | 49 | ▶ | if ( $value_type eq 'MARPA_STEP_TRACE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 49 | ▶ | if ( my $trace_output = trace_op( $grammar, $recce, $value ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 2 | ▶ | print {$trace_file_handle} $trace_output | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 49 | next STEP; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | } ## end if ( $value_type eq 'MARPA_STEP_TRACE' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | 0 | die "Internal error: Unknown value type $value_type"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | } ## end STEP: while (1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | 7962 | return \( $value->absolute(0) ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | } ## end sub Marpa::R2::Recognizer::value | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 95 | ▶ | sub do_high_rule_only { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_high_rule_only: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 95 | my ($recce) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 95 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | 95 | $order->high_rank_only_set(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | 95 | $order->rank(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | 95 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | } ## end sub do_high_rule_only | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 8 | ▶ | sub do_rank_by_rule { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_rank_by_rule: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 8 | my ($recce) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 8 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | # Rank by rule is the default, but just in case | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 8 | $order->high_rank_only_set(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 8 | $order->rank(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 8 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | } ## end sub do_rank_by_rule | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | # INTERNAL OK AFTER HERE _marpa_ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 1 | ▶ | sub Marpa::R2::Recognizer::show_bocage { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_bocage: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | 1 | my ($recce, $verbose) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | 1 | ▶ | $verbose //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$verbose //= 0
MC/DC0%0/1
$verbose //= 0
$verbose
Truth table50%1/2
A
A= $verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | 1 | my @data = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 1 | my $id = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | 1 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 1 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | 1 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | 1 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 1 | OR_NODE: for ( my $or_node_id = 0;; $or_node_id++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | 21 | my $irl_id = $bocage->_marpa_b_or_node_irl($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | 21 | ▶ | last OR_NODE if not defined $irl_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | 20 | my $position = $bocage->_marpa_b_or_node_position($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | 20 | my $or_origin = $bocage->_marpa_b_or_node_origin($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | 20 | my $origin_earleme = $recce_c->earleme($or_origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | 20 | my $or_set = $bocage->_marpa_b_or_node_set($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | 20 | my $current_earleme = $recce_c->earleme($or_set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | 20 | my @and_node_ids = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | ( $bocage->_marpa_b_or_node_first_and($or_node_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | .. $bocage->_marpa_b_or_node_last_and($or_node_id) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | AND_NODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | 20 | for my $and_node_id (@and_node_ids) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | 23 | my $symbol = $bocage->_marpa_b_and_node_symbol($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | 23 | my $cause_tag; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | 23 | ▶ | if ( defined $symbol ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | 7 | $cause_tag = "S$symbol"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | 23 | my $cause_id = $bocage->_marpa_b_and_node_cause($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | 23 | ▶ | if ( defined $cause_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | 16 | $cause_tag = "OR#$cause_id=" . | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | Marpa::R2::Recognizer::or_node_tag( $recce, $cause_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | 23 | my $parent_tag = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | Marpa::R2::Recognizer::or_node_tag( $recce, $or_node_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | 23 | my $predecessor_id = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | $bocage->_marpa_b_and_node_predecessor($and_node_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | 23 | my $predecessor_tag = q{-}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | 23 | ▶ | if ( defined $predecessor_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | 10 | $predecessor_tag = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | $predecessor_tag = "OR#$predecessor_id=" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | Marpa::R2::Recognizer::or_node_tag( $recce, $predecessor_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | 23 | my $tag = join q{ }, "AND#$and_node_id:", "parent=OR#$or_node_id=$parent_tag", | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | "pred=$predecessor_tag", "cause=$cause_tag"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | 23 | push @data, [ $and_node_id, $tag ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | } ## end AND_NODE: for my $and_node_id (@and_node_ids) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | } ## end OR_NODE: for ( my $or_node_id = 0;; $or_node_id++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | 1 | my @sorted_data = map { $_->[-1] } sort { $a->[0] <=> $b->[0] } @data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | 1 | return ( join "\n", @sorted_data ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | } ## end sub Marpa::R2::Recognizer::show_bocage | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | 83 | ▶ | sub Marpa::R2::Recognizer::and_node_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and_node_tag: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | 83 | my ( $recce, $and_node_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | 83 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | 83 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | 83 | my $parent_or_node_id = $bocage->_marpa_b_and_node_parent($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | 83 | my $origin = $bocage->_marpa_b_or_node_origin($parent_or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | 83 | my $origin_earleme = $recce_c->earleme($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | 83 | my $current_earley_set = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | $bocage->_marpa_b_or_node_set($parent_or_node_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | 83 | my $current_earleme = $recce_c->earleme($current_earley_set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | 83 | my $cause_id = $bocage->_marpa_b_and_node_cause($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | 83 | my $predecessor_id = $bocage->_marpa_b_and_node_predecessor($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | 83 | my $middle_earley_set = $bocage->_marpa_b_and_node_middle($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | 83 | my $middle_earleme = $recce_c->earleme($middle_earley_set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | 83 | my $position = $bocage->_marpa_b_or_node_position($parent_or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | 83 | my $irl_id = $bocage->_marpa_b_or_node_irl($parent_or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | #<<< perltidy introduces trailing space on this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | 83 | my $tag = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | 'R' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | . $irl_id . q{:} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | . $position . q{@} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | #>>> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | 83 | ▶ | if ( defined $cause_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | 45 | my $cause_irl_id = $bocage->_marpa_b_or_node_irl($cause_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | 45 | $tag .= 'C' . $cause_irl_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | 38 | my $symbol = $bocage->_marpa_b_and_node_symbol($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | 38 | $tag .= 'S' . $symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | 83 | $tag .= q{@} . $middle_earleme; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | 83 | return $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | } ## end sub Marpa::R2::Recognizer::and_node_tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | 2 | ▶ | sub Marpa::R2::Recognizer::show_and_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_and_nodes: called CC=8 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | 2 | my ($recce, $verbose) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | 2 | ▶ | $verbose //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$verbose //= 0
MC/DC0%0/1
$verbose //= 0
$verbose
Truth table50%1/2
A
A= $verbose
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | 2 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | 2 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | 2 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | 2 | my @data = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | 2 | AND_NODE: for ( my $id = 0;; $id++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | 46 | my $parent = $bocage->_marpa_b_and_node_parent($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | 46 | my $predecessor = $bocage->_marpa_b_and_node_predecessor($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | 46 | my $cause = $bocage->_marpa_b_and_node_cause($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | 46 | my $symbol = $bocage->_marpa_b_and_node_symbol($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | 46 | ▶ | last AND_NODE if not defined $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | 44 | my $origin = $bocage->_marpa_b_or_node_origin($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | 44 | my $set = $bocage->_marpa_b_or_node_set($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | 44 | my $irl_id = $bocage->_marpa_b_or_node_irl($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | 44 | my $position = $bocage->_marpa_b_or_node_position($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | 44 | my $origin_earleme = $recce_c->earleme($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | 44 | my $current_earleme = $recce_c->earleme($set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | 44 | my $middle_earley_set = $bocage->_marpa_b_and_node_middle($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | 44 | my $middle_earleme = $recce_c->earleme($middle_earley_set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | #<<< perltidy introduces trailing space on this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | 44 | my $desc = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | "And-node #$id: R" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | . $irl_id . q{:} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | . $position . q{@} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | #>>> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | 44 | my $cause_rule = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | 44 | ▶ | if ( defined $cause ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | 26 | my $cause_irl_id = $bocage->_marpa_b_or_node_irl($cause); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | 26 | $desc .= 'C' . $cause_irl_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | 18 | $desc .= 'S' . $symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | 44 | $desc .= q{@} . $middle_earleme; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | 44 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | ▶ | $desc .= " parent=" . (defined $parent ? "OR#$parent" : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | 0 | ▶ | $desc .= " pred=" . (defined $predecessor ? "OR#$predecessor" : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | ▶ | $desc .= " cause=" . (defined $cause ? "OR#$cause" : '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | 44 | push @data, $desc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | } ## end AND_NODE: for ( my $id = 0;; $id++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | 2 | return ( join "\n", @data ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | } ## end sub Marpa::R2::Recognizer::show_and_nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | 89 | ▶ | sub Marpa::R2::Recognizer::or_node_tag { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
or_node_tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | 89 | my ( $recce, $or_node_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | 89 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | 89 | my $set = $bocage->_marpa_b_or_node_set($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | 89 | my $irl_id = $bocage->_marpa_b_or_node_irl($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | 89 | my $origin = $bocage->_marpa_b_or_node_origin($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | 89 | my $position = $bocage->_marpa_b_or_node_position($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | 89 | return 'R' . $irl_id . q{:} . $position . q{@} . $origin . q{-} . $set; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | } ## end sub Marpa::R2::Recognizer::or_node_tag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | 2 | ▶ | sub Marpa::R2::Recognizer::show_or_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_or_nodes: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | 2 | my ( $recce, $verbose ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | 2 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | 2 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | 2 | my $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | 2 | my @data = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | 2 | my $id = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | 2 | OR_NODE: for ( ;; ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | 43 | my $origin = $bocage->_marpa_b_or_node_origin($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | 43 | my $set = $bocage->_marpa_b_or_node_set($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | 43 | my $irl_id = $bocage->_marpa_b_or_node_irl($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | 43 | my $position = $bocage->_marpa_b_or_node_position($id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | 43 | $id++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | 43 | ▶ | last OR_NODE if not defined $origin; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | 41 | my $origin_earleme = $recce_c->earleme($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | 41 | my $current_earleme = $recce_c->earleme($set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | #<<< perltidy introduces trailing space on this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | 41 | my $desc = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | 'R' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | . $irl_id . q{:} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | . $position . q{@} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | #>>> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | 41 | push @data, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | [ $origin_earleme, $current_earleme, $irl_id, $position, $desc ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | } ## end OR_NODE: for ( ;; ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | 41 | my @sorted_data = map { $_->[-1] } sort { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | 2 | ▶ | $a->[0] <=> $b->[0] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition88%8/9
$Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0] || $Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1] || $Marpa::R2::Internal::Value::a->[2] <=> $Marpa::R2::Internal::Value::b->[2] || $Marpa::R2::Internal::Value::a->[3] <=> $Marpa::R2::Internal::Value::b->[3]
$Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0] or $Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1] or $Marpa::R2::Internal::Value::a->[2] <=> $Marpa::R2::Internal::Value::b->[2]
$Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0] or $Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1]
MC/DC0%0/4
$Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0] || $Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1] || $Marpa::R2::Internal::Value::a->[2] <=> $Marpa::R2::Internal::Value::b->[2] || $Marpa::R2::Internal::Value::a->[3] <=> $Marpa::R2::Internal::Value::b->[3]
$Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0]
$Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1]
$Marpa::R2::Internal::Value::a->[2] <=> $Marpa::R2::Internal::Value::b->[2]
$Marpa::R2::Internal::Value::a->[3] <=> $Marpa::R2::Internal::Value::b->[3]
Truth table80%4/5
A or B or C || D
A= $Marpa::R2::Internal::Value::a->[0] <=> $Marpa::R2::Internal::Value::b->[0]B= $Marpa::R2::Internal::Value::a->[1] <=> $Marpa::R2::Internal::Value::b->[1]C= $Marpa::R2::Internal::Value::a->[2] <=> $Marpa::R2::Internal::Value::b->[2]D= $Marpa::R2::Internal::Value::a->[3] <=> $Marpa::R2::Internal::Value::b->[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | or $a->[1] <=> $b->[1] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | or $a->[2] <=> $b->[2] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | or $a->[3] <=> $b->[3] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | } @data; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | 2 | return ( join "\n", @sorted_data ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | } ## end sub Marpa::R2::Recognizer::show_or_nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | # Not sorted and therefore not suitable for test suite | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | 0 | ▶ | sub Marpa::R2::Recognizer::verbose_or_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose_or_nodes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | my ($recce) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | 0 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | OR_NODE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | 0 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | my $or_node_id = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | defined( my $or_node_desc = $recce->verbose_or_node($or_node_id) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | $or_node_id++ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | 0 | $text .= $or_node_desc; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | } ## end OR_NODE: for ( my $or_node_id = 0; defined( my $or_node_desc =...)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | } ## end sub Marpa::R2::Recognizer::verbose_or_nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | 0 | ▶ | sub Marpa::R2::Recognizer::verbose_or_node { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose_or_node: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | 0 | my ( $recce, $or_node_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | 0 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | 0 | my $origin = $bocage->_marpa_b_or_node_origin($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | 0 | ▶ | return if not defined $origin; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | 0 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | 0 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | 0 | my $set = $bocage->_marpa_b_or_node_set($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | 0 | my $irl_id = $bocage->_marpa_b_or_node_irl($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | 0 | my $position = $bocage->_marpa_b_or_node_position($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | 0 | my $origin_earleme = $recce_c->earleme($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | my $current_earleme = $recce_c->earleme($set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | 0 | my $text = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | "OR-node #$or_node_id: R$irl_id" . q{:} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | . $position . q{@} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | . $current_earleme . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | $text .= | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | ( q{ } x 4 ) . $tracer->show_dotted_irl( $irl_id, $position ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | 0 | for my $and_node_id ( $bocage->_marpa_b_or_node_first_and($or_node_id) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | .. $bocage->_marpa_b_or_node_last_and($or_node_id) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | 0 | my $parent = $bocage->_marpa_b_and_node_parent($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | 0 | my $predecessor = $bocage->_marpa_b_and_node_predecessor($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | 0 | my $cause = $bocage->_marpa_b_and_node_cause($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | 0 | my $symbol = $bocage->_marpa_b_and_node_symbol($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | ▶ | last AND_NODE if not defined $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | 0 | my $origin = $bocage->_marpa_b_or_node_origin($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | my $set = $bocage->_marpa_b_or_node_set($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | 0 | my $irl_id = $bocage->_marpa_b_or_node_irl($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | 0 | my $position = $bocage->_marpa_b_or_node_position($parent); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | 0 | my $origin_earleme = $recce_c->earleme($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | my $current_earleme = $recce_c->earleme($set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | 0 | my $middle_earley_set = $bocage->_marpa_b_and_node_middle($and_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | 0 | my $middle_earleme = $recce_c->earleme($middle_earley_set); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | #<<< perltidy introduces trailing space on this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | 0 | my $desc = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | "And-node #$and_node_id: R" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | . $irl_id . q{:} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | . $position . q{@} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | #>>> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | my $cause_rule = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | if ( defined $cause ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | my $cause_irl_id = $bocage->_marpa_b_or_node_irl($cause); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | 0 | $desc .= 'C' . $cause_irl_id; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | $desc .= 'S' . $symbol; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | 0 | $desc .= q{@} . $middle_earleme; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | 0 | $text .= " $desc\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | } ## end sub Marpa::R2::Recognizer::verbose_or_node | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | 44 | ▶ | sub Marpa::R2::Recognizer::show_nook { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_nook: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | 44 | my ( $recce, $nook_id, $verbose ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | 44 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | 44 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | 44 | my $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | 44 | my $or_node_id = $tree->_marpa_t_nook_or_node($nook_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | 44 | ▶ | return if not defined $or_node_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | 40 | my $text = "o$or_node_id"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | 40 | ▶ | my $parent = $tree->_marpa_t_nook_parent($nook_id) // q{-}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$tree->_marpa_t_nook_parent($nook_id) // "-"
MC/DC100%1/1
$tree->_marpa_t_nook_parent($nook_id) // "-"
$tree->_marpa_t_nook_parent($nook_id)
Truth table100%2/2
A
A= $tree->_marpa_t_nook_parent($nook_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | CHILD_TYPE: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | 40 | ▶ | if ( $tree->_marpa_t_nook_is_cause($nook_id) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | 24 | $text .= "[c$parent]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | 24 | last CHILD_TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | 16 | ▶ | if ( $tree->_marpa_t_nook_is_predecessor($nook_id) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | 12 | $text .= "[p$parent]"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | 12 | last CHILD_TYPE; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | 4 | $text .= '[-]'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | } ## end CHILD_TYPE: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | 40 | my $or_node_tag = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | Marpa::R2::Recognizer::or_node_tag( $recce, $or_node_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | 40 | $text .= " $or_node_tag"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | 40 | $text .= ' p'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | 40 | ▶ | $text .= | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | $tree->_marpa_t_nook_predecessor_is_ready($nook_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | ? q{=ok} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | : q{-}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | 40 | $text .= ' c'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | 40 | ▶ | $text .= $tree->_marpa_t_nook_cause_is_ready($nook_id) ? q{=ok} : q{-}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | 40 | $text .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | DESCRIBE_CHOICES: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | 40 | my $this_choice = $tree->_marpa_t_nook_choice($nook_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | 40 | CHOICE: for ( my $choice_ix = 0;; $choice_ix++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | 89 | my $and_node_id = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | $order->_marpa_o_and_node_order_get( $or_node_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | $choice_ix ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | 89 | ▶ | last CHOICE if not defined $and_node_id; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | 49 | $text .= " o$or_node_id" . '[' . $choice_ix . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | 49 | ▶ | if ( defined $this_choice and $this_choice == $choice_ix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $this_choice and $this_choice == $choice_ix
MC/DC50%1/2
defined $this_choice and $this_choice == $choice_ix
defined $this_choice
$this_choice == $choice_ix
Truth table66%2/3
A and B
A= defined $this_choiceB= $this_choice == $choice_ix
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | 40 | $text .= q{*}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | 49 | my $and_node_tag = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | 49 | $text .= " ::= a$and_node_id $and_node_tag"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | 49 | $text .= "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | } ## end CHOICE: for ( my $choice_ix = 0;; $choice_ix++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | } ## end DESCRIBE_CHOICES: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | 40 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | } ## end sub Marpa::R2::Recognizer::show_nook | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | 4 | ▶ | sub Marpa::R2::Recognizer::show_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_tree: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | 4 | my ( $recce, $verbose ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | 4 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | 4 | NOOK: for ( my $nook_id = 0; 1; $nook_id++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | 44 | my $nook_text = $recce->show_nook( $nook_id, $verbose ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | 44 | ▶ | last NOOK if not defined $nook_text; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | 40 | $text .= "$nook_id: $nook_text"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | 4 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | } ## end sub Marpa::R2::Recognizer::show_tree | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | 14 | ▶ | sub trace_token_evaluation { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace_token_evaluation: called CC=6 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | 14 | my ( $recce, $value, $token_id, $token_value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | 14 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | 14 | my $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | 14 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | 14 | my $nook_ix = $value->_marpa_v_nook(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | 14 | ▶ | if ( not defined $nook_ix ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} "Nulling valuator\n" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | 14 | my $or_node_id = $tree->_marpa_t_nook_or_node($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | 14 | my $choice = $tree->_marpa_t_nook_choice($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | 14 | my $and_node_id = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | $order->_marpa_o_and_node_order_get( $or_node_id, $choice ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | 14 | my $token_name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | 14 | ▶ | if ( defined $token_id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | 14 | $token_name = $grammar->symbol_name($token_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | 14 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | 'Pushed value from ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | ': ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | ( $token_name ? qq{$token_name = } : q{} ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | Data::Dumper->new( [ \$token_value ] )->Terse(1)->Dump | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | or Marpa::R2::exception('print to trace handle failed'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | 14 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | } ## end sub trace_token_evaluation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | 18 | ▶ | sub trace_stack_1 { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace_stack_1: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | 18 | my ( $grammar, $recce, $value, $args, $rule_id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | 18 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | 18 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | 18 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | 18 | my $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | 18 | my $argc = scalar @{$args}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | 18 | my $nook_ix = $value->_marpa_v_nook(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | 18 | my $or_node_id = $tree->_marpa_t_nook_or_node($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | 18 | my $choice = $tree->_marpa_t_nook_choice($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | 18 | my $and_node_id = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | $order->_marpa_o_and_node_order_get( $or_node_id, $choice ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | 18 | return 'Popping ', $argc, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | ' values to evaluate ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | ', rule: ', $grammar->brief_rule($rule_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | } ## end sub trace_stack_1 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | 49 | ▶ | sub trace_op { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace_op: called CC=13 SCAR=29.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | 49 | my ( $grammar, $recce, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | 49 | my $trace_output = q{}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | 49 | ▶ | my $trace_values = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce->[22] // 0
MC/DC0%0/1
$recce->[22] // 0
$recce->[22]
Truth table50%1/2
A
A= $recce->[22]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_VALUES] // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | 49 | ▶ | return $trace_output if not $trace_values >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | 32 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | 32 | my $bocage = $recce->[Marpa::R2::Internal::Recognizer::B_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | 32 | my $order = $recce->[Marpa::R2::Internal::Recognizer::O_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | 32 | my $tree = $recce->[Marpa::R2::Internal::Recognizer::T_C]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | 32 | my $nook_ix = $value->_marpa_v_nook(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | 32 | my $or_node_id = $tree->_marpa_t_nook_or_node($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | 32 | my $choice = $tree->_marpa_t_nook_choice($nook_ix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | 32 | my $and_node_id = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | $order->_marpa_o_and_node_order_get( $or_node_id, $choice ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | 32 | my $trace_irl_id = $bocage->_marpa_b_or_node_irl($or_node_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | 32 | my $virtual_rhs = $grammar_c->_marpa_g_irl_is_virtual_rhs($trace_irl_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | 32 | my $virtual_lhs = $grammar_c->_marpa_g_irl_is_virtual_lhs($trace_irl_id); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | 32 | ▶ | return $trace_output | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | if $bocage->_marpa_b_or_node_position($or_node_id) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | != $grammar_c->_marpa_g_irl_length($trace_irl_id); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | 20 | ▶ | return $trace_output if not $virtual_rhs and not $virtual_lhs; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$virtual_rhs or $virtual_lhs
MC/DC50%1/2
$virtual_rhs or $virtual_lhs
$virtual_rhs
$virtual_lhs
Truth table66%2/3
A or B
A= $virtual_rhsB= $virtual_lhs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | 2 | ▶ | if ( $virtual_rhs and not $virtual_lhs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$virtual_rhs and not $virtual_lhs
MC/DC0%0/2
$virtual_rhs and not $virtual_lhs
$virtual_rhs
not $virtual_lhs
Truth table33%1/3
A and not(B)
A= $virtual_rhsB= not $virtual_lhs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | 0 | ▶ | $trace_output .= join q{}, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | 'Head of Virtual Rule: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | ', rule: ', $grammar->brief_irl($trace_irl_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | 'Incrementing virtual rule by ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | $grammar_c->_marpa_g_real_symbol_count($trace_irl_id), ' symbols', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | or Marpa::R2::exception('Could not print to trace file'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | 0 | return $trace_output; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | } ## end if ( $virtual_rhs and not $virtual_lhs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | 2 | ▶ | if ( $virtual_lhs and $virtual_rhs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$virtual_lhs and $virtual_rhs
MC/DC0%0/2
$virtual_lhs and $virtual_rhs
$virtual_lhs
$virtual_rhs
Truth table33%1/3
A and B
A= $virtual_lhsB= $virtual_rhs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | 0 | $trace_output .= join q{}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | 'Virtual Rule: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | ', rule: ', $grammar->brief_irl($trace_irl_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | "\nAdding ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | $grammar_c->_marpa_g_real_symbol_count($trace_irl_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | 0 | return $trace_output; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | } ## end if ( $virtual_lhs and $virtual_rhs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | 2 | ▶ | if ( not $virtual_rhs and $virtual_lhs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $virtual_rhs and $virtual_lhs
MC/DC0%0/2
not $virtual_rhs and $virtual_lhs
not $virtual_rhs
$virtual_lhs
Truth table33%1/3
not(A) and B
A= not $virtual_rhsB= $virtual_lhs
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | 2 | $trace_output .= join q{}, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | 'New Virtual Rule: ', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | Marpa::R2::Recognizer::and_node_tag( $recce, $and_node_id ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | ', rule: ', $grammar->brief_irl($trace_irl_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | "\nReal symbol count is ", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | $grammar_c->_marpa_g_real_symbol_count($trace_irl_id), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | 2 | return $trace_output; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | } ## end if ( not $virtual_rhs and $virtual_lhs ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | 0 | return $trace_output; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | } ## end sub trace_op | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | 7972 | ▶ | sub value_trace { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_trace: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | 7972 | my ( $value, $trace_flag ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | 7972 | return $value->_marpa_v_trace($trace_flag); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | 150 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | # vim: expandtab shiftwidth=4: | ||||||||||||||||||||||||||||||||||||||||||||||||||