| 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::Recognizer; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | 150 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 150 | ▶ | use vars qw($VERSION $STRING_VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 150 | $VERSION = '13.003_000'; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 150 | $STRING_VERSION = $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 26 | ## no critic(BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 150 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 28 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | package Marpa::R2::Internal::Recognizer; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 150 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 150 | my $parse_number = 0; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # Returns the new parse object or throws an exception | ||||||||||||||||||||||||||||||||||||||||||
| 37 | sub Marpa::R2::Recognizer::new { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 226 | ▶ | my ( $class, @arg_hashes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=26 SCAR=34.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 226 | my $recce = bless [], $class; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 226 | my $grammar; | |||||||||||||||||||||||||||||||||||||||||
| 42 | my $trace_file_handle; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 226 | for my $arg_hash (@arg_hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # Need to capture the trace file handle early | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 226 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 226 | ▶ | if ( defined( $value = $arg_hash->{trace_file_handle} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 5 | delete $arg_hash->{trace_file_handle}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | $trace_file_handle = $value; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 226 | ▶ | if ( defined( $value = $arg_hash->{grammar} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 226 | delete $arg_hash->{grammar}; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 226 | $grammar = $value; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } ## end for my $arg_hash (@arg_hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 226 | ▶ | Marpa::R2::exception('No grammar specified') if not defined $grammar; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 226 | ▶ | $trace_file_handle //= $grammar->[Marpa::R2::Internal::Grammar::TRACE_FILE_HANDLE] ; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$trace_file_handle //= $grammar->[8]
MC/DC0%0/2
$trace_file_handle //= $grammar->[8]
$trace_file_handle
$grammar->[8]
Truth table66%2/3
A //= B
A= $trace_file_handleB= $grammar->[8]
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 226 | local $Marpa::R2::Internal::TRACE_FH = | |||||||||||||||||||||||||||||||||||||||||
| 60 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE] = $trace_file_handle; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 226 | $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR] = $grammar; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 226 | my $grammar_class = ref $grammar; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 226 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | "${class}::new() grammar arg has wrong class: $grammar_class") | ||||||||||||||||||||||||||||||||||||||||||
| 67 | if not $grammar_class eq 'Marpa::R2::Grammar'; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 226 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 226 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 226 | my $problems = $grammar->[Marpa::R2::Internal::Grammar::PROBLEMS]; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 226 | ▶ | if ($problems) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 75 | Marpa::R2::Grammar::show_problems($grammar), | ||||||||||||||||||||||||||||||||||||||||||
| 76 | "Attempt to parse grammar with fatal problems\n", | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 'Marpa::R2 cannot proceed', | ||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } ## end if ($problems) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 226 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C] = | |||||||||||||||||||||||||||||||||||||||||
| 82 | Marpa::R2::Thin::R->new($grammar_c); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 226 | ▶ | if ( not defined $recce_c ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $error_code = $grammar_c->error_code() // -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$grammar_c->error_code // -1
MC/DC0%0/1
$grammar_c->error_code // -1
$grammar_c->error_code
Truth table0%0/2
A
A= $grammar_c->error_code
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $error_code == $Marpa::R2::Error::NOT_PRECOMPUTED ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 87 | 'Attempt to parse grammar which is not precomputed'); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | Marpa::R2::exception( $grammar_c->error() ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | } ## end if ( not defined $recce_c ) | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 226 | $recce_c->ruby_slippers_set(1); | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 226 | ▶ | if ( defined $grammar->[Marpa::R2::Internal::Grammar::ACTION_OBJECT] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $grammar->[15] or defined $grammar->[5] or not defined $grammar->[11]
defined $grammar->[15] or defined $grammar->[5]
MC/DC0%0/3
defined $grammar->[15] or defined $grammar->[5] or not defined $grammar->[11]
defined $grammar->[15]
defined $grammar->[5]
not defined $grammar->[11]
Truth table75%3/4
A or B or not(C)
A= defined $grammar->[15]B= defined $grammar->[5]C= not defined $grammar->[11]
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | or defined $grammar->[Marpa::R2::Internal::Grammar::ACTIONS] | ||||||||||||||||||||||||||||||||||||||||||
| 96 | or not defined $grammar->[Marpa::R2::Internal::Grammar::INTERNAL] ) | ||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 226 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] = | |||||||||||||||||||||||||||||||||||||||||
| 99 | 'legacy'; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } ## end if ( defined $grammar->[...]) | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 226 | ARG_HASH: for my $arg_hash (@arg_hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 103 | 226 | ▶ | if ( defined( my $value = $arg_hash->{'leo'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | ▶ | my $boolean = $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | $recce->use_leo_set($boolean); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | delete $arg_hash->{leo}; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | } ## end ARG_HASH: for my $arg_hash (@arg_hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 226 | ARG_HASH: for my $arg_hash (@arg_hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 111 | 226 | ▶ | if ( defined( my $value = $arg_hash->{'event_if_expected'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 'value of "event_if_expected" must be a REF to an array of symbol names' | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ) if ref $value ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | for my $symbol_name ( @{$value} ) { | |||||||||||||||||||||||||||||||||||||||||
| 116 | 18 | my $symbol_id = $tracer->symbol_by_name($symbol_name); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 18 | ▶ | Marpa::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | qq{Unknown symbol in "event_if_expected" value: "$symbol_name"} | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ) if not defined $symbol_id; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 18 | $recce_c->expected_symbol_event_set( $symbol_id, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 121 | } ## end for my $symbol_name ( @{$value} ) | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | delete $arg_hash->{event_if_expected}; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } ## end if ( defined( my $value = $arg_hash->{'event_if_expected'...})) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } ## end ARG_HASH: for my $arg_hash (@arg_hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 226 | $recce->[Marpa::R2::Internal::Recognizer::WARNINGS] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 226 | $recce->[Marpa::R2::Internal::Recognizer::RANKING_METHOD] = 'none'; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 226 | $recce->[Marpa::R2::Internal::Recognizer::MAX_PARSES] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 226 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | # Position 0 is not used because 0 indicates an unvalued token. | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # Position 1 is reserved for undef. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # Position 2 is reserved for literal tokens (used in SLIF). | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 226 | $recce->[Marpa::R2::Internal::Recognizer::TOKEN_VALUES] = [undef, undef, undef]; | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 226 | $recce->reset_evaluation(); | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 226 | ▶ | if ( not $recce_c->start_input() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $error = $grammar_c->error(); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | Marpa::R2::exception( 'Recognizer start of input failed: ', $error ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 226 | $recce->[Marpa::R2::Internal::Recognizer::EVENTS] = cook_events($recce); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 226 | $recce->set(@arg_hashes); | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 226 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS] > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | my @terminals_expected = @{ $recce->terminals_expected() }; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | for my $terminal ( sort @terminals_expected ) { | |||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | say {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | qq{Expecting "$terminal" at earleme 0} | ||||||||||||||||||||||||||||||||||||||||||
| 151 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | } ## end if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS...]) | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 226 | return $recce; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } ## end sub Marpa::R2::Recognizer::new | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # Not documented, at least for the moment | ||||||||||||||||||||||||||||||||||||||||||
| 159 | sub Marpa::R2::Recognizer::grammar { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 31 | ▶ | $_[0]->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grammar: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | sub Marpa::R2::Recognizer::thin { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 4250 | ▶ | $_[0]->[Marpa::R2::Internal::Recognizer::C]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
thin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # For the non-legacy case, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | # I reset the ordering, forcing it to be recalculated | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # for each parse series. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # But I do not actually allow the ranking method to | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # be changed once a parse is created. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # Since I am stabilizing Marpa::R2, the "fix" should | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # probably be to save the overhead, rather than | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # to allow 'ranking_method' to be changed. | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # But for now I will do nothing. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # JK -- Mon Nov 24 17:35:24 PST 2014 | ||||||||||||||||||||||||||||||||||||||||||
| 177 | sub Marpa::R2::Recognizer::reset_evaluation { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 1306 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_evaluation: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1306 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 1306 | my $package_source = | |||||||||||||||||||||||||||||||||||||||||
| 181 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE]; | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1306 | ▶ | if ( defined $package_source and $package_source ne 'legacy' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $package_source and $package_source ne "legacy"
MC/DC100%2/2
defined $package_source and $package_source ne "legacy"
defined $package_source
$package_source ne "legacy"
Truth table100%3/3
A and B
A= defined $package_sourceB= $package_source ne "legacy"
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | # Packaage source, once legacy, stays legacy | ||||||||||||||||||||||||||||||||||||||||||
| 185 | # Otherwise, reset it | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 46 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] = | |||||||||||||||||||||||||||||||||||||||||
| 187 | undef; | ||||||||||||||||||||||||||||||||||||||||||
| 188 | } ## end if ( defined $package_source and $package_source ne ...) | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::NO_PARSE] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::ASF_OR_NODES] = []; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::B_C] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::EVENTS] = []; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::O_C] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::PER_PARSE_CONSTRUCTOR] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::READ_STRING_ERROR] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::NULL_VALUES] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::REGISTRATIONS] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_SYMBOL_ID] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURE_BY_RULE_ID] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::T_C] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 1306 | $recce->[Marpa::R2::Internal::Recognizer::TREE_MODE] = undef; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 1306 | return; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } ## end sub Marpa::R2::Recognizer::reset_evaluation | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | sub Marpa::R2::Recognizer::set { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 1330 | ▶ | my ( $recce, @arg_hashes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=51 SCAR=56.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 1330 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # This may get changed below | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 1330 | my $trace_fh = | |||||||||||||||||||||||||||||||||||||||||
| 214 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 1330 | for my $args (@arg_hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 1330 | my $ref_type = ref $args; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 1330 | ▶ | if ( not $ref_type or $ref_type ne 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $ref_type or $ref_type ne "HASH"
MC/DC0%0/2
not $ref_type or $ref_type ne "HASH"
not $ref_type
$ref_type ne "HASH"
Truth table33%1/3
not(A) or B
A= not $ref_typeB= $ref_type ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | Carp::croak( | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
"ref to $ref_type" || 'non-reference'
MC/DC0%0/1
"ref to $ref_type" || 'non-reference'
"ref to $ref_type"
Truth table0%0/2
A
A= "ref to $ref_type"
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 'Marpa::R2 Recognizer expects args as ref to HASH, got ', | ||||||||||||||||||||||||||||||||||||||||||
| 222 | ( "ref to $ref_type" || 'non-reference' ), | ||||||||||||||||||||||||||||||||||||||||||
| 223 | ' instead' | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } ## end if ( not $ref_type or $ref_type ne 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | state $recognizer_options = { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 1330 | map { ( $_, 1 ) } | |||||||||||||||||||||||||||||||||||||||||
| 229 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 230 | closures | ||||||||||||||||||||||||||||||||||||||||||
| 231 | end | ||||||||||||||||||||||||||||||||||||||||||
| 232 | event_if_expected | ||||||||||||||||||||||||||||||||||||||||||
| 233 | leo | ||||||||||||||||||||||||||||||||||||||||||
| 234 | max_parses | ||||||||||||||||||||||||||||||||||||||||||
| 235 | semantics_package | ||||||||||||||||||||||||||||||||||||||||||
| 236 | ranking_method | ||||||||||||||||||||||||||||||||||||||||||
| 237 | too_many_earley_items | ||||||||||||||||||||||||||||||||||||||||||
| 238 | trace_actions | ||||||||||||||||||||||||||||||||||||||||||
| 239 | trace_and_nodes | ||||||||||||||||||||||||||||||||||||||||||
| 240 | trace_bocage | ||||||||||||||||||||||||||||||||||||||||||
| 241 | trace_earley_sets | ||||||||||||||||||||||||||||||||||||||||||
| 242 | trace_fh | ||||||||||||||||||||||||||||||||||||||||||
| 243 | trace_file_handle | ||||||||||||||||||||||||||||||||||||||||||
| 244 | trace_or_nodes | ||||||||||||||||||||||||||||||||||||||||||
| 245 | trace_terminals | ||||||||||||||||||||||||||||||||||||||||||
| 246 | trace_values | ||||||||||||||||||||||||||||||||||||||||||
| 247 | warnings | ||||||||||||||||||||||||||||||||||||||||||
| 248 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 249 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 1330 | ▶ | if (my @bad_options = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 425 | grep { not exists $recognizer_options->{$_} } | |||||||||||||||||||||||||||||||||||||||||
| 253 | 1330 | keys %{$args} | |||||||||||||||||||||||||||||||||||||||||
| 254 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 255 | { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | Carp::croak( 'Unknown option(s) for Marpa::R2 Recognizer: ', | |||||||||||||||||||||||||||||||||||||||||
| 257 | join q{ }, @bad_options ); | ||||||||||||||||||||||||||||||||||||||||||
| 258 | } ## end if ( my @bad_options = grep { not exists $recognizer_options...}) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 1330 | ▶ | if ( defined( my $value = $args->{'event_if_expected'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | ## It could be allowed, but it is not needed and this is simpler | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 263 | q{'event_if_expected' not allowed once input has started}); | ||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 1330 | ▶ | if ( defined( my $value = $args->{'leo'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 268 | q{Cannot reset 'leo' once input has started}); | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 1330 | ▶ | if ( defined( my $value = $args->{'max_parses'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 84 | $recce->[Marpa::R2::Internal::Recognizer::MAX_PARSES] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 1330 | ▶ | if ( defined( my $value = $args->{'semantics_package'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # Not allowed once parsing is started | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 104 | ▶ | if ( defined $recce->[Marpa::R2::Internal::Recognizer::B_C] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 280 | q{Cannot change 'semantics_package' named argument once parsing has started} | ||||||||||||||||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 104 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce->[31] //= "semantics_package"
MC/DC0%0/1
$recce->[31] //= "semantics_package"
$recce->[31]
Truth table50%1/2
A
A= $recce->[31]
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | //= 'semantics_package'; | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 104 | ▶ | if ( $recce | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | ->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE_SOURCE] ne | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 'semantics_package' ) | ||||||||||||||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 291 | qq{'semantics_package' named argument in conflict with other choices\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 292 | qq{ Usually this means you tried to use the discouraged 'action_object' named argument as well\n} | ||||||||||||||||||||||||||||||||||||||||||
| 293 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } ## end if ( $recce->[...]) | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 104 | $recce->[Marpa::R2::Internal::Recognizer::RESOLVE_PACKAGE] = | |||||||||||||||||||||||||||||||||||||||||
| 296 | $value; | ||||||||||||||||||||||||||||||||||||||||||
| 297 | } ## end if ( defined( my $value = $args->{'semantics_package'...})) | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1330 | ▶ | if ( defined( my $value = $args->{'ranking_method'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | # Not allowed once parsing is started | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 96 | ▶ | if ( defined $recce->[Marpa::R2::Internal::Recognizer::B_C] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 304 | q{Cannot change ranking method once parsing has started}); | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 96 | state $ranking_methods = { map { ($_, 0) } qw(high_rule_only rule none) }; | |||||||||||||||||||||||||||||||||||||||||
| 307 | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||||
| 308 | qq{ranking_method value is $value (should be one of }, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ( join q{, }, map { q{'} . $_ . q{'} } keys %{$ranking_methods} ), | |||||||||||||||||||||||||||||||||||||||||
| 310 | ')' ) | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 96 | ▶ | if not exists $ranking_methods->{$value}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 96 | $recce->[Marpa::R2::Internal::Recognizer::RANKING_METHOD] = | |||||||||||||||||||||||||||||||||||||||||
| 313 | $value; | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } ## end if ( defined( my $value = $args->{'ranking_method'} ...)) | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_fh'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 4 | $trace_fh = | |||||||||||||||||||||||||||||||||||||||||
| 318 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE] = | ||||||||||||||||||||||||||||||||||||||||||
| 319 | $value; | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_file_handle'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 1 | $trace_fh = | |||||||||||||||||||||||||||||||||||||||||
| 324 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE] = | ||||||||||||||||||||||||||||||||||||||||||
| 325 | $value; | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_actions'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_ACTIONS] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | say {$trace_fh} 'Setting trace_actions option' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } ## end if ( defined( my $value = $args->{'trace_actions'} )) | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_and_nodes'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 'trace_and_nodes must be set to a number >= 0') | ||||||||||||||||||||||||||||||||||||||||||
| 339 | if $value !~ /\A\d+\z/xms; | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_AND_NODES] = | |||||||||||||||||||||||||||||||||||||||||
| 341 | $value + 0; | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | say {$trace_fh} "Setting trace_and_nodes option to $value" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } ## end if ( defined( my $value = $args->{'trace_and_nodes'}...)) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_bocage'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | Marpa::R2::exception('trace_bocage must be set to a number >= 0') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | if $value !~ /\A\d+\z/xms; | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_BOCAGE] = | |||||||||||||||||||||||||||||||||||||||||
| 352 | $value + 0; | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | say {$trace_fh} "Setting trace_bocage option to $value" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } ## end if ( defined( my $value = $args->{'trace_bocage'} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_or_nodes'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 'trace_or_nodes must be set to a number >= 0') | ||||||||||||||||||||||||||||||||||||||||||
| 362 | if $value !~ /\A\d+\z/xms; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_OR_NODES] = | |||||||||||||||||||||||||||||||||||||||||
| 364 | $value + 0; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | say {$trace_fh} "Setting trace_or_nodes option to $value" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } ## end if ( defined( my $value = $args->{'trace_or_nodes'} ...)) | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_terminals'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 5 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS] = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | Scalar::Util::looks_like_number($value) ? $value : 0; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 5 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 5 | ▶ | say {$trace_fh} 'Setting trace_terminals option' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } ## end if ( defined( my $value = $args->{'trace_terminals'}...)) | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_earley_sets'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_EARLEY_SETS] = | |||||||||||||||||||||||||||||||||||||||||
| 382 | $value; | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | say {$trace_fh} 'Setting trace_earley_sets option' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | } ## end if ( defined( my $value = $args->{'trace_earley_sets'...})) | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 1330 | ▶ | if ( defined( my $value = $args->{'trace_values'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 4 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_VALUES] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 391 | 4 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | ▶ | say {$trace_fh} 'Setting trace_values option' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | } ## end if ( defined( my $value = $args->{'trace_values'} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 1330 | ▶ | if ( defined( my $value = $args->{'end'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | # Not allowed once evaluation is started | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 90 | ▶ | if ( defined $recce->[Marpa::R2::Internal::Recognizer::B_C] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 402 | q{Cannot reset end once evaluation has started}); | ||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | 90 | $recce->[Marpa::R2::Internal::Recognizer::END_OF_PARSE] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } ## end if ( defined( my $value = $args->{'end'} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 1330 | ▶ | if ( defined( my $value = $args->{'closures'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | # Not allowed once evaluation is started | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 35 | ▶ | if ( defined $recce->[Marpa::R2::Internal::Recognizer::B_C] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 412 | q{Cannot reset closures once evaluation has started}); | ||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 35 | my $closures = | |||||||||||||||||||||||||||||||||||||||||
| 415 | $recce->[Marpa::R2::Internal::Recognizer::CLOSURES] = $value; | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 35 | for my $action ( keys %{$closures} ) { | |||||||||||||||||||||||||||||||||||||||||
| 417 | 2980 | my $closure = $closures->{$action}; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 2980 | ▶ | Marpa::R2::exception(qq{Bad closure for action "$action"}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | if ref $closure ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | } ## end if ( defined( my $value = $args->{'closures'} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 1330 | ▶ | if ( defined( my $value = $args->{'warnings'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $recce->[Marpa::R2::Internal::Recognizer::WARNINGS] = $value; | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 1330 | ▶ | if ( defined( my $value = $args->{'too_many_earley_items'} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 2 | $recce_c->earley_item_warning_threshold_set($value); | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | } ## end for my $args (@arg_hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 1330 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 434 | } ## end sub Marpa::R2::Recognizer::set | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | sub Marpa::R2::Recognizer::latest_earley_set { | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 9649 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
latest_earley_set: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 9649 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 9649 | return $recce_c->latest_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | sub Marpa::R2::Recognizer::check_terminal { | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | ▶ | my ( $recce, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_terminal: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | return $grammar->check_terminal($name); | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | sub Marpa::R2::Recognizer::exhausted { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 321 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exhausted: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 321 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 321 | return $recce_c->is_exhausted(); | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | sub Marpa::R2::Recognizer::current_earleme { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 1526 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_earleme: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 1526 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 1526 | return $recce_c->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | sub Marpa::R2::Recognizer::furthest_earleme { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
furthest_earleme: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | return $recce_c->furthest_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | sub Marpa::R2::Recognizer::earleme { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 1467 | ▶ | my ( $recce, $earley_set_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
earleme: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 1467 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 1467 | return $recce_c->earleme($earley_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | sub Marpa::R2::Recognizer::expected_symbol_event_set { | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 7 | ▶ | my ( $recce, $symbol_name, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expected_symbol_event_set: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | 7 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 7 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 7 | my $symbol_id = | |||||||||||||||||||||||||||||||||||||||||
| 477 | $grammar->[Marpa::R2::Internal::Grammar::TRACER] | ||||||||||||||||||||||||||||||||||||||||||
| 478 | ->symbol_by_name($symbol_name); | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 7 | ▶ | Marpa::exception(qq{Unknown symbol: "$symbol_name"}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | if not defined $symbol_id; | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 7 | return $recce_c->expected_symbol_event_set( $symbol_id, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } ## end sub Marpa::R2::Recognizer::expected_symbol_event_set | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | # Now useless and deprecated | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | sub Marpa::R2::Recognizer::strip { return 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strip: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | # Viewing methods, for debugging | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | sub Marpa::R2::Recognizer::progress { | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 207 | ▶ | my ( $recce, $ordinal_arg ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
progress: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 207 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 492 | 207 | my $latest_earley_set = $recce->latest_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 493 | 207 | my $ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 494 | SET_ORDINAL: { | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 207 | ▶ | if ( not defined $ordinal_arg ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | $ordinal = $latest_earley_set; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | last SET_ORDINAL; | |||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 204 | ▶ | if ( $ordinal_arg > $latest_earley_set ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 501 | qq{Argument out of bounds in recce->progress($ordinal_arg)\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 502 | qq{ Argument specifies Earley set after the latest Earley set 0\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 503 | qq{ The latest Earley set is Earley set $latest_earley_set\n} | ||||||||||||||||||||||||||||||||||||||||||
| 504 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 505 | } ## end if ( $ordinal_arg > $latest_earley_set ) | ||||||||||||||||||||||||||||||||||||||||||
| 506 | 204 | ▶ | if ( $ordinal_arg >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 196 | $ordinal = $ordinal_arg; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 196 | last SET_ORDINAL; | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | # If we are here, $ordinal_arg < 0 | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 8 | $ordinal = $latest_earley_set + 1 + $ordinal_arg; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 8 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | qq{Argument out of bounds in recce->progress($ordinal_arg)\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 515 | qq{ Argument specifies Earley set before Earley set 0\n} | ||||||||||||||||||||||||||||||||||||||||||
| 516 | ) if $ordinal < 0; | ||||||||||||||||||||||||||||||||||||||||||
| 517 | } ## end SET_ORDINAL: | ||||||||||||||||||||||||||||||||||||||||||
| 518 | 207 | my $result = []; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 207 | $recce_c->progress_report_start($ordinal); | |||||||||||||||||||||||||||||||||||||||||
| 520 | 207 | ITEM: while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 521 | 20704 | my @item = $recce_c->progress_item(); | |||||||||||||||||||||||||||||||||||||||||
| 522 | 20704 | ▶ | last ITEM if not defined $item[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 20497 | push @{$result}, [@item]; | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 207 | $recce_c->progress_report_finish(); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 207 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 527 | } ## end sub Marpa::R2::Recognizer::progress | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | sub Marpa::R2::Recognizer::show_progress { | ||||||||||||||||||||||||||||||||||||||||||
| 530 | 4 | ▶ | my ( $recce, $start_ordinal, $end_ordinal ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_progress: called CC=17 SCAR=28.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 4 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 4 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 4 | my $last_ordinal = $recce->latest_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 4 | ▶ | if ( not defined $start_ordinal ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 2 | $start_ordinal = $last_ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 4 | ▶ | if ( $start_ordinal < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $start_ordinal += $last_ordinal + 1; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 4 | ▶ | if ( $start_ordinal < 0 or $start_ordinal > $last_ordinal ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$start_ordinal < 0 or $start_ordinal > $last_ordinal
MC/DC0%0/2
$start_ordinal < 0 or $start_ordinal > $last_ordinal
$start_ordinal < 0
$start_ordinal > $last_ordinal
Truth table33%1/3
A or B
A= $start_ordinal < 0B= $start_ordinal > $last_ordinal
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | return | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | "Marpa::PP::Recognizer::show_progress start index is $start_ordinal, " | |||||||||||||||||||||||||||||||||||||||||
| 546 | . "must be in range 0-$last_ordinal"; | ||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } ## end else [ if ( $start_ordinal < 0 ) ] | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 4 | ▶ | if ( not defined $end_ordinal ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 3 | $end_ordinal = $start_ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||
| 553 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | my $end_ordinal_argument = $end_ordinal; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 1 | ▶ | if ( $end_ordinal < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | $end_ordinal += $last_ordinal + 1; | |||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | 1 | ▶ | if ( $end_ordinal < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 559 | return | ||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | "Marpa::PP::Recognizer::show_progress end index is $end_ordinal_argument, " | |||||||||||||||||||||||||||||||||||||||||
| 561 | . sprintf ' must be in range %d-%d', -( $last_ordinal + 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 562 | $last_ordinal; | ||||||||||||||||||||||||||||||||||||||||||
| 563 | } ## end if ( $end_ordinal < 0 ) | ||||||||||||||||||||||||||||||||||||||||||
| 564 | } ## end else [ if ( not defined $end_ordinal ) ] | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 4 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 567 | 4 | for my $current_ordinal ( $start_ordinal .. $end_ordinal ) { | |||||||||||||||||||||||||||||||||||||||||
| 568 | 7 | my $current_earleme = $recce->earleme($current_ordinal); | |||||||||||||||||||||||||||||||||||||||||
| 569 | 7 | my %by_rule_by_position = (); | |||||||||||||||||||||||||||||||||||||||||
| 570 | 7 | for my $progress_item ( @{ $recce->progress($current_ordinal) } ) { | |||||||||||||||||||||||||||||||||||||||||
| 571 | 55 | my ( $rule_id, $position, $origin ) = @{$progress_item}; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 55 | ▶ | if ( $position < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 34 | $position = $grammar_c->rule_length($rule_id); | |||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 55 | $by_rule_by_position{$rule_id}->{$position}->{$origin}++; | |||||||||||||||||||||||||||||||||||||||||
| 576 | } ## end for my $progress_item ( @{ $recce->progress($current_ordinal...)}) | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 7 | for my $rule_id ( sort { $a <=> $b } keys %by_rule_by_position ) { | |||||||||||||||||||||||||||||||||||||||||
| 579 | 21 | my $by_position = $by_rule_by_position{$rule_id}; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 21 | for my $position ( sort { $a <=> $b } keys %{$by_position} ) { | |||||||||||||||||||||||||||||||||||||||||
| 581 | 31 | my $raw_origins = $by_position->{$position}; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 31 | my @origins = sort { $a <=> $b } keys %{$raw_origins}; | |||||||||||||||||||||||||||||||||||||||||
| 583 | 31 | my $origins_count = scalar @origins; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 31 | my $origin_desc; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 31 | ▶ | if ( $origins_count <= 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 586 | 29 | $origin_desc = join q{,}, @origins; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 2 | $origin_desc = $origins[0] . q{...} . $origins[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 31 | my $rhs_length = $grammar_c->rule_length($rule_id); | |||||||||||||||||||||||||||||||||||||||||
| 593 | 31 | my $item_text; | |||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | # flag indicating whether we need to show the dot in the rule | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 31 | ▶ | if ( $position >= $rhs_length ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 14 | $item_text .= "F$rule_id"; | |||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||
| 599 | elsif ($position) { | ||||||||||||||||||||||||||||||||||||||||||
| 600 | 5 | $item_text .= "R$rule_id:$position"; | |||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 12 | $item_text .= "P$rule_id"; | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 31 | ▶ | $item_text .= " x$origins_count" if $origins_count > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | 31 | $item_text | |||||||||||||||||||||||||||||||||||||||||
| 607 | .= q{ @} . $origin_desc . q{-} . $current_earleme . q{ }; | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 31 | $item_text | |||||||||||||||||||||||||||||||||||||||||
| 609 | .= $grammar->show_dotted_rule( $rule_id, $position ); | ||||||||||||||||||||||||||||||||||||||||||
| 610 | 31 | $text .= $item_text . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 611 | } ## end for my $position ( sort { $a <=> $b } keys %{...}) | ||||||||||||||||||||||||||||||||||||||||||
| 612 | } ## end for my $rule_id ( sort { $a <=> $b } keys ...) | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | } ## end for my $current_ordinal ( $start_ordinal .. $end_ordinal) | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 4 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 616 | } ## end sub Marpa::R2::Recognizer::show_progress | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | sub Marpa::R2::Recognizer::read { | ||||||||||||||||||||||||||||||||||||||||||
| 619 | 10542 | ▶ | my $arg_count = scalar @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | 10542 | my ( $recce, $symbol_name, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 621 | 10542 | ▶ | return if not $recce->alternative( $symbol_name, \$value ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 10540 | return $recce->earleme_complete(); | |||||||||||||||||||||||||||||||||||||||||
| 623 | } ## end sub Marpa::R2::Recognizer::read | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | sub Marpa::R2::Recognizer::alternative { | ||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 12530 | ▶ | my ( $recce, $symbol_name, $value_ref, $length ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alternative: called CC=19 SCAR=30.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 12530 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $recce or ref $recce ne "Marpa::R2::Recognizer"
MC/DC0%0/2
not defined $recce or ref $recce ne "Marpa::R2::Recognizer"
not defined $recce
ref $recce ne "Marpa::R2::Recognizer"
Truth table33%1/3
not(A) or B
A= not defined $recceB= ref $recce ne "Marpa::R2::Recognizer"
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | 'No recognizer object for Marpa::R2::Recognizer::tokens') | ||||||||||||||||||||||||||||||||||||||||||
| 631 | if not defined $recce | ||||||||||||||||||||||||||||||||||||||||||
| 632 | or ref $recce ne 'Marpa::R2::Recognizer'; | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | 12530 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | "recce->alternative(): symbol name is undefined\n", | ||||||||||||||||||||||||||||||||||||||||||
| 636 | " The symbol name cannot be undefined\n" | ||||||||||||||||||||||||||||||||||||||||||
| 637 | ) if not defined $symbol_name; | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 12530 | ▶ | Marpa::R2::exception('Attempt to read token after parsing is finished') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | if $recce->[Marpa::R2::Internal::Recognizer::FINISHED]; | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 12530 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 643 | 12530 | my $trace_fh = | |||||||||||||||||||||||||||||||||||||||||
| 644 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 12530 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 12530 | my $token_values = | |||||||||||||||||||||||||||||||||||||||||
| 647 | $recce->[Marpa::R2::Internal::Recognizer::TOKEN_VALUES]; | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 12530 | my $symbol_id = | |||||||||||||||||||||||||||||||||||||||||
| 649 | $grammar->[Marpa::R2::Internal::Grammar::TRACER] | ||||||||||||||||||||||||||||||||||||||||||
| 650 | ->symbol_by_name($symbol_name); | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 12530 | ▶ | if ( not defined $symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||||||||||||||||
| 654 | qq{alternative(): symbol "$symbol_name" does not exist}); | ||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | 12530 | my $value_ix = 1; # undef | |||||||||||||||||||||||||||||||||||||||||
| 658 | SET_VALUE_IX: { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 12530 | ▶ | last SET_VALUE_IX if not defined $value_ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | 12260 | my $ref_type = ref $value_ref; | |||||||||||||||||||||||||||||||||||||||||
| 661 | 12260 | ▶ | if ( $ref_type ne 'SCALAR' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ref_type ne "SCALAR" and $ref_type ne "REF" and $ref_type ne "VSTRING"
$ref_type ne "SCALAR" and $ref_type ne "REF"
MC/DC0%0/3
$ref_type ne "SCALAR" and $ref_type ne "REF" and $ref_type ne "VSTRING"
$ref_type ne "SCALAR"
$ref_type ne "REF"
$ref_type ne "VSTRING"
Truth table25%1/4
A and B and C
A= $ref_type ne "SCALAR"B= $ref_type ne "REF"C= $ref_type ne "VSTRING"
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | and $ref_type ne 'REF' | ||||||||||||||||||||||||||||||||||||||||||
| 663 | and $ref_type ne 'VSTRING' ) | ||||||||||||||||||||||||||||||||||||||||||
| 664 | { | ||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | Marpa::R2::exception('alternative(): value must be undef or ref'); | |||||||||||||||||||||||||||||||||||||||||
| 666 | } ## end if ( $ref_type ne 'SCALAR' and $ref_type ne 'REF' and...) | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 12260 | my $value = ${$value_ref}; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 12260 | ▶ | last SET_VALUE_IX if not defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 669 | 11915 | $value_ix = scalar @{$token_values}; | |||||||||||||||||||||||||||||||||||||||||
| 670 | 11915 | push @{$token_values}, $value; | |||||||||||||||||||||||||||||||||||||||||
| 671 | } ## end SET_VALUE_IX: | ||||||||||||||||||||||||||||||||||||||||||
| 672 | 12530 | ▶ | $length //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$length //= 1
MC/DC100%1/1
$length //= 1
$length
Truth table100%2/2
A
A= $length
| |||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | # value_ix is *never* zero. | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 12530 | my $result = $recce_c->alternative( $symbol_id, $value_ix, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 12530 | my $trace_terminals = | |||||||||||||||||||||||||||||||||||||||||
| 678 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS]; | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 12530 | ▶ | if ($trace_terminals) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 13 | ▶ | my $verb = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 681 | $result == $Marpa::R2::Error::NONE ? 'Accepted' : 'Rejected'; | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 13 | my $current_earleme = $recce_c->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 683 | 13 | ▶ | say {$trace_fh} qq{$verb "$symbol_name" at $current_earleme-} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | . ( $length + $current_earleme ) | ||||||||||||||||||||||||||||||||||||||||||
| 685 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 686 | } ## end if ($trace_terminals) | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 12530 | ▶ | return 1 if $result == $Marpa::R2::Error::NONE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | # The last two are perhaps unnecessary or arguable, | ||||||||||||||||||||||||||||||||||||||||||
| 691 | # but they preserve compatibility with Marpa::XS | ||||||||||||||||||||||||||||||||||||||||||
| 692 | return | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 285 | ▶ | if $result == $Marpa::R2::Error::UNEXPECTED_TOKEN_ID | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$result == $Marpa::R2::Error::UNEXPECTED_TOKEN_ID or $result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HERE or $result == $Marpa::R2::Error::INACCESSIBLE_TOKEN
$result == $Marpa::R2::Error::UNEXPECTED_TOKEN_ID or $result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HERE
MC/DC66%2/3
$result == $Marpa::R2::Error::UNEXPECTED_TOKEN_ID or $result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HERE or $result == $Marpa::R2::Error::INACCESSIBLE_TOKEN
$result == $Marpa::R2::Error::UNEXPECTED_TOKEN_ID
$result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HERE
$result == $Marpa::R2::Error::INACCESSIBLE_TOKEN
Truth table75%3/4
A or B or C
A= $result == $Marpa::R2::Error::UNEXPECTED_TOKEN_IDB= $result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HEREC= $result == $Marpa::R2::Error::INACCESSIBLE_TOKEN
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | || $result == $Marpa::R2::Error::NO_TOKEN_EXPECTED_HERE | ||||||||||||||||||||||||||||||||||||||||||
| 695 | || $result == $Marpa::R2::Error::INACCESSIBLE_TOKEN; | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 3 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 3 | Marpa::R2::exception( $grammar_c->error() ); | |||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | } ## end sub Marpa::R2::Recognizer::alternative | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | # Perform the completion step on an earley set | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | sub Marpa::R2::Recognizer::end_input { | ||||||||||||||||||||||||||||||||||||||||||
| 705 | 110 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_input: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 110 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 707 | 110 | my $furthest_earleme = $recce_c->furthest_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 708 | 110 | ▶ | while ( $recce_c->current_earleme() < $furthest_earleme ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 20030 | $recce->earleme_complete(); | |||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 110 | $recce->[Marpa::R2::Internal::Recognizer::FINISHED] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 110 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } ## end sub Marpa::R2::Recognizer::end_input | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | sub Marpa::R2::Recognizer::terminals_expected { | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 1317 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
terminals_expected: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | 1317 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 718 | 1317 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 719 | 1317 | return [ map { $grammar->symbol_name($_) } | |||||||||||||||||||||||||||||||||||||||||
| 720 | $recce_c->terminals_expected() ]; | ||||||||||||||||||||||||||||||||||||||||||
| 721 | } ## end sub Marpa::R2::Recognizer::terminals_expected | ||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | sub cook_events { | ||||||||||||||||||||||||||||||||||||||||||
| 724 | 306 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cook_events: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | 306 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 726 | 306 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 727 | 306 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 306 | my @cooked_events = (); | |||||||||||||||||||||||||||||||||||||||||
| 730 | 306 | my $event_count = $grammar_c->event_count(); | |||||||||||||||||||||||||||||||||||||||||
| 731 | 306 | ▶ | EVENT: for ( my $event_ix = 0; $event_ix < $event_count; $event_ix++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | 116 | my ( $event_type, $value ) = $grammar_c->event($event_ix); | |||||||||||||||||||||||||||||||||||||||||
| 733 | 116 | ▶ | if ( $event_type eq 'MARPA_EVENT_EARLEY_ITEM_THRESHOLD' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | say { | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 5 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE] } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | "Earley item count ($value) exceeds warning threshold" | ||||||||||||||||||||||||||||||||||||||||||
| 737 | or die "say: $ERRNO"; | ||||||||||||||||||||||||||||||||||||||||||
| 738 | 5 | push @cooked_events, ['EARLEY_ITEM_THRESHOLD']; | |||||||||||||||||||||||||||||||||||||||||
| 739 | 5 | next EVENT; | |||||||||||||||||||||||||||||||||||||||||
| 740 | } ## end if ( $event_type eq 'MARPA_EVENT_EARLEY_ITEM_THRESHOLD') | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 111 | ▶ | if ( $event_type eq 'MARPA_EVENT_SYMBOL_EXPECTED' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | 78 | push @cooked_events, | |||||||||||||||||||||||||||||||||||||||||
| 743 | [ 'SYMBOL_EXPECTED', $grammar->symbol_name($value) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 744 | 78 | next EVENT; | |||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 33 | ▶ | if ( $event_type eq 'MARPA_EVENT_EXHAUSTED' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 33 | push @cooked_events, ['EXHAUSTED']; | |||||||||||||||||||||||||||||||||||||||||
| 748 | 33 | next EVENT; | |||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | } ## end EVENT: for ( my $event_ix = 0; $event_ix < $event_count; ...) | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 306 | return \@cooked_events; | |||||||||||||||||||||||||||||||||||||||||
| 752 | } ## end sub cook_events | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | sub Marpa::R2::Recognizer::earleme_complete { | ||||||||||||||||||||||||||||||||||||||||||
| 755 | 30670 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
earleme_complete: called CC=8 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 30670 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 758 | 30670 | local $Marpa::R2::Internal::TRACE_FH = | |||||||||||||||||||||||||||||||||||||||||
| 759 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_FILE_HANDLE]; | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 30670 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 761 | 30670 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 30670 | my $event_count = $recce_c->earleme_complete(); | |||||||||||||||||||||||||||||||||||||||||
| 764 | 30670 | ▶ | $recce->[Marpa::R2::Internal::Recognizer::EVENTS] = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 765 | $event_count ? cook_events($recce) : []; | ||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 30670 | ▶ | if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_EARLEY_SETS] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $latest_set = $recce_c->latest_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} "=== Earley set $latest_set\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | print {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | Marpa::R2::show_earley_set($recce, $latest_set) | ||||||||||||||||||||||||||||||||||||||||||
| 773 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 774 | } ## end if ( $recce->[Marpa::R2::Internal::Recognizer::TRACE_EARLEY_SETS...]) | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 30670 | my $trace_terminals = | |||||||||||||||||||||||||||||||||||||||||
| 777 | $recce->[Marpa::R2::Internal::Recognizer::TRACE_TERMINALS]; | ||||||||||||||||||||||||||||||||||||||||||
| 778 | 30670 | ▶ | if ( $trace_terminals > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 779 | 3 | my $current_earleme = $recce_c->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 780 | 3 | my $terminals_expected = $recce->terminals_expected(); | |||||||||||||||||||||||||||||||||||||||||
| 781 | 3 | for my $terminal ( @{$terminals_expected} ) { | |||||||||||||||||||||||||||||||||||||||||
| 782 | 3 | ▶ | say {$Marpa::R2::Internal::TRACE_FH} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | qq{Expecting "$terminal" at $current_earleme} | ||||||||||||||||||||||||||||||||||||||||||
| 784 | or Marpa::R2::exception("Cannot print: $ERRNO"); | ||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 786 | } ## end if ( $trace_terminals > 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 30670 | return $event_count; | |||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | } ## end sub Marpa::R2::Recognizer::earleme_complete | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | sub Marpa::R2::Recognizer::events { | ||||||||||||||||||||||||||||||||||||||||||
| 793 | 101 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
events: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | 101 | return $recce->[Marpa::R2::Internal::Recognizer::EVENTS]; | |||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 150 | my @escape_by_ord = (); | |||||||||||||||||||||||||||||||||||||||||
| 798 | 150 | $escape_by_ord[ ord q{\\} ] = q{\\\\}; | |||||||||||||||||||||||||||||||||||||||||
| 799 | $escape_by_ord[ ord eval qq{"$_"} ] = $_ | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 150 | for "\\t", "\\r", "\\f", "\\b", "\\a", "\\e"; | |||||||||||||||||||||||||||||||||||||||||
| 801 | 150 | $escape_by_ord[0xa] = '\\n'; | |||||||||||||||||||||||||||||||||||||||||
| 802 | 150 | ▶ | $escape_by_ord[$_] //= chr $_ for 32 .. 126; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$escape_by_ord[$_] //= chr $_
MC/DC100%2/2
$escape_by_ord[$_] //= chr $_
$escape_by_ord[$_]
chr $_
Truth table100%3/3
A //= B
A= $escape_by_ord[$_]B= chr $_
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 150 | ▶ | $escape_by_ord[$_] //= sprintf( "\\x%02x", $_ ) for 0 .. 255; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$escape_by_ord[$_] //= sprintf("\\x%02x", $_)
MC/DC0%0/2
$escape_by_ord[$_] //= sprintf("\\x%02x", $_)
$escape_by_ord[$_]
sprintf("\\x%02x", $_)
Truth table66%2/3
A //= B
A= $escape_by_ord[$_]B= sprintf("\\x%02x", $_)
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | sub Marpa::R2::escape_string { | ||||||||||||||||||||||||||||||||||||||||||
| 806 | 18 | ▶ | my ( $string, $length ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escape_string: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 807 | 18 | my $reversed = $length < 0; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 18 | ▶ | if ($reversed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | 9 | $string = reverse $string; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 9 | $length = -$length; | |||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||
| 812 | 18 | my @escaped_chars = (); | |||||||||||||||||||||||||||||||||||||||||
| 813 | 18 | ORD: for my $ord ( map {ord} split //xms, $string ) { | |||||||||||||||||||||||||||||||||||||||||
| 814 | 127 | ▶ | last ORD if $length <= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | 127 | ▶ | my $escaped_char = $escape_by_ord[$ord] // sprintf( "\\x{%04x}", $ord ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$escape_by_ord[$ord] // sprintf("\\x{%04x}", $ord)
MC/DC0%0/2
$escape_by_ord[$ord] // sprintf("\\x{%04x}", $ord)
$escape_by_ord[$ord]
sprintf("\\x{%04x}", $ord)
Truth table66%2/3
A // B
A= $escape_by_ord[$ord]B= sprintf("\\x{%04x}", $ord)
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 127 | $length -= length $escaped_char; | |||||||||||||||||||||||||||||||||||||||||
| 817 | 127 | push @escaped_chars, $escaped_char; | |||||||||||||||||||||||||||||||||||||||||
| 818 | } ## end for my $ord ( map {ord} split //xms, $string ) | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 18 | ▶ | @escaped_chars = reverse @escaped_chars if $reversed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | 18 | IX: for my $ix ( reverse 0 .. $#escaped_chars ) { | |||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | # only trailing spaces are escaped | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 28 | ▶ | last IX if $escaped_chars[$ix] ne q{ }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 824 | 10 | $escaped_chars[$ix] = '\\s'; | |||||||||||||||||||||||||||||||||||||||||
| 825 | } ## end IX: for my $ix ( reverse 0 .. $#escaped_chars ) | ||||||||||||||||||||||||||||||||||||||||||
| 826 | 18 | return join q{}, @escaped_chars; | |||||||||||||||||||||||||||||||||||||||||
| 827 | } ## end sub escape_string | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | # INTERNAL OK AFTER HERE _marpa_ | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | sub Marpa::R2::Recognizer::use_leo_set { | ||||||||||||||||||||||||||||||||||||||||||
| 832 | 7 | ▶ | my ( $recce, $boolean ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
use_leo_set: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | 7 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 834 | 7 | return $recce_c->_marpa_r_is_use_leo_set($boolean); | |||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | # Not intended to be documented. | ||||||||||||||||||||||||||||||||||||||||||
| 838 | # Returns the size of the last completed earley set. | ||||||||||||||||||||||||||||||||||||||||||
| 839 | # For testing, especially that the Leo items | ||||||||||||||||||||||||||||||||||||||||||
| 840 | # are doing their job. | ||||||||||||||||||||||||||||||||||||||||||
| 841 | sub Marpa::R2::Recognizer::earley_set_size { | ||||||||||||||||||||||||||||||||||||||||||
| 842 | 179 | ▶ | my ( $recce, $set_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
earley_set_size: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 179 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 179 | ▶ | $set_id //= $recce_c->latest_earley_set(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$set_id //= $recce_c->latest_earley_set
MC/DC0%0/2
$set_id //= $recce_c->latest_earley_set
$set_id
$recce_c->latest_earley_set
Truth table33%1/3
A //= B
A= $set_idB= $recce_c->latest_earley_set
| |||||||||||||||||||||||||||||||||||||||||||
| 845 | 179 | return $recce_c->_marpa_r_earley_set_size($set_id); | |||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | sub ahm_describe { | ||||||||||||||||||||||||||||||||||||||||||
| 849 | 1994 | ▶ | my ($recce, $ahm_id) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ahm_describe: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | 1994 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 851 | 1994 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 852 | 1994 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 1994 | my $irl_id = $grammar_c->_marpa_g_ahm_irl($ahm_id); | |||||||||||||||||||||||||||||||||||||||||
| 854 | 1994 | my $dot_position = $grammar_c->_marpa_g_ahm_position($ahm_id); | |||||||||||||||||||||||||||||||||||||||||
| 855 | 1994 | ▶ | if ($dot_position < 0) { return 'R' . $irl_id . q{$} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | 1301 | return 'R' . $irl_id . q{:} . $dot_position; | |||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | sub Marpa::R2::show_lim { | ||||||||||||||||||||||||||||||||||||||||||
| 860 | 670 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_lim: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | 670 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 862 | 670 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 863 | 670 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||
| 864 | 670 | my $leo_base_state = $recce_c->_marpa_r_leo_base_state(); | |||||||||||||||||||||||||||||||||||||||||
| 865 | 670 | ▶ | return if not defined $leo_base_state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | 188 | my $trace_earley_set = $recce_c->_marpa_r_trace_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 867 | 188 | my $trace_earleme = $recce_c->earleme($trace_earley_set); | |||||||||||||||||||||||||||||||||||||||||
| 868 | 188 | my $postdot_symbol_id = $recce_c->_marpa_r_postdot_item_symbol(); | |||||||||||||||||||||||||||||||||||||||||
| 869 | 188 | my $postdot_symbol_name = $tracer->isy_name($postdot_symbol_id); | |||||||||||||||||||||||||||||||||||||||||
| 870 | 188 | my $predecessor_symbol_id = $recce_c->_marpa_r_leo_predecessor_symbol(); | |||||||||||||||||||||||||||||||||||||||||
| 871 | 188 | my $base_origin_set_id = $recce_c->_marpa_r_leo_base_origin(); | |||||||||||||||||||||||||||||||||||||||||
| 872 | 188 | my $base_origin_earleme = $recce_c->earleme($base_origin_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | 188 | my $text = sprintf 'L%d@%d', $postdot_symbol_id, $trace_earleme; | |||||||||||||||||||||||||||||||||||||||||
| 875 | 188 | my @link_texts = qq{"$postdot_symbol_name"}; | |||||||||||||||||||||||||||||||||||||||||
| 876 | 188 | ▶ | if ( defined $predecessor_symbol_id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 877 | 185 | push @link_texts, sprintf 'L%d@%d', $predecessor_symbol_id, | |||||||||||||||||||||||||||||||||||||||||
| 878 | $base_origin_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||
| 880 | 188 | push @link_texts, sprintf 'S%d@%d-%d', $leo_base_state, | |||||||||||||||||||||||||||||||||||||||||
| 881 | $base_origin_earleme, | ||||||||||||||||||||||||||||||||||||||||||
| 882 | $trace_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 188 | $text .= ' [' . ( join '; ', @link_texts ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 884 | 188 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 885 | } ## end sub Marpa::R2::show_lim | ||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | sub Marpa::R2::show_leo_item { | ||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_leo_item: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | my $leo_base_state = $recce_c->_marpa_r_leo_base_state(); | |||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | return if not defined $leo_base_state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | my $trace_earley_set = $recce_c->_marpa_r_trace_earley_set(); | |||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | my $trace_earleme = $recce_c->earleme($trace_earley_set); | |||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | my $postdot_symbol_id = $recce_c->_marpa_r_postdot_item_symbol(); | |||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | my $postdot_symbol_name = $tracer->isy_name($postdot_symbol_id); | |||||||||||||||||||||||||||||||||||||||||
| 898 | # my $predecessor_symbol_id = $recce_c->_marpa_r_leo_predecessor_symbol(); | ||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $base_origin_set_id = $recce_c->_marpa_r_leo_base_origin(); | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $base_origin_earleme = $recce_c->earleme($base_origin_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | my $text = sprintf 'L@%d', $trace_earleme; | |||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | my @link_texts = ('-'); | |||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | push @link_texts, qq{"$postdot_symbol_name"}; | |||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | push @link_texts, "$base_origin_earleme"; | |||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $text .= ' [' . ( join '; ', @link_texts ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 908 | } ## end sub Marpa::R2::show_leo_item | ||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||
| 910 | # Assumes trace token source link set by caller | ||||||||||||||||||||||||||||||||||||||||||
| 911 | sub Marpa::R2::show_token_link_choice { | ||||||||||||||||||||||||||||||||||||||||||
| 912 | 101 | ▶ | my ( $recce, $current_earleme ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_token_link_choice: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 101 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 914 | 101 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 915 | 101 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 916 | 101 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||
| 917 | 101 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 918 | 101 | my @pieces = (); | |||||||||||||||||||||||||||||||||||||||||
| 919 | 101 | my ( $token_id, $value_ix ) = $recce_c->_marpa_r_source_token(); | |||||||||||||||||||||||||||||||||||||||||
| 920 | 101 | my $predecessor_ahm = $recce_c->_marpa_r_source_predecessor_state(); | |||||||||||||||||||||||||||||||||||||||||
| 921 | 101 | my $origin_set_id = $recce_c->_marpa_r_earley_item_origin(); | |||||||||||||||||||||||||||||||||||||||||
| 922 | 101 | my $origin_earleme = $recce_c->earleme($origin_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 923 | 101 | my $middle_earleme = $origin_earleme; | |||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 101 | ▶ | if ( defined $predecessor_ahm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | 101 | my $middle_set_id = $recce_c->_marpa_r_source_middle(); | |||||||||||||||||||||||||||||||||||||||||
| 927 | 101 | $middle_earleme = $recce_c->earleme($middle_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 928 | 101 | push @pieces, | |||||||||||||||||||||||||||||||||||||||||
| 929 | 'c=' | ||||||||||||||||||||||||||||||||||||||||||
| 930 | . ahm_describe($recce, $predecessor_ahm) | ||||||||||||||||||||||||||||||||||||||||||
| 931 | . q{@} | ||||||||||||||||||||||||||||||||||||||||||
| 932 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||
| 933 | . $middle_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 934 | } ## end if ( defined $predecessor_ahm ) | ||||||||||||||||||||||||||||||||||||||||||
| 935 | 101 | my $symbol_name = $tracer->isy_name($token_id); | |||||||||||||||||||||||||||||||||||||||||
| 936 | 101 | push @pieces, 's=' . $symbol_name; | |||||||||||||||||||||||||||||||||||||||||
| 937 | 101 | my $token_length = $current_earleme - $middle_earleme; | |||||||||||||||||||||||||||||||||||||||||
| 938 | 101 | my $value = | |||||||||||||||||||||||||||||||||||||||||
| 939 | $recce->[Marpa::R2::Internal::Recognizer::TOKEN_VALUES]->[$value_ix]; | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 101 | my $token_dump = Data::Dumper->new( [ \$value ] )->Terse(1)->Dump; | |||||||||||||||||||||||||||||||||||||||||
| 941 | 101 | chomp $token_dump; | |||||||||||||||||||||||||||||||||||||||||
| 942 | 101 | push @pieces, "t=$token_dump"; | |||||||||||||||||||||||||||||||||||||||||
| 943 | 101 | return '[' . ( join '; ', @pieces ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 944 | } ## end sub Marpa::R2::show_token_link_choice | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | # Assumes trace completion source link set by caller | ||||||||||||||||||||||||||||||||||||||||||
| 947 | sub Marpa::R2::show_completion_link_choice { | ||||||||||||||||||||||||||||||||||||||||||
| 948 | 236 | ▶ | my ( $recce, $link_ahm_id, $current_earleme ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_completion_link_choice: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 949 | 236 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 950 | 236 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 951 | 236 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 952 | 236 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||
| 953 | 236 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 954 | 236 | my @pieces = (); | |||||||||||||||||||||||||||||||||||||||||
| 955 | 236 | my $predecessor_state = $recce_c->_marpa_r_source_predecessor_state(); | |||||||||||||||||||||||||||||||||||||||||
| 956 | 236 | my $origin_set_id = $recce_c->_marpa_r_earley_item_origin(); | |||||||||||||||||||||||||||||||||||||||||
| 957 | 236 | my $origin_earleme = $recce_c->earleme($origin_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 958 | 236 | my $middle_set_id = $recce_c->_marpa_r_source_middle(); | |||||||||||||||||||||||||||||||||||||||||
| 959 | 236 | my $middle_earleme = $recce_c->earleme($middle_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | 236 | ▶ | if ( defined $predecessor_state ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 962 | 236 | push @pieces, | |||||||||||||||||||||||||||||||||||||||||
| 963 | 'p=' | ||||||||||||||||||||||||||||||||||||||||||
| 964 | . ahm_describe($recce, $predecessor_state) . q{@} | ||||||||||||||||||||||||||||||||||||||||||
| 965 | . $origin_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||
| 966 | . $middle_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 967 | } ## end if ( defined $predecessor_state ) | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 236 | push @pieces, | |||||||||||||||||||||||||||||||||||||||||
| 969 | 'c=' . ahm_describe($recce, $link_ahm_id) . q{@} | ||||||||||||||||||||||||||||||||||||||||||
| 970 | . $middle_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||
| 971 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 972 | 236 | return '[' . ( join '; ', @pieces ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 973 | } ## end sub Marpa::R2::show_completion_link_choice | ||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | # Assumes trace completion source link set by caller | ||||||||||||||||||||||||||||||||||||||||||
| 976 | sub Marpa::R2::show_leo_link_choice { | ||||||||||||||||||||||||||||||||||||||||||
| 977 | 27 | ▶ | my ( $recce, $link_ahm_id, $current_earleme ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_leo_link_choice: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 978 | 27 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 979 | 27 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 980 | 27 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 981 | 27 | my $symbols = $grammar->[Marpa::R2::Internal::Grammar::SYMBOLS]; | |||||||||||||||||||||||||||||||||||||||||
| 982 | 27 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 27 | my @pieces = (); | |||||||||||||||||||||||||||||||||||||||||
| 984 | 27 | my $middle_set_id = $recce_c->_marpa_r_source_middle(); | |||||||||||||||||||||||||||||||||||||||||
| 985 | 27 | my $middle_earleme = $recce_c->earleme($middle_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 986 | 27 | my $leo_transition_symbol = | |||||||||||||||||||||||||||||||||||||||||
| 987 | $recce_c->_marpa_r_source_leo_transition_symbol(); | ||||||||||||||||||||||||||||||||||||||||||
| 988 | 27 | push @pieces, 'l=L' . $leo_transition_symbol . q{@} . $middle_earleme; | |||||||||||||||||||||||||||||||||||||||||
| 989 | 27 | push @pieces, | |||||||||||||||||||||||||||||||||||||||||
| 990 | 'c=' . ahm_describe($recce, $link_ahm_id) | ||||||||||||||||||||||||||||||||||||||||||
| 991 | . q{@} | ||||||||||||||||||||||||||||||||||||||||||
| 992 | . $middle_earleme . q{-} | ||||||||||||||||||||||||||||||||||||||||||
| 993 | . $current_earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 27 | return '[' . ( join '; ', @pieces ) . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 995 | } ## end sub Marpa::R2::show_leo_link_choice | ||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||
| 997 | # Assumes trace earley item was set by caller | ||||||||||||||||||||||||||||||||||||||||||
| 998 | sub Marpa::R2::show_earley_item { | ||||||||||||||||||||||||||||||||||||||||||
| 999 | 770 | ▶ | my ( $recce, $current_es, $item_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_earley_item: called CC=14 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 770 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | 770 | my $grammar = $recce->[Marpa::R2::Internal::Recognizer::GRAMMAR]; | |||||||||||||||||||||||||||||||||||||||||
| 1002 | 770 | my $grammar_c = $grammar->[Marpa::R2::Internal::Grammar::C]; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 770 | my $tracer = $grammar->[Marpa::R2::Internal::Grammar::TRACER]; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 770 | my $ahm_id_of_yim = $recce_c->_marpa_r_earley_item_trace($item_id); | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 770 | ▶ | return if not defined $ahm_id_of_yim; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 697 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 1009 | 697 | my $origin_set_id = $recce_c->_marpa_r_earley_item_origin(); | |||||||||||||||||||||||||||||||||||||||||
| 1010 | 697 | my $earleme = $recce_c->earleme($current_es); | |||||||||||||||||||||||||||||||||||||||||
| 1011 | 697 | my $origin_earleme = $recce_c->earleme($origin_set_id); | |||||||||||||||||||||||||||||||||||||||||
| 1012 | 697 | $text .= sprintf "ahm%d: %s@%d-%d", $ahm_id_of_yim, | |||||||||||||||||||||||||||||||||||||||||
| 1013 | ahm_describe($recce, $ahm_id_of_yim), | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | $origin_earleme, $earleme; | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | 697 | my @lines = $text; | |||||||||||||||||||||||||||||||||||||||||
| 1016 | 697 | my $irl_id = $grammar_c->_marpa_g_ahm_irl($ahm_id_of_yim); | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 697 | my $dot_position = $grammar_c->_marpa_g_ahm_position($ahm_id_of_yim); | |||||||||||||||||||||||||||||||||||||||||
| 1018 | 697 | push @lines, qq{ } | |||||||||||||||||||||||||||||||||||||||||
| 1019 | . ahm_describe($recce, $ahm_id_of_yim) | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | . q{: } | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | . $tracer->show_dotted_irl($irl_id, $dot_position); | ||||||||||||||||||||||||||||||||||||||||||
| 1022 | 697 | my @sort_data = (); | |||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||
| 1024 | 697 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1025 | my $symbol_id = $recce_c->_marpa_r_first_token_link_trace(); | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | defined $symbol_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | $symbol_id = $recce_c->_marpa_r_next_token_link_trace() | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | 101 | ▶ | push @sort_data, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce_c->_marpa_r_source_predecessor_state // -1
MC/DC0%0/1
$recce_c->_marpa_r_source_predecessor_state // -1
$recce_c->_marpa_r_source_predecessor_state
Truth table50%1/2
A
A= $recce_c->_marpa_r_source_predecessor_state
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | $recce_c->_marpa_r_source_middle(), | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | $symbol_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | ( $recce_c->_marpa_r_source_predecessor_state() // -1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | Marpa::R2::show_token_link_choice( $recce, $earleme ) | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | } ## end for ( my $symbol_id = $recce_c->_marpa_r_first_token_link_trace...) | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | 101 | my @pieces = map { $_->[-1] } sort { | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 697 | ▶ | $a->[0] <=> $b->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
MC/DC0%0/2
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]
$Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
Truth table0%0/3
A or B
A= $Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]B= $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 1040 | || $a->[1] <=> $b->[1] | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | || $a->[2] <=> $b->[2] | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | } @sort_data; | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | 697 | @sort_data = (); | |||||||||||||||||||||||||||||||||||||||||
| 1044 | 697 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1045 | my $cause_AHFA_id = $recce_c->_marpa_r_first_completion_link_trace(); | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | defined $cause_AHFA_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | $cause_AHFA_id = $recce_c->_marpa_r_next_completion_link_trace() | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | 236 | ▶ | push @sort_data, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$recce_c->_marpa_r_source_predecessor_state // -1
MC/DC0%0/1
$recce_c->_marpa_r_source_predecessor_state // -1
$recce_c->_marpa_r_source_predecessor_state
Truth table50%1/2
A
A= $recce_c->_marpa_r_source_predecessor_state
| |||||||||||||||||||||||||||||||||||||||||||
| 1051 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | $recce_c->_marpa_r_source_middle(), | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | $cause_AHFA_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | ( $recce_c->_marpa_r_source_predecessor_state() // -1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | Marpa::R2::show_completion_link_choice( | ||||||||||||||||||||||||||||||||||||||||||
| 1056 | $recce, $cause_AHFA_id, $earleme | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | } ## end for ( my $cause_AHFA_id = $recce_c...) | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | 236 | push @pieces, map { $_->[-1] } sort { | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 697 | ▶ | $a->[0] <=> $b->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
MC/DC0%0/2
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]
$Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
Truth table66%2/3
A or B
A= $Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]B= $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 1062 | || $a->[1] <=> $b->[1] | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | || $a->[2] <=> $b->[2] | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | } @sort_data; | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | 697 | @sort_data = (); | |||||||||||||||||||||||||||||||||||||||||
| 1066 | 697 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | my $link_ahm_id = $recce_c->_marpa_r_first_leo_link_trace(); | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | defined $link_ahm_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | $link_ahm_id = $recce_c->_marpa_r_next_leo_link_trace() | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | 27 | push @sort_data, | |||||||||||||||||||||||||||||||||||||||||
| 1073 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | $recce_c->_marpa_r_source_middle(), | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | $link_ahm_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | $recce_c->_marpa_r_source_leo_transition_symbol(), | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | Marpa::R2::show_leo_link_choice( | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | $recce, $link_ahm_id, $earleme | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | } ## end for ( my $link_ahm_id = $recce_c...) | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | 27 | push @pieces, map { $_->[-1] } sort { | |||||||||||||||||||||||||||||||||||||||||
| 1083 | 697 | ▶ | $a->[0] <=> $b->[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
MC/DC0%0/2
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0] or $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
$Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]
$Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
Truth table0%0/3
A or B
A= $Marpa::R2::Internal::Recognizer::a->[0] <=> $Marpa::R2::Internal::Recognizer::b->[0]B= $Marpa::R2::Internal::Recognizer::a->[1] <=> $Marpa::R2::Internal::Recognizer::b->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | || $a->[1] <=> $b->[1] | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | || $a->[2] <=> $b->[2] | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | } @sort_data; | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | 697 | ▶ | push @lines, q{ } . join q{ }, @pieces if @pieces; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1088 | 697 | return join "\n", @lines, q{}; | |||||||||||||||||||||||||||||||||||||||||
| 1089 | } ## end sub Marpa::R2::show_earley_item | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | sub Marpa::R2::show_earley_set { | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 81 | ▶ | my ( $recce, $traced_set_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_earley_set: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1093 | 81 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 1094 | 81 | my $text = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 1095 | 81 | my @sorted_data = (); | |||||||||||||||||||||||||||||||||||||||||
| 1096 | 81 | ▶ | if ( not defined $recce_c->_marpa_r_earley_set_trace($traced_set_id) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 8 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1099 | 73 | EARLEY_ITEM: for ( my $item_id = 0;; $item_id++ ) { | |||||||||||||||||||||||||||||||||||||||||
| 1100 | 770 | my $item_desc = Marpa::R2::show_earley_item( $recce, $traced_set_id, $item_id ); | |||||||||||||||||||||||||||||||||||||||||
| 1101 | 770 | ▶ | last EARLEY_ITEM if not defined $item_desc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1102 | # We do not sort these any more | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | 697 | push @sorted_data, $item_desc; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | } ## end EARLEY_ITEM: for ( my $item_id = 0;; $item_id++ ) | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | 73 | my @sort_data = (); | |||||||||||||||||||||||||||||||||||||||||
| 1106 | POSTDOT_ITEM: | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | 73 | ▶ | for ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1108 | my $postdot_symbol_id = $recce_c->_marpa_r_first_postdot_item_trace(); | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | defined $postdot_symbol_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | $postdot_symbol_id = $recce_c->_marpa_r_next_postdot_item_trace() | ||||||||||||||||||||||||||||||||||||||||||
| 1111 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1112 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | # If there is no base Earley item, | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | # then this is not a Leo item, so we skip it | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | 670 | my $leo_item_desc = Marpa::R2::show_lim($recce); | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 670 | ▶ | next POSTDOT_ITEM if not defined $leo_item_desc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 188 | push @sort_data, [ $postdot_symbol_id, $leo_item_desc ]; | |||||||||||||||||||||||||||||||||||||||||
| 1119 | } ## end POSTDOT_ITEM: for ( my $postdot_symbol_id = $recce_c...) | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | push @sorted_data, join q{}, | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | 73 | map { $_->[-1] . "\n" } sort { $a->[0] <=> $b->[0] } @sort_data; | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 73 | return join q{}, @sorted_data; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | } ## end sub Marpa::R2::show_earley_set | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | sub Marpa::R2::Recognizer::show_earley_sets { | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | 8 | ▶ | my ($recce) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_earley_sets: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1127 | 8 | my $recce_c = $recce->[Marpa::R2::Internal::Recognizer::C]; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 8 | my $last_completed_earleme = $recce_c->current_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 1129 | 8 | my $furthest_earleme = $recce_c->furthest_earleme(); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | 8 | my $text = "Last Completed: $last_completed_earleme; " | |||||||||||||||||||||||||||||||||||||||||
| 1131 | . "Furthest: $furthest_earleme\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | 8 | LIST: for ( my $ix = 0;; $ix++ ) { | |||||||||||||||||||||||||||||||||||||||||
| 1133 | 81 | my $set_desc = Marpa::R2::show_earley_set( $recce, $ix ); | |||||||||||||||||||||||||||||||||||||||||
| 1134 | 81 | ▶ | last LIST if not $set_desc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1135 | 73 | $text .= "Earley Set $ix\n$set_desc"; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1137 | 8 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | } ## end sub Marpa::R2::Recognizer::show_earley_sets | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 150 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | # vim: set expandtab shiftwidth=4: | ||||||||||||||||||||||||||||||||||||||||||