| 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::MetaAST; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 150 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 150 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 150 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 150 | ▶ | use vars qw($VERSION $STRING_VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 150 | $VERSION = '13.003_000'; | |||||||||||||||||||||||||||
| 24 | 150 | $STRING_VERSION = $VERSION; | |||||||||||||||||||||||||||
| 25 | ## no critic(BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||
| 26 | 150 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||
| 27 | ## use critic | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | package Marpa::R2::Internal::MetaAST; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 150 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub new { | ||||||||||||||||||||||||||||
| 34 | 217 | ▶ | my ( $class, $p_rules_source ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 35 | 217 | my $meta_recce = Marpa::R2::Internal::Scanless::meta_recce(); | |||||||||||||||||||||||||||
| 36 | 217 | ▶ | eval { $meta_recce->read($p_rules_source) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | or Marpa::R2::exception( "Parse of BNF/Scanless source failed\n", | ||||||||||||||||||||||||||||
| 38 | $EVAL_ERROR ); | ||||||||||||||||||||||||||||
| 39 | 215 | ▶ | if ( my $ambiguity_status = $meta_recce->ambiguous() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 1 | Marpa::R2::exception( "Parse of BNF/Scanless source failed:\n", | |||||||||||||||||||||||||||
| 41 | $ambiguity_status ); | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 214 | my $value_ref = $meta_recce->value(); | |||||||||||||||||||||||||||
| 44 | 214 | ▶ | Marpa::R2::exception('Parse of BNF/Scanless source failed') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | if not defined $value_ref; | ||||||||||||||||||||||||||||
| 46 | 214 | my $ast = { meta_recce => $meta_recce, top_node => ${$value_ref} }; | |||||||||||||||||||||||||||
| 47 | 214 | return bless $ast, $class; | |||||||||||||||||||||||||||
| 48 | } ## end sub new | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub Marpa::R2::Internal::MetaAST::Parse::substring { | ||||||||||||||||||||||||||||
| 51 | 13 | ▶ | my ( $parse, $start, $length ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
substring: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 13 | my $meta_slr = $parse->{meta_recce}; | |||||||||||||||||||||||||||
| 53 | 13 | my $thin_meta_slr = $meta_slr->[Marpa::R2::Internal::Scanless::R::C]; | |||||||||||||||||||||||||||
| 54 | 13 | my $string = $thin_meta_slr->substring( $start, $length ); | |||||||||||||||||||||||||||
| 55 | 13 | chomp $string; | |||||||||||||||||||||||||||
| 56 | 13 | return $string; | |||||||||||||||||||||||||||
| 57 | } ## end sub Marpa::R2::Internal::MetaAST::Parse::substring | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub ast_to_hash { | ||||||||||||||||||||||||||||
| 60 | 214 | ▶ | my ($ast) = @_; | ||||||||||||||||||||||||||
|
Subroutine
ast_to_hash: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||
| 61 | 214 | my $hashed_ast = {}; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 214 | $hashed_ast->{meta_recce} = $ast->{meta_recce}; | |||||||||||||||||||||||||||
| 64 | 214 | bless $hashed_ast, 'Marpa::R2::Internal::MetaAST::Parse'; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 214 | $hashed_ast->{current_lexer} = 'L0'; | |||||||||||||||||||||||||||
| 67 | 214 | $hashed_ast->{rules}->{G1} = []; | |||||||||||||||||||||||||||
| 68 | 214 | my $g1_symbols = $hashed_ast->{symbols}->{G1} = {}; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 214 | my ( undef, undef, @statements ) = @{ $ast->{top_node} }; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # This is the last ditch exception catcher | ||||||||||||||||||||||||||||
| 73 | # It forces all Marpa exceptions to be die's, | ||||||||||||||||||||||||||||
| 74 | # then catches them and rethrows using Carp. | ||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||
| 76 | # The plan is to use die(), with higher levels | ||||||||||||||||||||||||||||
| 77 | # catching and re-die()'ing after adding | ||||||||||||||||||||||||||||
| 78 | # helpful location information. After the | ||||||||||||||||||||||||||||
| 79 | # re-throw it is caught here and passed to | ||||||||||||||||||||||||||||
| 80 | # Carp. | ||||||||||||||||||||||||||||
| 81 | 214 | my $eval_ok = eval { | |||||||||||||||||||||||||||
| 82 | 214 | local $Marpa::R2::JUST_DIE = 1; | |||||||||||||||||||||||||||
| 83 | 214 | $_->evaluate($hashed_ast) for @statements; | |||||||||||||||||||||||||||
| 84 | 214 | 1; | |||||||||||||||||||||||||||
| 85 | }; | ||||||||||||||||||||||||||||
| 86 | 214 | ▶ | Marpa::R2::exception($EVAL_ERROR) if not $eval_ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 214 | my %grammars = (); | |||||||||||||||||||||||||||
| 89 | 214 | $grammars{$_} = 1 for keys %{ $hashed_ast->{rules} }; | |||||||||||||||||||||||||||
| 90 | my @lexers = | ||||||||||||||||||||||||||||
| 91 | 214 | grep { ( substr $_, 0, 1 ) eq 'L' } keys %grammars; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 214 | for my $lexer (@lexers) { | |||||||||||||||||||||||||||
| 94 | 194 | my $lexer_name = $lexer; | |||||||||||||||||||||||||||
| 95 | NAME_LEXER: { | ||||||||||||||||||||||||||||
| 96 | 194 | ▶ | if ( $lexer eq 'L0' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 194 | $lexer_name = "L0 (the default)"; | |||||||||||||||||||||||||||
| 98 | 194 | last NAME_LEXER; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | last NAME_LEXER if ( substr $lexer_name, 0, 2 ) ne 'L-'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | $lexer_name = substr $lexer_name, 2; | |||||||||||||||||||||||||||
| 102 | } ## end NAME_LEXER: | ||||||||||||||||||||||||||||
| 103 | } ## end for my $lexer (@lexers) | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 214 | my %stripped_character_classes = (); | |||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||
| 107 | 214 | my $character_classes = $hashed_ast->{character_classes}; | |||||||||||||||||||||||||||
| 108 | 214 | for my $symbol_name ( sort keys %{$character_classes} ) { | |||||||||||||||||||||||||||
| 109 | 942 | my ($re) = @{ $character_classes->{$symbol_name} }; | |||||||||||||||||||||||||||
| 110 | 942 | $stripped_character_classes{$symbol_name} = $re; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | 214 | $hashed_ast->{character_classes} = \%stripped_character_classes; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 214 | return $hashed_ast; | |||||||||||||||||||||||||||
| 116 | } ## end sub ast_to_hash | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | sub Marpa::R2::Internal::MetaAST::Parse::start_rule_setup { | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my ($ast) = @_; | ||||||||||||||||||||||||||
|
Subroutine
start_rule_setup: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my $start_lhs = $ast->{'start_lhs'} // $ast->{'first_lhs'}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$ast->{"start_lhs"} // $ast->{"first_lhs"}
MC/DC0%0/2
$ast->{"start_lhs"} // $ast->{"first_lhs"}
$ast->{"start_lhs"}
$ast->{"first_lhs"}
Truth table0%0/3
A // B
A= $ast->{"start_lhs"}B= $ast->{"first_lhs"}
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | Marpa::R2::exception('No rules in SLIF grammar') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | if not defined $start_lhs; | ||||||||||||||||||||||||||||
| 123 | 0 | Marpa::R2::Internal::MetaAST::start_rule_create( $ast, $start_lhs ); | |||||||||||||||||||||||||||
| 124 | } ## end sub Marpa::R2::Internal::MetaAST::Parse::start_rule_setup | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # This class is for pieces of RHS alternatives, as they are | ||||||||||||||||||||||||||||
| 127 | # being constructed | ||||||||||||||||||||||||||||
| 128 | 150 | my $PROTO_ALTERNATIVE = 'Marpa::R2::Internal::MetaAST::Proto_Alternative'; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub Marpa::R2::Internal::MetaAST::Proto_Alternative::combine { | ||||||||||||||||||||||||||||
| 131 | 725 | ▶ | my ( $class, @hashes ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
combine: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 132 | 725 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 133 | 725 | for my $hash_to_add (@hashes) { | |||||||||||||||||||||||||||
| 134 | 860 | for my $key ( keys %{$hash_to_add} ) { | |||||||||||||||||||||||||||
| 135 | ## expect to be caught and rethrown | ||||||||||||||||||||||||||||
| 136 | die qq{A Marpa rule contained a duplicate key\n}, | ||||||||||||||||||||||||||||
| 137 | qq{ The key was "$key"\n} | ||||||||||||||||||||||||||||
| 138 | 854 | ▶ | if exists $self->{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | 854 | $self->{$key} = $hash_to_add->{$key}; | |||||||||||||||||||||||||||
| 140 | } ## end for my $key ( keys %{$hash_to_add} ) | ||||||||||||||||||||||||||||
| 141 | } ## end for my $hash_to_add (@hashes) | ||||||||||||||||||||||||||||
| 142 | 725 | return $self; | |||||||||||||||||||||||||||
| 143 | } ## end sub Marpa::R2::Internal::MetaAST::Proto_Alternative::combine | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | sub Marpa::R2::Internal::MetaAST::Parse::bless_hash_rule { | ||||||||||||||||||||||||||||
| 146 | 1959 | ▶ | my ( $parse, $hash_rule, $blessing, $naming, $original_lhs ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bless_hash_rule: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||
| 147 | 1959 | ▶ | return if (substr $Marpa::R2::Internal::SUBGRAMMAR, 0, 1) eq 'L'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 1244 | ▶ | $naming //= $original_lhs; | ||||||||||||||||||||||||||
|
Condition66%2/3
$naming //= $original_lhs
MC/DC0%0/2
$naming //= $original_lhs
$naming
$original_lhs
Truth table66%2/3
A //= B
A= $namingB= $original_lhs
| |||||||||||||||||||||||||||||
| 150 | 1244 | $hash_rule->{name} = $naming; | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 1244 | ▶ | return if not defined $blessing; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | FIND_BLESSING: { | ||||||||||||||||||||||||||||
| 154 | 100 | ▶ | last FIND_BLESSING if $blessing =~ /\A [\w] /xms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 28 | ▶ | return if $blessing eq '::undef'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | # Rule may be half-formed, but assume we have lhs | ||||||||||||||||||||||||||||
| 158 | 28 | ▶ | if ( $blessing eq '::lhs' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 28 | $blessing = $original_lhs; | |||||||||||||||||||||||||||
| 160 | 28 | ▶ | if ( $blessing =~ / [^ [:alnum:]] /xms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 162 | qq{"::lhs" blessing only allowed if LHS is whitespace and alphanumerics\n}, | ||||||||||||||||||||||||||||
| 163 | qq{ LHS was <$original_lhs>\n} | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | } ## end if ( $blessing =~ / [^ [:alnum:]] /xms ) | ||||||||||||||||||||||||||||
| 166 | 28 | $blessing =~ s/[ ]/_/gxms; | |||||||||||||||||||||||||||
| 167 | 28 | last FIND_BLESSING; | |||||||||||||||||||||||||||
| 168 | } ## end if ( $blessing eq '::lhs' ) | ||||||||||||||||||||||||||||
| 169 | 0 | Marpa::R2::exception( qq{Unknown blessing "$blessing"\n} ); | |||||||||||||||||||||||||||
| 170 | } ## end FIND_BLESSING: | ||||||||||||||||||||||||||||
| 171 | 100 | $hash_rule->{bless} = $blessing; | |||||||||||||||||||||||||||
| 172 | 100 | return 1; | |||||||||||||||||||||||||||
| 173 | } ## end sub Marpa::R2::Internal::MetaAST::Parse::bless_hash_rule | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 3698 | ▶ | sub Marpa::R2::Internal::MetaAST_Nodes::bare_name::name { return $_[0]->[2] } | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | sub Marpa::R2::Internal::MetaAST_Nodes::reserved_action_name::name { | ||||||||||||||||||||||||||||
| 178 | 60 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 179 | 60 | return $self->[2]; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | sub Marpa::R2::Internal::MetaAST_Nodes::reserved_event_name::name { | ||||||||||||||||||||||||||||
| 183 | 33 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 184 | 33 | my $name = $self->[2]; | |||||||||||||||||||||||||||
| 185 | 33 | $name =~ s/\A : /'/xms; | |||||||||||||||||||||||||||
| 186 | 33 | return $name; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | sub Marpa::R2::Internal::MetaAST_Nodes::action_name::name { | ||||||||||||||||||||||||||||
| 190 | 455 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 191 | 455 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | sub Marpa::R2::Internal::MetaAST_Nodes::alternative_name::name { | ||||||||||||||||||||||||||||
| 195 | 5 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 196 | 5 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | sub Marpa::R2::Internal::MetaAST_Nodes::event_name::name { | ||||||||||||||||||||||||||||
| 200 | 279 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 201 | 279 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | sub Marpa::R2::Internal::MetaAST_Nodes::lexer_name::name { | ||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 206 | 0 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | sub Marpa::R2::Internal::MetaAST_Nodes::array_descriptor::name { | ||||||||||||||||||||||||||||
| 210 | 98 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | sub Marpa::R2::Internal::MetaAST_Nodes::reserved_blessing_name::name { | ||||||||||||||||||||||||||||
| 214 | 12 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | sub Marpa::R2::Internal::MetaAST_Nodes::blessing_name::name { | ||||||||||||||||||||||||||||
| 218 | 84 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 219 | 84 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | sub Marpa::R2::Internal::MetaAST_Nodes::standard_name::name { | ||||||||||||||||||||||||||||
| 223 | 129 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | sub Marpa::R2::Internal::MetaAST_Nodes::Perl_name::name { | ||||||||||||||||||||||||||||
| 227 | 297 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | sub Marpa::R2::Internal::MetaAST_Nodes::lhs::name { | ||||||||||||||||||||||||||||
| 231 | 1425 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 232 | 1425 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 233 | 1425 | return $symbol->name($parse); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | # After development, delete this | ||||||||||||||||||||||||||||
| 237 | sub Marpa::R2::Internal::MetaAST_Nodes::lhs::evaluate { | ||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 239 | 0 | return $values->name($parse); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | sub Marpa::R2::Internal::MetaAST_Nodes::quantifier::evaluate { | ||||||||||||||||||||||||||||
| 243 | 234 | ▶ | my ($data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 244 | 234 | return $data->[2]; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | sub Marpa::R2::Internal::MetaAST_Nodes::op_declare::op { | ||||||||||||||||||||||||||||
| 248 | 1425 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 249 | 1425 | return $values->[2]->op(); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | sub Marpa::R2::Internal::MetaAST_Nodes::op_declare_match::op { | ||||||||||||||||||||||||||||
| 253 | 609 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 254 | 609 | return $values->[2]; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | sub Marpa::R2::Internal::MetaAST_Nodes::op_declare_bnf::op { | ||||||||||||||||||||||||||||
| 258 | 928 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 259 | 928 | return $values->[2]; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | sub Marpa::R2::Internal::MetaAST_Nodes::bracketed_name::name { | ||||||||||||||||||||||||||||
| 263 | 440 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 264 | 440 | my ( undef, undef, $bracketed_name ) = @{$values}; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | # normalize whitespace | ||||||||||||||||||||||||||||
| 267 | 440 | $bracketed_name =~ s/\A [<] \s*//xms; | |||||||||||||||||||||||||||
| 268 | 440 | $bracketed_name =~ s/ \s* [>] \z//xms; | |||||||||||||||||||||||||||
| 269 | 440 | $bracketed_name =~ s/ \s+ / /gxms; | |||||||||||||||||||||||||||
| 270 | 440 | return $bracketed_name; | |||||||||||||||||||||||||||
| 271 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::bracketed_name::name | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | sub Marpa::R2::Internal::MetaAST_Nodes::single_quoted_name::name { | ||||||||||||||||||||||||||||
| 274 | 194 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 275 | 194 | my ( undef, undef, $single_quoted_name ) = @{$values}; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | # normalize whitespace | ||||||||||||||||||||||||||||
| 278 | 194 | $single_quoted_name =~ s/\A ['] \s*//xms; | |||||||||||||||||||||||||||
| 279 | 194 | $single_quoted_name =~ s/ \s* ['] \z//xms; | |||||||||||||||||||||||||||
| 280 | 194 | $single_quoted_name =~ s/ \s+ / /gxms; | |||||||||||||||||||||||||||
| 281 | 194 | return $single_quoted_name; | |||||||||||||||||||||||||||
| 282 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::single_quoted_name::name | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | sub Marpa::R2::Internal::MetaAST_Nodes::parenthesized_rhs_primary_list::evaluate | ||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||
| 286 | 77 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 287 | 77 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||
| 288 | 77 | my @symbol_lists = map { $_->evaluate($parse); } @values; | |||||||||||||||||||||||||||
| 289 | 77 | my $flattened_list = | |||||||||||||||||||||||||||
| 290 | Marpa::R2::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | ||||||||||||||||||||||||||||
| 291 | 77 | $flattened_list->mask_set(0); | |||||||||||||||||||||||||||
| 292 | 77 | return $flattened_list; | |||||||||||||||||||||||||||
| 293 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::parenthesized_rhs_primary_list::evaluate | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | sub Marpa::R2::Internal::MetaAST_Nodes::rhs::evaluate { | ||||||||||||||||||||||||||||
| 296 | 1663 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 297 | 1663 | my ( $start, $length, @values ) = @{$data}; | |||||||||||||||||||||||||||
| 298 | 1663 | my $rhs = eval { | |||||||||||||||||||||||||||
| 299 | 1663 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||
| 300 | 1663 | my $flattened_list = | |||||||||||||||||||||||||||
| 301 | Marpa::R2::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | ||||||||||||||||||||||||||||
| 302 | 1663 | bless { | |||||||||||||||||||||||||||
| 303 | rhs => $flattened_list->names($parse), | ||||||||||||||||||||||||||||
| 304 | mask => $flattened_list->mask() | ||||||||||||||||||||||||||||
| 305 | }, | ||||||||||||||||||||||||||||
| 306 | $PROTO_ALTERNATIVE; | ||||||||||||||||||||||||||||
| 307 | }; | ||||||||||||||||||||||||||||
| 308 | 1663 | ▶ | if ( not $rhs ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||
| 310 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||
| 311 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 312 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||
| 313 | q{ RHS involved was }, | ||||||||||||||||||||||||||||
| 314 | $parse->substring( $start, $length ) | ||||||||||||||||||||||||||||
| 315 | ); | ||||||||||||||||||||||||||||
| 316 | } ## end if ( not $rhs ) | ||||||||||||||||||||||||||||
| 317 | 1663 | return $rhs; | |||||||||||||||||||||||||||
| 318 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::rhs::evaluate | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | sub Marpa::R2::Internal::MetaAST_Nodes::rhs_primary::evaluate { | ||||||||||||||||||||||||||||
| 321 | 2834 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 322 | 2834 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||
| 323 | 2834 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||
| 324 | 2834 | return Marpa::R2::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | |||||||||||||||||||||||||||
| 325 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::rhs_primary::evaluate | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | sub Marpa::R2::Internal::MetaAST_Nodes::rhs_primary_list::evaluate { | ||||||||||||||||||||||||||||
| 328 | 77 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 329 | 77 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||
| 330 | 77 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||
| 331 | 77 | return Marpa::R2::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | |||||||||||||||||||||||||||
| 332 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::rhs_primary_list::evaluate | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | sub Marpa::R2::Internal::MetaAST_Nodes::action::evaluate { | ||||||||||||||||||||||||||||
| 335 | 455 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 336 | 455 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||
| 337 | 455 | return bless { action => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | sub Marpa::R2::Internal::MetaAST_Nodes::blessing::evaluate { | ||||||||||||||||||||||||||||
| 341 | 84 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 342 | 84 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||
| 343 | 84 | return bless { bless => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | sub Marpa::R2::Internal::MetaAST_Nodes::naming::evaluate { | ||||||||||||||||||||||||||||
| 347 | 5 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 348 | 5 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||
| 349 | 5 | return bless { name => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | sub Marpa::R2::Internal::MetaAST_Nodes::right_association::evaluate { | ||||||||||||||||||||||||||||
| 353 | 10 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 354 | 10 | return bless { assoc => 'R' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | sub Marpa::R2::Internal::MetaAST_Nodes::left_association::evaluate { | ||||||||||||||||||||||||||||
| 358 | 0 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 359 | 0 | return bless { assoc => 'L' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | sub Marpa::R2::Internal::MetaAST_Nodes::group_association::evaluate { | ||||||||||||||||||||||||||||
| 363 | 11 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 364 | 11 | return bless { assoc => 'G' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | sub Marpa::R2::Internal::MetaAST_Nodes::event_specification::evaluate { | ||||||||||||||||||||||||||||
| 368 | 127 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 369 | 127 | return bless { event => ( $values->[2]->event() ) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | sub Marpa::R2::Internal::MetaAST_Nodes::event_initialization::event { | ||||||||||||||||||||||||||||
| 373 | 279 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
event: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 374 | 279 | my $event_name = $values->[2]; | |||||||||||||||||||||||||||
| 375 | 279 | my $event_initializer = $values->[3]; | |||||||||||||||||||||||||||
| 376 | 279 | return [$event_name->name(), $event_initializer->on_or_off()], | |||||||||||||||||||||||||||
| 377 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::event_specification::evaluate | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | sub Marpa::R2::Internal::MetaAST_Nodes::proper_specification::evaluate { | ||||||||||||||||||||||||||||
| 380 | 1 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 381 | 1 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 382 | 1 | return bless { proper => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | sub Marpa::R2::Internal::MetaAST_Nodes::latm_specification::evaluate { | ||||||||||||||||||||||||||||
| 386 | 45 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 387 | 45 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 388 | 45 | return bless { latm => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | sub Marpa::R2::Internal::MetaAST_Nodes::pause_specification::evaluate { | ||||||||||||||||||||||||||||
| 392 | 54 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 393 | 54 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 394 | 54 | return bless { pause => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | sub Marpa::R2::Internal::MetaAST_Nodes::priority_specification::evaluate { | ||||||||||||||||||||||||||||
| 398 | 2 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 399 | 2 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 400 | 2 | return bless { priority => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | sub Marpa::R2::Internal::MetaAST_Nodes::rank_specification::evaluate { | ||||||||||||||||||||||||||||
| 404 | 45 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 405 | 45 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 406 | 45 | return bless { rank => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | sub Marpa::R2::Internal::MetaAST_Nodes::null_ranking_specification::evaluate { | ||||||||||||||||||||||||||||
| 410 | 2 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 411 | 2 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 412 | 2 | return bless { null_ranking => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | sub Marpa::R2::Internal::MetaAST_Nodes::null_ranking_constant::value { | ||||||||||||||||||||||||||||
| 416 | 2 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | sub Marpa::R2::Internal::MetaAST_Nodes::before_or_after::value { | ||||||||||||||||||||||||||||
| 420 | 54 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | sub Marpa::R2::Internal::MetaAST_Nodes::event_initializer::on_or_off | ||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||
| 425 | # die Data::Dumper::Dumper(\@_); | ||||||||||||||||||||||||||||
| 426 | 279 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||
|
Subroutine
on_or_off: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 427 | 279 | my $is_activated = $values->[2]; | |||||||||||||||||||||||||||
| 428 | 279 | ▶ | return 1 if not defined $is_activated; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 429 | 102 | return $is_activated->value(); | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | sub Marpa::R2::Internal::MetaAST_Nodes::on_or_off::value { | ||||||||||||||||||||||||||||
| 433 | 102 | ▶ | return $_[0]->[2] eq 'off' ? 0 : 1; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | sub Marpa::R2::Internal::MetaAST_Nodes::boolean::value { | ||||||||||||||||||||||||||||
| 437 | 46 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | sub Marpa::R2::Internal::MetaAST_Nodes::signed_integer::value { | ||||||||||||||||||||||||||||
| 441 | 47 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | sub Marpa::R2::Internal::MetaAST_Nodes::separator_specification::evaluate { | ||||||||||||||||||||||||||||
| 445 | 13 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 446 | 13 | my $child = $values->[2]; | |||||||||||||||||||||||||||
| 447 | 13 | return bless { separator => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | sub Marpa::R2::Internal::MetaAST_Nodes::adverb_item::evaluate { | ||||||||||||||||||||||||||||
| 451 | 860 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 452 | 860 | my $child = $values->[2]->evaluate($parse); | |||||||||||||||||||||||||||
| 453 | 860 | return bless $child, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | sub Marpa::R2::Internal::MetaAST_Nodes::default_rule::evaluate { | ||||||||||||||||||||||||||||
| 457 | 112 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||
| 458 | 112 | my ( $start, $length, undef, $op_declare, $raw_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||
| 459 | 112 | ▶ | my $subgrammar = $op_declare->op() eq q{::=} ? 'G1' : $parse->{current_lexer}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 460 | 112 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | # A default rule clears the previous default | ||||||||||||||||||||||||||||
| 463 | 112 | my %default_adverbs = (); | |||||||||||||||||||||||||||
| 464 | 112 | $parse->{default_adverbs}->{$subgrammar} = \%default_adverbs; | |||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 112 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 467 | 120 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 468 | 120 | ▶ | if ( $key eq 'action' and $subgrammar eq 'G1' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq "action" and $subgrammar eq "G1"
MC/DC50%1/2
$key eq "action" and $subgrammar eq "G1"
$key eq "action"
$subgrammar eq "G1"
Truth table66%2/3
A and B
A= $key eq "action"B= $subgrammar eq "G1"
| |||||||||||||||||||||||||||||
| 469 | 112 | $default_adverbs{$key} = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 470 | 112 | next ADVERB; | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | 8 | ▶ | if ( $key eq 'bless' and $subgrammar eq 'G1' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key eq "bless" and $subgrammar eq "G1"
MC/DC0%0/2
$key eq "bless" and $subgrammar eq "G1"
$key eq "bless"
$subgrammar eq "G1"
Truth table33%1/3
A and B
A= $key eq "bless"B= $subgrammar eq "G1"
| |||||||||||||||||||||||||||||
| 473 | 8 | $default_adverbs{$key} = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 474 | 8 | next ADVERB; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | 0 | die qq{Adverb "$key" not allowed in $subgrammar default rule\n}, | |||||||||||||||||||||||||||
| 477 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 478 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 479 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 480 | 112 | return undef; | |||||||||||||||||||||||||||
| 481 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::default_rule::evaluate | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | sub Marpa::R2::Internal::MetaAST_Nodes::discard_default_statement::evaluate { | ||||||||||||||||||||||||||||
| 484 | 27 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=5 SCAR=17.3
| |||||||||||||||||||||||||||||
| 485 | 27 | my ( $start, $length, $raw_adverb_list ) = @{$data}; | |||||||||||||||||||||||||||
| 486 | 27 | local $Marpa::R2::Internal::SUBGRAMMAR = 'G1'; | |||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | 27 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 489 | 27 | ▶ | if ( exists $parse->{discard_default_adverbs} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 490 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||
| 491 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 492 | qq{More than one discard default statement is not allowed\n}, | ||||||||||||||||||||||||||||
| 493 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||
| 494 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||
| 495 | ); | ||||||||||||||||||||||||||||
| 496 | } ## end if ( exists $parse->{discard_default_adverbs} ) | ||||||||||||||||||||||||||||
| 497 | 27 | $parse->{discard_default_adverbs} = {}; | |||||||||||||||||||||||||||
| 498 | 27 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 499 | 27 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 500 | 27 | ▶ | if ( $key eq 'event' and defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$key eq "event" and defined $value
MC/DC0%0/2
$key eq "event" and defined $value
$key eq "event"
defined $value
Truth table33%1/3
A and B
A= $key eq "event"B= defined $value
| |||||||||||||||||||||||||||||
| 501 | 27 | $parse->{discard_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||
| 502 | 27 | next ADVERB; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | Marpa::R2::exception( | ||||||||||||||||||||||||||||
| 505 | 0 | qq{"$key" adverb not allowed as discard default"}); | |||||||||||||||||||||||||||
| 506 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 507 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 508 | 27 | return undef; | |||||||||||||||||||||||||||
| 509 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::discard_default_statement::evaluate | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | sub Marpa::R2::Internal::MetaAST_Nodes::lexeme_default_statement::evaluate { | ||||||||||||||||||||||||||||
| 512 | 53 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 513 | 53 | my ( $start, $length, $raw_adverb_list ) = @{$data}; | |||||||||||||||||||||||||||
| 514 | 53 | local $Marpa::R2::Internal::SUBGRAMMAR = 'G1'; | |||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | 53 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 517 | 53 | ▶ | if ( exists $parse->{lexeme_default_adverbs} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 518 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||
| 519 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 520 | qq{More than one lexeme default statement is not allowed\n}, | ||||||||||||||||||||||||||||
| 521 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||
| 522 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||
| 523 | ); | ||||||||||||||||||||||||||||
| 524 | } ## end if ( exists $parse->{lexeme_default_adverbs} ) | ||||||||||||||||||||||||||||
| 525 | 53 | $parse->{lexeme_default_adverbs} = {}; | |||||||||||||||||||||||||||
| 526 | 53 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 527 | 87 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 528 | 87 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | 40 | $parse->{lexeme_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||
| 530 | 40 | next ADVERB; | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | 47 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 533 | 4 | $parse->{lexeme_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||
| 534 | 4 | next ADVERB; | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | 43 | ▶ | if ( $key eq 'latm' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 537 | 43 | $parse->{lexeme_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||
| 538 | 43 | next ADVERB; | |||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||
| 540 | Marpa::R2::exception( | ||||||||||||||||||||||||||||
| 541 | 0 | qq{"$key" adverb not allowed as lexeme default"}); | |||||||||||||||||||||||||||
| 542 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 543 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 544 | 53 | return undef; | |||||||||||||||||||||||||||
| 545 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::lexeme_default_statement::evaluate | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | sub Marpa::R2::Internal::MetaAST_Nodes::inaccessible_statement::evaluate { | ||||||||||||||||||||||||||||
| 548 | 7 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 549 | 7 | my ( $start, $length, $inaccessible_treatment ) = @{$data}; | |||||||||||||||||||||||||||
| 550 | 7 | local $Marpa::R2::Internal::SUBGRAMMAR = 'G1'; | |||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 7 | ▶ | if ( exists $parse->{defaults}->{if_inaccessible} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 553 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||
| 554 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 555 | qq{More than one inaccessible default statement is not allowed\n}, | ||||||||||||||||||||||||||||
| 556 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||
| 557 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||
| 558 | ); | ||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | 7 | $parse->{defaults}->{if_inaccessible} = $inaccessible_treatment->value(); | |||||||||||||||||||||||||||
| 561 | 7 | return undef; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | sub Marpa::R2::Internal::MetaAST_Nodes::inaccessible_treatment::value { | ||||||||||||||||||||||||||||
| 565 | 7 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||
| 568 | sub Marpa::R2::Internal::MetaAST_Nodes::priority_rule::evaluate { | ||||||||||||||||||||||||||||
| 569 | 1129 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=67 SCAR=47.5
| |||||||||||||||||||||||||||||
| 570 | my ( $start, $length, $raw_lhs, $op_declare, $raw_priorities ) = | ||||||||||||||||||||||||||||
| 571 | 1129 | @{$values}; | |||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 1129 | my $current_lexer = $parse->{current_lexer}; | |||||||||||||||||||||||||||
| 574 | 1129 | my $subgrammar; | |||||||||||||||||||||||||||
| 575 | 1129 | ▶ | if ( $op_declare->op() eq q{::=} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 662 | ▶ | if ( $current_lexer ne 'L0' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 577 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 578 | 0 | die "G1 rules currently allowed only when L0 is current lexer\n", | |||||||||||||||||||||||||||
| 579 | qq{ A prioritized rule was found when "$current_lexer" was the current lexer\n"}, | ||||||||||||||||||||||||||||
| 580 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 581 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 582 | } ## end if ( $current_lexer ne 'L0' ) | ||||||||||||||||||||||||||||
| 583 | 662 | $subgrammar = 'G1'; | |||||||||||||||||||||||||||
| 584 | } ## end if ( $op_declare->op() eq q{::=} ) | ||||||||||||||||||||||||||||
| 585 | else { | ||||||||||||||||||||||||||||
| 586 | 467 | $subgrammar = $current_lexer; | |||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | 1129 | my $lhs = $raw_lhs->name($parse); | |||||||||||||||||||||||||||
| 590 | 1129 | ▶ | $parse->{'first_lhs'} //= $lhs if $subgrammar eq 'G1'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parse->{"first_lhs"} //= $lhs
MC/DC0%0/2
$parse->{"first_lhs"} //= $lhs
$parse->{"first_lhs"}
$lhs
Truth table66%2/3
A //= B
A= $parse->{"first_lhs"}B= $lhs
| |||||||||||||||||||||||||||||
| 591 | 1129 | local $Marpa::R2::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||
| 593 | 1129 | my ( undef, undef, @priorities ) = @{$raw_priorities}; | |||||||||||||||||||||||||||
| 594 | 1129 | my $priority_count = scalar @priorities; | |||||||||||||||||||||||||||
| 595 | 1129 | my @working_rules = (); | |||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | 1129 | ▶ | $parse->{rules}->{$subgrammar} //= []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parse->{"rules"}{$subgrammar} //= []
MC/DC100%1/1
$parse->{"rules"}{$subgrammar} //= []
$parse->{"rules"}{$subgrammar}
Truth table100%2/2
A
A= $parse->{"rules"}{$subgrammar}
| |||||||||||||||||||||||||||||
| 598 | 1129 | my $rules = $parse->{rules}->{$subgrammar}; | |||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | 1129 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | 1129 | ▶ | if ( $priority_count <= 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | ## If there is only one priority | ||||||||||||||||||||||||||||
| 604 | 1110 | my ( undef, undef, @alternatives ) = @{ $priorities[0] }; | |||||||||||||||||||||||||||
| 605 | 1110 | for my $alternative (@alternatives) { | |||||||||||||||||||||||||||
| 606 | my ($alternative_start, $alternative_end, | ||||||||||||||||||||||||||||
| 607 | $raw_rhs, $raw_adverb_list | ||||||||||||||||||||||||||||
| 608 | 1549 | ) = @{$alternative}; | |||||||||||||||||||||||||||
| 609 | 1549 | my ( $proto_rule, $adverb_list ); | |||||||||||||||||||||||||||
| 610 | 1549 | my $eval_ok = eval { | |||||||||||||||||||||||||||
| 611 | 1549 | $proto_rule = $raw_rhs->evaluate($parse); | |||||||||||||||||||||||||||
| 612 | 1549 | $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 613 | 1549 | 1; | |||||||||||||||||||||||||||
| 614 | }; | ||||||||||||||||||||||||||||
| 615 | 1549 | ▶ | if ( not $eval_ok ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 616 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||
| 617 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||
| 618 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 619 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||
| 620 | qq{ The problem was in this RHS alternative:\n}, | ||||||||||||||||||||||||||||
| 621 | q{ }, | ||||||||||||||||||||||||||||
| 622 | $parse->substring( $alternative_start, $alternative_end ), | ||||||||||||||||||||||||||||
| 623 | "\n" | ||||||||||||||||||||||||||||
| 624 | ); | ||||||||||||||||||||||||||||
| 625 | } ## end if ( not $eval_ok ) | ||||||||||||||||||||||||||||
| 626 | 1549 | my @rhs_names = @{ $proto_rule->{rhs} }; | |||||||||||||||||||||||||||
| 627 | 1549 | my @mask = @{ $proto_rule->{mask} }; | |||||||||||||||||||||||||||
| 628 | 1549 | ▶ | if ( ( substr $subgrammar, 0, 1 ) eq 'L' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
substr($subgrammar, 0, 1) eq "L" and grep {not $_;} @mask
MC/DC0%0/2
substr($subgrammar, 0, 1) eq "L" and grep {not $_;} @mask
substr($subgrammar, 0, 1) eq "L"
grep {not $_;} @mask
Truth table66%2/3
A and B
A= substr($subgrammar, 0, 1) eq "L"B= grep {not $_;} @mask
| |||||||||||||||||||||||||||||
| 629 | 948 | and grep { !$_ } @mask ) | |||||||||||||||||||||||||||
| 630 | { | ||||||||||||||||||||||||||||
| 631 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 632 | qq{hidden symbols are not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 633 | ); | ||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||
| 635 | 1549 | my %hash_rule = | |||||||||||||||||||||||||||
| 636 | ( lhs => $lhs, rhs => \@rhs_names, mask => \@mask ); | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | 1549 | my $action; | |||||||||||||||||||||||||||
| 639 | my $blessing; | ||||||||||||||||||||||||||||
| 640 | 1549 | my $naming; | |||||||||||||||||||||||||||
| 641 | 1549 | my $null_ranking; | |||||||||||||||||||||||||||
| 642 | 1549 | my $rank; | |||||||||||||||||||||||||||
| 643 | 1549 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 644 | 279 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 645 | 279 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 646 | 201 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 647 | 201 | next ADVERB; | |||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||
| 649 | 78 | ▶ | if ( $key eq 'assoc' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | # OK, but ignored | ||||||||||||||||||||||||||||
| 652 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||
| 654 | 78 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 655 | 26 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 656 | 26 | next ADVERB; | |||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||
| 658 | 52 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 659 | 5 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 660 | 5 | next ADVERB; | |||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||
| 662 | 47 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 663 | 2 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 664 | 2 | next ADVERB; | |||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||
| 666 | 45 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 667 | 45 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 668 | 45 | next ADVERB; | |||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||
| 670 | my ( $line, $column ) = | ||||||||||||||||||||||||||||
| 671 | 0 | $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 672 | 0 | die qq{Adverb "$key" not allowed in an prioritized rule\n}, | |||||||||||||||||||||||||||
| 673 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 674 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | 1549 | ▶ | $action //= $default_adverbs->{action}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$action //= $default_adverbs->{"action"}
MC/DC100%2/2
$action //= $default_adverbs->{"action"}
$action
$default_adverbs->{"action"}
Truth table100%3/3
A //= B
A= $actionB= $default_adverbs->{"action"}
| |||||||||||||||||||||||||||||
| 677 | 1549 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 678 | 469 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 679 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 680 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 681 | 469 | $hash_rule{action} = $action; | |||||||||||||||||||||||||||
| 682 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | 1549 | ▶ | $rank //= $default_adverbs->{rank}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$rank //= $default_adverbs->{"rank"}
MC/DC50%1/2
$rank //= $default_adverbs->{"rank"}
$rank
$default_adverbs->{"rank"}
Truth table66%2/3
A //= B
A= $rankB= $default_adverbs->{"rank"}
| |||||||||||||||||||||||||||||
| 685 | 1549 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 686 | 45 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 687 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 688 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 689 | 45 | $hash_rule{rank} = $rank; | |||||||||||||||||||||||||||
| 690 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 1549 | ▶ | $null_ranking //= $default_adverbs->{null_ranking}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$null_ranking //= $default_adverbs->{"null_ranking"}
MC/DC50%1/2
$null_ranking //= $default_adverbs->{"null_ranking"}
$null_ranking
$default_adverbs->{"null_ranking"}
Truth table66%2/3
A //= B
A= $null_rankingB= $default_adverbs->{"null_ranking"}
| |||||||||||||||||||||||||||||
| 693 | 1549 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 694 | 2 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 695 | qq{null-ranking allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 696 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 697 | 2 | $hash_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||
| 698 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | 1549 | ▶ | $blessing //= $default_adverbs->{bless}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$blessing //= $default_adverbs->{"bless"}
MC/DC100%2/2
$blessing //= $default_adverbs->{"bless"}
$blessing
$default_adverbs->{"bless"}
Truth table100%3/3
A //= B
A= $blessingB= $default_adverbs->{"bless"}
| |||||||||||||||||||||||||||||
| 701 | 1549 | ▶ | if (defined $blessing | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $blessing and substr($subgrammar, 0, 1) eq "L"
MC/DC0%0/2
defined $blessing and substr($subgrammar, 0, 1) eq "L"
defined $blessing
substr($subgrammar, 0, 1) eq "L"
Truth table66%2/3
A and B
A= defined $blessingB= substr($subgrammar, 0, 1) eq "L"
| |||||||||||||||||||||||||||||
| 702 | and | ||||||||||||||||||||||||||||
| 703 | ( substr $subgrammar, 0, 1 ) eq 'L' | ||||||||||||||||||||||||||||
| 704 | ) | ||||||||||||||||||||||||||||
| 705 | { | ||||||||||||||||||||||||||||
| 706 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 707 | 'bless option not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||
| 708 | $lhs, '")' | ||||||||||||||||||||||||||||
| 709 | ); | ||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | 1549 | $parse->bless_hash_rule( \%hash_rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | 1549 | push @{$rules}, \%hash_rule; | |||||||||||||||||||||||||||
| 715 | } ## end for my $alternative (@alternatives) | ||||||||||||||||||||||||||||
| 716 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 717 | 1110 | return undef; | |||||||||||||||||||||||||||
| 718 | } ## end if ( $priority_count <= 1 ) | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | 19 | for my $priority_ix ( 0 .. $priority_count - 1 ) { | |||||||||||||||||||||||||||
| 721 | 75 | my $priority = $priority_count - ( $priority_ix + 1 ); | |||||||||||||||||||||||||||
| 722 | 75 | my ( undef, undef, @alternatives ) = @{ $priorities[$priority_ix] }; | |||||||||||||||||||||||||||
| 723 | 75 | for my $alternative (@alternatives) { | |||||||||||||||||||||||||||
| 724 | my ($alternative_start, $alternative_end, | ||||||||||||||||||||||||||||
| 725 | $raw_rhs, $raw_adverb_list | ||||||||||||||||||||||||||||
| 726 | 114 | ) = @{$alternative}; | |||||||||||||||||||||||||||
| 727 | 114 | my ( $adverb_list, $rhs ); | |||||||||||||||||||||||||||
| 728 | 114 | my $eval_ok = eval { | |||||||||||||||||||||||||||
| 729 | 114 | $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 730 | 114 | $rhs = $raw_rhs->evaluate($parse); | |||||||||||||||||||||||||||
| 731 | 114 | 1; | |||||||||||||||||||||||||||
| 732 | }; | ||||||||||||||||||||||||||||
| 733 | 114 | ▶ | if ( not $eval_ok ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 734 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||
| 735 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||
| 736 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 737 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||
| 738 | qq{ The problem was in this RHS alternative:\n}, | ||||||||||||||||||||||||||||
| 739 | q{ }, | ||||||||||||||||||||||||||||
| 740 | $parse->substring( $alternative_start, $alternative_end ), | ||||||||||||||||||||||||||||
| 741 | "\n" | ||||||||||||||||||||||||||||
| 742 | ); | ||||||||||||||||||||||||||||
| 743 | } ## end if ( not $eval_ok ) | ||||||||||||||||||||||||||||
| 744 | 114 | push @working_rules, [ $priority, $rhs, $adverb_list ]; | |||||||||||||||||||||||||||
| 745 | } ## end for my $alternative (@alternatives) | ||||||||||||||||||||||||||||
| 746 | } ## end for my $priority_ix ( 0 .. $priority_count - 1 ) | ||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | # Default mask (all ones) is OK for this rule | ||||||||||||||||||||||||||||
| 749 | 19 | my @arg0_action = (); | |||||||||||||||||||||||||||
| 750 | 19 | ▶ | @arg0_action = ( action => '::first' ) if $subgrammar eq 'G1'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 751 | 19 | push @{$rules}, | |||||||||||||||||||||||||||
| 752 | { | ||||||||||||||||||||||||||||
| 753 | lhs => $lhs, | ||||||||||||||||||||||||||||
| 754 | rhs => [ $parse->prioritized_symbol( $lhs, 0 ) ], | ||||||||||||||||||||||||||||
| 755 | @arg0_action, | ||||||||||||||||||||||||||||
| 756 | description => qq{Internal rule top priority rule for <$lhs>}, | ||||||||||||||||||||||||||||
| 757 | }, | ||||||||||||||||||||||||||||
| 758 | ( | ||||||||||||||||||||||||||||
| 759 | map { | ||||||||||||||||||||||||||||
| 760 | 19 | ; | |||||||||||||||||||||||||||
| 761 | 56 | { lhs => $parse->prioritized_symbol( $lhs, $_ - 1 ), | |||||||||||||||||||||||||||
| 762 | rhs => [ $parse->prioritized_symbol( $lhs, $_ ) ], | ||||||||||||||||||||||||||||
| 763 | description => ( | ||||||||||||||||||||||||||||
| 764 | qq{Internal rule for symbol <$lhs> priority transition from } | ||||||||||||||||||||||||||||
| 765 | . ( $_ - 1 ) | ||||||||||||||||||||||||||||
| 766 | . qq{ to $_} | ||||||||||||||||||||||||||||
| 767 | ), | ||||||||||||||||||||||||||||
| 768 | @arg0_action | ||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||
| 770 | } 1 .. $priority_count - 1 | ||||||||||||||||||||||||||||
| 771 | ); | ||||||||||||||||||||||||||||
| 772 | 19 | RULE: for my $working_rule (@working_rules) { | |||||||||||||||||||||||||||
| 773 | 114 | my ( $priority, $rhs, $adverb_list ) = @{$working_rule}; | |||||||||||||||||||||||||||
| 774 | 114 | my @new_rhs = @{ $rhs->{rhs} }; | |||||||||||||||||||||||||||
| 775 | 114 | my @arity = grep { $new_rhs[$_] eq $lhs } 0 .. $#new_rhs; | |||||||||||||||||||||||||||
| 776 | 114 | my $rhs_length = scalar @new_rhs; | |||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | 114 | my $current_exp = $parse->prioritized_symbol( $lhs, $priority ); | |||||||||||||||||||||||||||
| 779 | 114 | my @mask = @{ $rhs->{mask} }; | |||||||||||||||||||||||||||
| 780 | 114 | ▶ | if ( ( substr $subgrammar, 0, 1 ) eq 'L' and grep { !$_ } @mask ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
substr($subgrammar, 0, 1) eq "L" and grep {not $_;} @mask
MC/DC0%0/2
substr($subgrammar, 0, 1) eq "L" and grep {not $_;} @mask
substr($subgrammar, 0, 1) eq "L"
grep {not $_;} @mask
Truth table33%1/3
A and B
A= substr($subgrammar, 0, 1) eq "L"B= grep {not $_;} @mask
| |||||||||||||||||||||||||||||
| 781 | { | ||||||||||||||||||||||||||||
| 782 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 783 | 'hidden symbols are not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||
| 784 | $lhs, '")' | ||||||||||||||||||||||||||||
| 785 | ); | ||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||
| 787 | 114 | my %new_xs_rule = ( lhs => $current_exp ); | |||||||||||||||||||||||||||
| 788 | 114 | $new_xs_rule{mask} = \@mask; | |||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | 114 | my $action; | |||||||||||||||||||||||||||
| 791 | my $assoc; | ||||||||||||||||||||||||||||
| 792 | 114 | my $blessing; | |||||||||||||||||||||||||||
| 793 | 114 | my $naming; | |||||||||||||||||||||||||||
| 794 | 114 | my $rank; | |||||||||||||||||||||||||||
| 795 | 114 | my $null_ranking; | |||||||||||||||||||||||||||
| 796 | 114 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 797 | 108 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 798 | 108 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 799 | 44 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 800 | 44 | next ADVERB; | |||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||
| 802 | 64 | ▶ | if ( $key eq 'assoc' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 803 | 21 | $assoc = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 804 | 21 | next ADVERB; | |||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||
| 806 | 43 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 807 | 43 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 808 | 43 | next ADVERB; | |||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||
| 810 | 0 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 811 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 812 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||
| 814 | 0 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 815 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 816 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||
| 818 | 0 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 819 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 820 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||
| 822 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 823 | 0 | die qq{Adverb "$key" not allowed in a prioritized rule\n}, | |||||||||||||||||||||||||||
| 824 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 825 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | 114 | ▶ | $assoc //= 'L'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$assoc //= "L"
MC/DC100%1/1
$assoc //= "L"
$assoc
Truth table100%2/2
A
A= $assoc
| |||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||
| 829 | 114 | ▶ | $action //= $default_adverbs->{action}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$action //= $default_adverbs->{"action"}
MC/DC100%2/2
$action //= $default_adverbs->{"action"}
$action
$default_adverbs->{"action"}
Truth table100%3/3
A //= B
A= $actionB= $default_adverbs->{"action"}
| |||||||||||||||||||||||||||||
| 830 | 114 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 831 | 107 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 832 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 833 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 834 | 107 | $new_xs_rule{action} = $action; | |||||||||||||||||||||||||||
| 835 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | 114 | ▶ | $null_ranking //= $default_adverbs->{null_ranking}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$null_ranking //= $default_adverbs->{"null_ranking"}
MC/DC0%0/2
$null_ranking //= $default_adverbs->{"null_ranking"}
$null_ranking
$default_adverbs->{"null_ranking"}
Truth table33%1/3
A //= B
A= $null_rankingB= $default_adverbs->{"null_ranking"}
| |||||||||||||||||||||||||||||
| 838 | 114 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 839 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 840 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 841 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 842 | 0 | $new_xs_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||
| 843 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | 114 | ▶ | $rank //= $default_adverbs->{rank}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$rank //= $default_adverbs->{"rank"}
MC/DC0%0/2
$rank //= $default_adverbs->{"rank"}
$rank
$default_adverbs->{"rank"}
Truth table33%1/3
A //= B
A= $rankB= $default_adverbs->{"rank"}
| |||||||||||||||||||||||||||||
| 846 | 114 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 847 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 848 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 849 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 850 | 0 | $new_xs_rule{rank} = $rank; | |||||||||||||||||||||||||||
| 851 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | 114 | ▶ | $blessing //= $default_adverbs->{bless}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$blessing //= $default_adverbs->{"bless"}
MC/DC100%2/2
$blessing //= $default_adverbs->{"bless"}
$blessing
$default_adverbs->{"bless"}
Truth table100%3/3
A //= B
A= $blessingB= $default_adverbs->{"bless"}
| |||||||||||||||||||||||||||||
| 854 | 114 | ▶ | if ( defined $blessing | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $blessing and substr($subgrammar, 0, 1) eq "L"
MC/DC0%0/2
defined $blessing and substr($subgrammar, 0, 1) eq "L"
defined $blessing
substr($subgrammar, 0, 1) eq "L"
Truth table66%2/3
A and B
A= defined $blessingB= substr($subgrammar, 0, 1) eq "L"
| |||||||||||||||||||||||||||||
| 855 | and ( substr $subgrammar, 0, 1 ) eq 'L' ) | ||||||||||||||||||||||||||||
| 856 | { | ||||||||||||||||||||||||||||
| 857 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 858 | 'bless option not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||
| 859 | $lhs, '")' | ||||||||||||||||||||||||||||
| 860 | ); | ||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | 114 | $parse->bless_hash_rule( \%new_xs_rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||
| 865 | 114 | my $next_priority = $priority + 1; | |||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||
| 867 | # This is probably a mis-feature. It probably should be | ||||||||||||||||||||||||||||
| 868 | # $next_priority = $priority if $next_priority >= $priority_count; | ||||||||||||||||||||||||||||
| 869 | # However, I probably will not change this, because some apps | ||||||||||||||||||||||||||||
| 870 | # may be relying on this behavior. | ||||||||||||||||||||||||||||
| 871 | 114 | ▶ | $next_priority = 0 if $next_priority >= $priority_count; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||
| 873 | 114 | my $next_exp = $parse->prioritized_symbol( $lhs, $next_priority); | |||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | 114 | ▶ | if ( not scalar @arity ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 876 | 29 | $new_xs_rule{rhs} = \@new_rhs; | |||||||||||||||||||||||||||
| 877 | 29 | push @{$rules}, \%new_xs_rule; | |||||||||||||||||||||||||||
| 878 | 29 | next RULE; | |||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | 85 | ▶ | if ( scalar @arity == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 882 | 19 | ▶ | die 'Unnecessary unit rule in priority rule' if $rhs_length == 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 883 | 19 | $new_rhs[ $arity[0] ] = $current_exp; | |||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||
| 885 | DO_ASSOCIATION: { | ||||||||||||||||||||||||||||
| 886 | 85 | ▶ | if ( $assoc eq 'L' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 887 | 64 | $new_rhs[ $arity[0] ] = $current_exp; | |||||||||||||||||||||||||||
| 888 | 64 | for my $rhs_ix ( @arity[ 1 .. $#arity ] ) { | |||||||||||||||||||||||||||
| 889 | 56 | $new_rhs[$rhs_ix] = $next_exp; | |||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||
| 891 | 64 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||
| 892 | } ## end if ( $assoc eq 'L' ) | ||||||||||||||||||||||||||||
| 893 | 21 | ▶ | if ( $assoc eq 'R' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 894 | 10 | $new_rhs[ $arity[-1] ] = $current_exp; | |||||||||||||||||||||||||||
| 895 | 10 | for my $rhs_ix ( @arity[ 0 .. $#arity - 1 ] ) { | |||||||||||||||||||||||||||
| 896 | 10 | $new_rhs[$rhs_ix] = $next_exp; | |||||||||||||||||||||||||||
| 897 | } | ||||||||||||||||||||||||||||
| 898 | 10 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||
| 899 | } ## end if ( $assoc eq 'R' ) | ||||||||||||||||||||||||||||
| 900 | 11 | ▶ | if ( $assoc eq 'G' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 901 | 11 | for my $rhs_ix ( @arity[ 0 .. $#arity ] ) { | |||||||||||||||||||||||||||
| 902 | 11 | $new_rhs[$rhs_ix] = $parse->prioritized_symbol( $lhs, 0 ); | |||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||
| 904 | 11 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||
| 905 | } ## end if ( $assoc eq 'G' ) | ||||||||||||||||||||||||||||
| 906 | 0 | die qq{Unknown association type: "$assoc"}; | |||||||||||||||||||||||||||
| 907 | } ## end DO_ASSOCIATION: | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | 85 | $new_xs_rule{rhs} = \@new_rhs; | |||||||||||||||||||||||||||
| 910 | 85 | push @{$rules}, \%new_xs_rule; | |||||||||||||||||||||||||||
| 911 | } ## end RULE: for my $working_rule (@working_rules) | ||||||||||||||||||||||||||||
| 912 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 913 | 19 | return undef; | |||||||||||||||||||||||||||
| 914 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::priority_rule::evaluate | ||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||
| 916 | sub Marpa::R2::Internal::MetaAST_Nodes::empty_rule::evaluate { | ||||||||||||||||||||||||||||
| 917 | 62 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=23 SCAR=42.4
| |||||||||||||||||||||||||||||
| 918 | my ( $start, $length, $raw_lhs, $op_declare, $raw_adverb_list ) = | ||||||||||||||||||||||||||||
| 919 | 62 | @{$values}; | |||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | 62 | my $current_lexer = $parse->{current_lexer}; | |||||||||||||||||||||||||||
| 922 | 62 | my $subgrammar; | |||||||||||||||||||||||||||
| 923 | 62 | ▶ | if ( $op_declare->op() eq q{::=} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 924 | 61 | ▶ | if ( $current_lexer ne 'L0' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 925 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 926 | 0 | die "G1 rules currently allowed only when L0 is current lexer\n", | |||||||||||||||||||||||||||
| 927 | qq{ An empty rule was found when "$current_lexer" was the current lexer\n"}, | ||||||||||||||||||||||||||||
| 928 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 929 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 930 | } ## end if ( $current_lexer ne 'L0' ) | ||||||||||||||||||||||||||||
| 931 | 61 | $subgrammar = 'G1'; | |||||||||||||||||||||||||||
| 932 | } ## end if ( $op_declare->op() eq q{::=} ) | ||||||||||||||||||||||||||||
| 933 | else { | ||||||||||||||||||||||||||||
| 934 | 1 | $subgrammar = $current_lexer; | |||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | 62 | my $lhs = $raw_lhs->name($parse); | |||||||||||||||||||||||||||
| 938 | 62 | ▶ | $parse->{'first_lhs'} //= $lhs if $subgrammar eq 'G1'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parse->{"first_lhs"} //= $lhs
MC/DC0%0/2
$parse->{"first_lhs"} //= $lhs
$parse->{"first_lhs"}
$lhs
Truth table66%2/3
A //= B
A= $parse->{"first_lhs"}B= $lhs
| |||||||||||||||||||||||||||||
| 939 | 62 | local $Marpa::R2::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||
| 941 | 62 | my %rule = ( lhs => $lhs, | |||||||||||||||||||||||||||
| 942 | description => qq{Empty rule for <$lhs>}, | ||||||||||||||||||||||||||||
| 943 | rhs => [] ); | ||||||||||||||||||||||||||||
| 944 | 62 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | 62 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||
| 948 | 62 | my $action; | |||||||||||||||||||||||||||
| 949 | my $blessing; | ||||||||||||||||||||||||||||
| 950 | 62 | my $naming; | |||||||||||||||||||||||||||
| 951 | 62 | my $rank; | |||||||||||||||||||||||||||
| 952 | 62 | my $null_ranking; | |||||||||||||||||||||||||||
| 953 | 62 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 954 | 8 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 955 | 8 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 956 | 8 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 957 | 8 | next ADVERB; | |||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||
| 959 | 0 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 960 | 0 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 961 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||
| 963 | 0 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 964 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 965 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||
| 967 | 0 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 968 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 969 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||
| 971 | 0 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 972 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 973 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||
| 975 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 976 | 0 | die qq{Adverb "$key" not allowed in an empty rule\n}, | |||||||||||||||||||||||||||
| 977 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 978 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||
| 980 | 62 | ▶ | $action //= $default_adverbs->{action}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$action //= $default_adverbs->{"action"}
MC/DC100%2/2
$action //= $default_adverbs->{"action"}
$action
$default_adverbs->{"action"}
Truth table100%3/3
A //= B
A= $actionB= $default_adverbs->{"action"}
| |||||||||||||||||||||||||||||
| 981 | 62 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 982 | 33 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 983 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 984 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 985 | 33 | $rule{action} = $action; | |||||||||||||||||||||||||||
| 986 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||
| 988 | 62 | ▶ | $null_ranking //= $default_adverbs->{null_ranking}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$null_ranking //= $default_adverbs->{"null_ranking"}
MC/DC0%0/2
$null_ranking //= $default_adverbs->{"null_ranking"}
$null_ranking
$default_adverbs->{"null_ranking"}
Truth table33%1/3
A //= B
A= $null_rankingB= $default_adverbs->{"null_ranking"}
| |||||||||||||||||||||||||||||
| 989 | 62 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 990 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 991 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 992 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 993 | 0 | $rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||
| 994 | } ## end if ( defined $null_ranking ) | ||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||
| 996 | 62 | ▶ | $rank //= $default_adverbs->{rank}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$rank //= $default_adverbs->{"rank"}
MC/DC0%0/2
$rank //= $default_adverbs->{"rank"}
$rank
$default_adverbs->{"rank"}
Truth table33%1/3
A //= B
A= $rankB= $default_adverbs->{"rank"}
| |||||||||||||||||||||||||||||
| 997 | 62 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 998 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 999 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1000 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 1001 | 0 | $rule{rank} = $rank; | |||||||||||||||||||||||||||
| 1002 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||
| 1004 | 62 | ▶ | $blessing //= $default_adverbs->{bless}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$blessing //= $default_adverbs->{"bless"}
MC/DC0%0/2
$blessing //= $default_adverbs->{"bless"}
$blessing
$default_adverbs->{"bless"}
Truth table33%1/3
A //= B
A= $blessingB= $default_adverbs->{"bless"}
| |||||||||||||||||||||||||||||
| 1005 | 62 | ▶ | if ( defined $blessing | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $blessing and substr($subgrammar, 0, 1) eq "L"
MC/DC0%0/2
defined $blessing and substr($subgrammar, 0, 1) eq "L"
defined $blessing
substr($subgrammar, 0, 1) eq "L"
Truth table33%1/3
A and B
A= defined $blessingB= substr($subgrammar, 0, 1) eq "L"
| |||||||||||||||||||||||||||||
| 1006 | and ( substr $subgrammar, 0, 1 ) eq 'L' ) | ||||||||||||||||||||||||||||
| 1007 | { | ||||||||||||||||||||||||||||
| 1008 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 1009 | qq{bless option not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1010 | ); | ||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||
| 1012 | 62 | $parse->bless_hash_rule( \%rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | # mask not needed | ||||||||||||||||||||||||||||
| 1015 | 62 | push @{ $parse->{rules}->{$subgrammar} }, \%rule; | |||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||
| 1017 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1018 | 62 | return undef; | |||||||||||||||||||||||||||
| 1019 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::empty_rule::evaluate | ||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||
| 1021 | sub Marpa::R2::Internal::MetaAST_Nodes::lexeme_rule::evaluate { | ||||||||||||||||||||||||||||
| 1022 | 63 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=11 SCAR=25.2
| |||||||||||||||||||||||||||||
| 1023 | 63 | my ( $start, $length, $symbol, $unevaluated_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||
| 1025 | 63 | my $symbol_name = $symbol->name(); | |||||||||||||||||||||||||||
| 1026 | 63 | my $declarations = $parse->{lexeme_declarations}->{$symbol_name}; | |||||||||||||||||||||||||||
| 1027 | 63 | ▶ | if ( defined $declarations ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1028 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1029 | 0 | die "Duplicate lexeme rule for <$symbol_name>\n", | |||||||||||||||||||||||||||
| 1030 | " Only one lexeme rule is allowed for each symbol\n", | ||||||||||||||||||||||||||||
| 1031 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 1032 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1033 | } ## end if ( defined $declarations ) | ||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||
| 1035 | 63 | my $adverb_list = $unevaluated_adverb_list->evaluate(); | |||||||||||||||||||||||||||
| 1036 | 63 | my %declarations; | |||||||||||||||||||||||||||
| 1037 | 63 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 1038 | 107 | my $raw_value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1039 | 107 | ▶ | if ( $key eq 'priority' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1040 | 2 | $declarations{$key} = $raw_value + 0; | |||||||||||||||||||||||||||
| 1041 | 2 | next ADVERB; | |||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||
| 1043 | 105 | ▶ | if ( $key eq 'pause' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1044 | 54 | ▶ | if ( $raw_value eq 'before' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1045 | 10 | $declarations{$key} = -1; | |||||||||||||||||||||||||||
| 1046 | 10 | next ADVERB; | |||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||
| 1048 | 44 | ▶ | if ( $raw_value eq 'after' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1049 | 44 | $declarations{$key} = 1; | |||||||||||||||||||||||||||
| 1050 | 44 | next ADVERB; | |||||||||||||||||||||||||||
| 1051 | } | ||||||||||||||||||||||||||||
| 1052 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1053 | 0 | die qq{Bad value for "pause" adverb: "$raw_value"}, | |||||||||||||||||||||||||||
| 1054 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 1055 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1056 | } ## end if ( $key eq 'pause' ) | ||||||||||||||||||||||||||||
| 1057 | 51 | ▶ | if ( $key eq 'event' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1058 | 49 | $declarations{$key} = $raw_value; | |||||||||||||||||||||||||||
| 1059 | 49 | next ADVERB; | |||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||
| 1061 | 2 | ▶ | if ( $key eq 'latm' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1062 | 2 | $declarations{$key} = $raw_value; | |||||||||||||||||||||||||||
| 1063 | 2 | next ADVERB; | |||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||
| 1065 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1066 | 0 | die qq{"$key" adverb not allowed in lexeme rule"\n}, | |||||||||||||||||||||||||||
| 1067 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 1068 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1069 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 1070 | 63 | ▶ | if ( exists $declarations{'event'} and not exists $declarations{'pause'} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $declarations{"event"} and not exists $declarations{"pause"}
MC/DC0%0/2
exists $declarations{"event"} and not exists $declarations{"pause"}
exists $declarations{"event"}
not exists $declarations{"pause"}
Truth table66%2/3
A and not(B)
A= exists $declarations{"event"}B= not exists $declarations{"pause"}
| |||||||||||||||||||||||||||||
| 1071 | { | ||||||||||||||||||||||||||||
| 1072 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1073 | 0 | die | |||||||||||||||||||||||||||
| 1074 | qq{"event" adverb not allowed without "pause" adverb in lexeme rule"\n}, | ||||||||||||||||||||||||||||
| 1075 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 1076 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1077 | } ## end if ( exists $declarations{'event'} and not exists $declarations...) | ||||||||||||||||||||||||||||
| 1078 | 63 | $parse->{lexeme_declarations}->{$symbol_name} = \%declarations; | |||||||||||||||||||||||||||
| 1079 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1080 | 63 | return undef; | |||||||||||||||||||||||||||
| 1081 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::lexeme_rule::evaluate | ||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||
| 1083 | sub Marpa::R2::Internal::MetaAST_Nodes::statements::evaluate { | ||||||||||||||||||||||||||||
| 1084 | 12 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1085 | 12 | my ( undef, undef, @statement_list ) = @{$data}; | |||||||||||||||||||||||||||
| 1086 | 12 | map { $_->evaluate($parse) } @statement_list; | |||||||||||||||||||||||||||
| 1087 | 12 | return undef; | |||||||||||||||||||||||||||
| 1088 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::statements::evaluate | ||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||
| 1090 | sub Marpa::R2::Internal::MetaAST_Nodes::statement::evaluate { | ||||||||||||||||||||||||||||
| 1091 | 2126 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1092 | 2126 | my ( undef, undef, $child ) = @{$data}; | |||||||||||||||||||||||||||
| 1093 | 2126 | $child->evaluate($parse); | |||||||||||||||||||||||||||
| 1094 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1095 | 2126 | return undef; | |||||||||||||||||||||||||||
| 1096 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::statement::evaluate | ||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||
| 1098 | sub Marpa::R2::Internal::MetaAST_Nodes::null_statement::evaluate { | ||||||||||||||||||||||||||||
| 1099 | 22 | ▶ | return undef; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | sub Marpa::R2::Internal::MetaAST_Nodes::statement_group::evaluate { | ||||||||||||||||||||||||||||
| 1103 | 12 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1104 | 12 | my ( undef, undef, $statements ) = @{$data}; | |||||||||||||||||||||||||||
| 1105 | 12 | $statements->evaluate($parse); | |||||||||||||||||||||||||||
| 1106 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1107 | 12 | return undef; | |||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | sub Marpa::R2::Internal::MetaAST::start_rule_create { | ||||||||||||||||||||||||||||
| 1111 | 285 | ▶ | my ( $parse, $symbol_name ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
start_rule_create: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1112 | 285 | my $start_lhs = '[:start]'; | |||||||||||||||||||||||||||
| 1113 | $parse->{'default_g1_start_action'} = | ||||||||||||||||||||||||||||
| 1114 | 285 | $parse->{'default_adverbs'}->{'G1'}->{'action'}; | |||||||||||||||||||||||||||
| 1115 | 285 | $parse->{'symbols'}->{'G1'}->{$start_lhs} = { | |||||||||||||||||||||||||||
| 1116 | display_form => ':start', | ||||||||||||||||||||||||||||
| 1117 | description => 'Internal G1 start symbol' | ||||||||||||||||||||||||||||
| 1118 | }; | ||||||||||||||||||||||||||||
| 1119 | 285 | push @{ $parse->{rules}->{G1} }, | |||||||||||||||||||||||||||
| 1120 | { | ||||||||||||||||||||||||||||
| 1121 | lhs => $start_lhs, | ||||||||||||||||||||||||||||
| 1122 | rhs => [$symbol_name], | ||||||||||||||||||||||||||||
| 1123 | action => '::first' | ||||||||||||||||||||||||||||
| 1124 | }; | ||||||||||||||||||||||||||||
| 1125 | } ## end sub Marpa::R2::Internal::MetaAST::start_rule_create | ||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||
| 1127 | sub Marpa::R2::Internal::MetaAST_Nodes::start_rule::evaluate { | ||||||||||||||||||||||||||||
| 1128 | 104 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||
| 1129 | 104 | my ( $start, $length, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1130 | 104 | ▶ | if ( defined $parse->{'start_lhs'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1131 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1132 | 0 | die qq{There are two start rules\n}, | |||||||||||||||||||||||||||
| 1133 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||
| 1134 | ' The second start rule is ', | ||||||||||||||||||||||||||||
| 1135 | $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||
| 1136 | "\n", | ||||||||||||||||||||||||||||
| 1137 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||
| 1138 | } ## end if ( defined $parse->{'start_lhs'} ) | ||||||||||||||||||||||||||||
| 1139 | 104 | $parse->{'start_lhs'} = $symbol->name($parse); | |||||||||||||||||||||||||||
| 1140 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1141 | 104 | return undef; | |||||||||||||||||||||||||||
| 1142 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::start_rule::evaluate | ||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||
| 1144 | sub Marpa::R2::Internal::MetaAST_Nodes::discard_rule::evaluate { | ||||||||||||||||||||||||||||
| 1145 | 149 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 1146 | 149 | my ( $start, $length, $symbol, $raw_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||
| 1148 | 149 | my $lexer_name = $parse->{current_lexer}; | |||||||||||||||||||||||||||
| 1149 | 149 | local $Marpa::R2::Internal::SUBGRAMMAR = $lexer_name; | |||||||||||||||||||||||||||
| 1150 | 149 | my $discard_lhs = '[:discard]'; | |||||||||||||||||||||||||||
| 1151 | 149 | $parse->symbol_names_set( | |||||||||||||||||||||||||||
| 1152 | $discard_lhs, | ||||||||||||||||||||||||||||
| 1153 | 'L', | ||||||||||||||||||||||||||||
| 1154 | { display_form => ':discard', | ||||||||||||||||||||||||||||
| 1155 | description => qq{Internal LHS for lexer "$lexer_name" discard} | ||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||
| 1157 | ); | ||||||||||||||||||||||||||||
| 1158 | 149 | my $rhs = $symbol->names($parse); | |||||||||||||||||||||||||||
| 1159 | 149 | my $rhs_as_event = $symbol->event_name($parse); | |||||||||||||||||||||||||||
| 1160 | 149 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 1161 | 149 | my $event; | |||||||||||||||||||||||||||
| 1162 | 149 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 1163 | 51 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1164 | 51 | ▶ | if ( $key eq 'event' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1165 | 51 | $event = $value; | |||||||||||||||||||||||||||
| 1166 | 51 | next ADVERB; | |||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||
| 1168 | Marpa::R2::exception( | ||||||||||||||||||||||||||||
| 1169 | 0 | qq{"$key" adverb not allowed as discard default"}); | |||||||||||||||||||||||||||
| 1170 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 1171 | my %rule_hash = ( | ||||||||||||||||||||||||||||
| 1172 | description => ( | ||||||||||||||||||||||||||||
| 1173 | "Discard rule for " . join q{ }, | ||||||||||||||||||||||||||||
| 1174 | 149 | map { '<' . $_ . '>' } @{$rhs} | |||||||||||||||||||||||||||
| 1175 | ), | ||||||||||||||||||||||||||||
| 1176 | lhs => $discard_lhs, | ||||||||||||||||||||||||||||
| 1177 | rhs => $rhs, | ||||||||||||||||||||||||||||
| 1178 | symbol_as_event => $rhs_as_event | ||||||||||||||||||||||||||||
| 1179 | ); | ||||||||||||||||||||||||||||
| 1180 | 149 | ▶ | $rule_hash{event} = $event if defined $event; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1181 | 149 | push @{ $parse->{rules}->{$lexer_name} }, \%rule_hash; | |||||||||||||||||||||||||||
| 1182 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1183 | 149 | return undef; | |||||||||||||||||||||||||||
| 1184 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::discard_rule::evaluate | ||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||
| 1186 | sub Marpa::R2::Internal::MetaAST_Nodes::quantified_rule::evaluate { | ||||||||||||||||||||||||||||
| 1187 | 234 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=28 SCAR=37.4
| |||||||||||||||||||||||||||||
| 1188 | my ( $start, $length, $lhs, $op_declare, $rhs, $quantifier, | ||||||||||||||||||||||||||||
| 1189 | $proto_adverb_list ) | ||||||||||||||||||||||||||||
| 1190 | 234 | = @{$values}; | |||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||
| 1192 | 234 | my $subgrammar; | |||||||||||||||||||||||||||
| 1193 | 234 | my $current_lexer = $parse->{current_lexer}; | |||||||||||||||||||||||||||
| 1194 | 234 | ▶ | if ( $op_declare->op() eq q{::=} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1195 | 93 | ▶ | if ( $current_lexer ne 'L0' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1196 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1197 | 0 | die "G1 rules currently allowed only when L0 is current lexer\n", | |||||||||||||||||||||||||||
| 1198 | qq{ A quantified rule was found when "$current_lexer" was the current lexer\n"}, | ||||||||||||||||||||||||||||
| 1199 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||
| 1200 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1201 | } ## end if ( $current_lexer ne 'L0' ) | ||||||||||||||||||||||||||||
| 1202 | 93 | $subgrammar = 'G1'; | |||||||||||||||||||||||||||
| 1203 | } ## end if ( $op_declare->op() eq q{::=} ) | ||||||||||||||||||||||||||||
| 1204 | else { | ||||||||||||||||||||||||||||
| 1205 | 141 | $subgrammar = $current_lexer; | |||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||
| 1208 | 234 | my $lhs_name = $lhs->name($parse); | |||||||||||||||||||||||||||
| 1209 | 234 | ▶ | $parse->{'first_lhs'} //= $lhs_name if $subgrammar eq 'G1'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parse->{"first_lhs"} //= $lhs_name
MC/DC0%0/2
$parse->{"first_lhs"} //= $lhs_name
$parse->{"first_lhs"}
$lhs_name
Truth table66%2/3
A //= B
A= $parse->{"first_lhs"}B= $lhs_name
| |||||||||||||||||||||||||||||
| 1210 | 234 | local $Marpa::R2::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||
| 1212 | 234 | my $adverb_list = $proto_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||
| 1213 | 234 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||
| 1215 | # Some properties of the sequence rule will not be altered | ||||||||||||||||||||||||||||
| 1216 | # no matter how complicated this gets | ||||||||||||||||||||||||||||
| 1217 | 234 | ▶ | my %sequence_rule = ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1218 | rhs => [ $rhs->name($parse) ], | ||||||||||||||||||||||||||||
| 1219 | min => ( $quantifier->evaluate($parse) eq q{+} ? 1 : 0 ) | ||||||||||||||||||||||||||||
| 1220 | ); | ||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||
| 1222 | 234 | my @rules = ( \%sequence_rule ); | |||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||
| 1224 | 234 | my $action; | |||||||||||||||||||||||||||
| 1225 | my $blessing; | ||||||||||||||||||||||||||||
| 1226 | 234 | my $naming; | |||||||||||||||||||||||||||
| 1227 | 234 | my $separator; | |||||||||||||||||||||||||||
| 1228 | 234 | my $proper; | |||||||||||||||||||||||||||
| 1229 | 234 | my $rank; | |||||||||||||||||||||||||||
| 1230 | 234 | my $null_ranking; | |||||||||||||||||||||||||||
| 1231 | 234 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||
| 1232 | 67 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1233 | 67 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1234 | 50 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1235 | 50 | next ADVERB; | |||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||
| 1237 | 17 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1238 | 3 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1239 | 3 | next ADVERB; | |||||||||||||||||||||||||||
| 1240 | } | ||||||||||||||||||||||||||||
| 1241 | 14 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1242 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1243 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 1244 | } | ||||||||||||||||||||||||||||
| 1245 | 14 | ▶ | if ( $key eq 'proper' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1246 | 1 | $proper = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1247 | 1 | next ADVERB; | |||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||
| 1249 | 13 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1250 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1251 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 1252 | } | ||||||||||||||||||||||||||||
| 1253 | 13 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1254 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1255 | 0 | next ADVERB; | |||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||
| 1257 | 13 | ▶ | if ( $key eq 'separator' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1258 | 13 | $separator = $adverb_list->{$key}; | |||||||||||||||||||||||||||
| 1259 | 13 | next ADVERB; | |||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||
| 1261 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1262 | 0 | die qq{Adverb "$key" not allowed in quantified rule\n}, | |||||||||||||||||||||||||||
| 1263 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||
| 1264 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||
| 1266 | # mask not needed | ||||||||||||||||||||||||||||
| 1267 | 234 | $sequence_rule{lhs} = $lhs_name; | |||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | 234 | ▶ | $sequence_rule{separator} = $separator | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1270 | if defined $separator; | ||||||||||||||||||||||||||||
| 1271 | 234 | ▶ | $sequence_rule{proper} = $proper if defined $proper; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||
| 1273 | 234 | ▶ | $action //= $default_adverbs->{action}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$action //= $default_adverbs->{"action"}
MC/DC100%2/2
$action //= $default_adverbs->{"action"}
$action
$default_adverbs->{"action"}
Truth table100%3/3
A //= B
A= $actionB= $default_adverbs->{"action"}
| |||||||||||||||||||||||||||||
| 1274 | 234 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1275 | 71 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1276 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1277 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 1278 | 71 | $sequence_rule{action} = $action; | |||||||||||||||||||||||||||
| 1279 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||
| 1281 | 234 | ▶ | $null_ranking //= $default_adverbs->{null_ranking}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$null_ranking //= $default_adverbs->{"null_ranking"}
MC/DC0%0/2
$null_ranking //= $default_adverbs->{"null_ranking"}
$null_ranking
$default_adverbs->{"null_ranking"}
Truth table33%1/3
A //= B
A= $null_rankingB= $default_adverbs->{"null_ranking"}
| |||||||||||||||||||||||||||||
| 1282 | 234 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1284 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1285 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 1286 | 0 | $sequence_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||
| 1287 | } ## end if ( defined $null_ranking ) | ||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||
| 1289 | 234 | ▶ | $rank //= $default_adverbs->{rank}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$rank //= $default_adverbs->{"rank"}
MC/DC0%0/2
$rank //= $default_adverbs->{"rank"}
$rank
$default_adverbs->{"rank"}
Truth table33%1/3
A //= B
A= $rankB= $default_adverbs->{"rank"}
| |||||||||||||||||||||||||||||
| 1290 | 234 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1291 | 0 | ▶ | Marpa::R2::exception( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1292 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1293 | ) if ( substr $subgrammar, 0, 1 ) eq 'L'; | ||||||||||||||||||||||||||||
| 1294 | 0 | $sequence_rule{rank} = $rank; | |||||||||||||||||||||||||||
| 1295 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||
| 1297 | 234 | ▶ | $blessing //= $default_adverbs->{bless}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$blessing //= $default_adverbs->{"bless"}
MC/DC100%2/2
$blessing //= $default_adverbs->{"bless"}
$blessing
$default_adverbs->{"bless"}
Truth table100%3/3
A //= B
A= $blessingB= $default_adverbs->{"bless"}
| |||||||||||||||||||||||||||||
| 1298 | 234 | ▶ | if ( defined $blessing and ( substr $subgrammar, 0, 1 ) eq 'L' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $blessing and substr($subgrammar, 0, 1) eq "L"
MC/DC0%0/2
defined $blessing and substr($subgrammar, 0, 1) eq "L"
defined $blessing
substr($subgrammar, 0, 1) eq "L"
Truth table66%2/3
A and B
A= defined $blessingB= substr($subgrammar, 0, 1) eq "L"
| |||||||||||||||||||||||||||||
| 1299 | { | ||||||||||||||||||||||||||||
| 1300 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 1301 | qq{bless option not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||
| 1302 | ); | ||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||
| 1304 | 234 | $parse->bless_hash_rule( \%sequence_rule, $blessing, $naming, $lhs_name ); | |||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||
| 1306 | 234 | push @{ $parse->{rules}->{$subgrammar} }, @rules; | |||||||||||||||||||||||||||
| 1307 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1308 | 234 | return undef; | |||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||
| 1310 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::quantified_rule::evaluate | ||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||
| 1312 | sub Marpa::R2::Internal::MetaAST_Nodes::completion_event_declaration::evaluate | ||||||||||||||||||||||||||||
| 1313 | { | ||||||||||||||||||||||||||||
| 1314 | 54 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 1315 | 54 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||
| 1316 | 54 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||
| 1317 | 54 | ▶ | my $completion_events = $parse->{completion_events} //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parse->{"completion_events"} //= {}
MC/DC100%1/1
$parse->{"completion_events"} //= {}
$parse->{"completion_events"}
Truth table100%2/2
A
A= $parse->{"completion_events"}
| |||||||||||||||||||||||||||||
| 1318 | 54 | ▶ | if ( defined $completion_events->{$symbol_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1319 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1320 | 0 | die qq{Completion event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||
| 1321 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||
| 1322 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||
| 1323 | "\n", | ||||||||||||||||||||||||||||
| 1324 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||
| 1325 | } ## end if ( defined $completion_events->{$symbol_name} ) | ||||||||||||||||||||||||||||
| 1326 | 54 | $completion_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||
| 1327 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1328 | 54 | return undef; | |||||||||||||||||||||||||||
| 1329 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::completion_event_declaration::evaluate | ||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||
| 1331 | sub Marpa::R2::Internal::MetaAST_Nodes::nulled_event_declaration::evaluate { | ||||||||||||||||||||||||||||
| 1332 | 46 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 1333 | 46 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||
| 1334 | 46 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||
| 1335 | 46 | ▶ | my $nulled_events = $parse->{nulled_events} //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parse->{"nulled_events"} //= {}
MC/DC100%1/1
$parse->{"nulled_events"} //= {}
$parse->{"nulled_events"}
Truth table100%2/2
A
A= $parse->{"nulled_events"}
| |||||||||||||||||||||||||||||
| 1336 | 46 | ▶ | if ( defined $nulled_events->{$symbol_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1337 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1338 | 0 | die qq{nulled event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||
| 1339 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||
| 1340 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||
| 1341 | "\n", | ||||||||||||||||||||||||||||
| 1342 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||
| 1343 | } ## end if ( defined $nulled_events->{$symbol_name} ) | ||||||||||||||||||||||||||||
| 1344 | 46 | $nulled_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||
| 1345 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1346 | 46 | return undef; | |||||||||||||||||||||||||||
| 1347 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::nulled_event_declaration::evaluate | ||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||
| 1349 | sub Marpa::R2::Internal::MetaAST_Nodes::prediction_event_declaration::evaluate | ||||||||||||||||||||||||||||
| 1350 | { | ||||||||||||||||||||||||||||
| 1351 | 52 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||
| 1352 | 52 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||
| 1353 | 52 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||
| 1354 | 52 | ▶ | my $prediction_events = $parse->{prediction_events} //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parse->{"prediction_events"} //= {}
MC/DC100%1/1
$parse->{"prediction_events"} //= {}
$parse->{"prediction_events"}
Truth table100%2/2
A
A= $parse->{"prediction_events"}
| |||||||||||||||||||||||||||||
| 1355 | 52 | ▶ | if ( defined $prediction_events->{$symbol_name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1356 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1357 | 0 | die qq{prediction event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||
| 1358 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||
| 1359 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||
| 1360 | "\n", | ||||||||||||||||||||||||||||
| 1361 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||
| 1362 | } ## end if ( defined $prediction_events->{$symbol_name} ) | ||||||||||||||||||||||||||||
| 1363 | 52 | $prediction_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||
| 1364 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1365 | 52 | return undef; | |||||||||||||||||||||||||||
| 1366 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::prediction_event_declaration::evaluate | ||||||||||||||||||||||||||||
| 1367 | |||||||||||||||||||||||||||||
| 1368 | sub Marpa::R2::Internal::MetaAST_Nodes::current_lexer_statement::evaluate | ||||||||||||||||||||||||||||
| 1369 | { | ||||||||||||||||||||||||||||
| 1370 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 1371 | 0 | my ( $start, $length, $lexer_name_object ) = @{$values}; | |||||||||||||||||||||||||||
| 1372 | 0 | my $raw_lexer_name = $lexer_name_object->name(); | |||||||||||||||||||||||||||
| 1373 | 0 | ▶ | if ( $raw_lexer_name eq 'L0' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1374 | 0 | $parse->{current_lexer} = $raw_lexer_name; | |||||||||||||||||||||||||||
| 1375 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1376 | 0 | return undef; | |||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||
| 1378 | 0 | ▶ | if ( $raw_lexer_name =~ m/\A [[:upper:]] [[:digit:]]+ \z/xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1379 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||
| 1380 | 0 | die qq{Attempt to name a new lexer "$raw_lexer_name"\n}, | |||||||||||||||||||||||||||
| 1381 | qq{ Lexer names of the form [A-Z][0-9]+ are reserved\n}, | ||||||||||||||||||||||||||||
| 1382 | qq{ Please choose another name\n}, | ||||||||||||||||||||||||||||
| 1383 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||
| 1384 | } ## end if ( defined $prediction_events->{$symbol_name} ) | ||||||||||||||||||||||||||||
| 1385 | 0 | my $lexer_name .= 'L-' . $raw_lexer_name; | |||||||||||||||||||||||||||
| 1386 | 0 | $parse->{current_lexer} = $lexer_name; | |||||||||||||||||||||||||||
| 1387 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||
| 1388 | 0 | return undef; | |||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||
| 1391 | sub Marpa::R2::Internal::MetaAST_Nodes::alternatives::evaluate { | ||||||||||||||||||||||||||||
| 1392 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1393 | 0 | return bless [ map { $_->evaluate( $_, $parse ) } @{$values} ], | |||||||||||||||||||||||||||
| 1394 | ref $values; | ||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||
| 1397 | sub Marpa::R2::Internal::MetaAST_Nodes::alternative::evaluate { | ||||||||||||||||||||||||||||
| 1398 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 1399 | 0 | my ( $start, $length, $rhs, $adverbs ) = @{$values}; | |||||||||||||||||||||||||||
| 1400 | 0 | my $alternative = eval { | |||||||||||||||||||||||||||
| 1401 | Marpa::R2::Internal::MetaAST::Proto_Alternative->combine( | ||||||||||||||||||||||||||||
| 1402 | 0 | map { $_->evaluate($parse) } $rhs, $adverbs ); | |||||||||||||||||||||||||||
| 1403 | }; | ||||||||||||||||||||||||||||
| 1404 | 0 | ▶ | if ( not $alternative ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1405 | 0 | Marpa::R2::exception( | |||||||||||||||||||||||||||
| 1406 | $EVAL_ERROR, "\n", | ||||||||||||||||||||||||||||
| 1407 | q{ Alternative involved was }, | ||||||||||||||||||||||||||||
| 1408 | $parse->substring( $start, $length ) | ||||||||||||||||||||||||||||
| 1409 | ); | ||||||||||||||||||||||||||||
| 1410 | } ## end if ( not $alternative ) | ||||||||||||||||||||||||||||
| 1411 | 0 | return $alternative; | |||||||||||||||||||||||||||
| 1412 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::alternative::evaluate | ||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||
| 1414 | sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::names { | ||||||||||||||||||||||||||||
| 1415 | 149 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1416 | 149 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1417 | 149 | return $symbol->names($parse); | |||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||
| 1420 | sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::name { | ||||||||||||||||||||||||||||
| 1421 | 247 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1422 | 247 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1423 | 247 | return $symbol->name($parse); | |||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||
| 1426 | sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::event_name { | ||||||||||||||||||||||||||||
| 1427 | 149 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1428 | 149 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1429 | 149 | return $symbol->event_name($parse); | |||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||
| 1432 | sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::literal { | ||||||||||||||||||||||||||||
| 1433 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
literal: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1434 | 0 | my ( $start, $length ) = @{$values}; | |||||||||||||||||||||||||||
| 1435 | 0 | return $parse->substring($start, $length); | |||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||
| 1438 | sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::evaluate { | ||||||||||||||||||||||||||||
| 1439 | 2177 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1440 | 2177 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1441 | 2177 | return Marpa::R2::Internal::MetaAST::Symbol_List->new( | |||||||||||||||||||||||||||
| 1442 | $symbol->name($parse) ); | ||||||||||||||||||||||||||||
| 1443 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::single_symbol::evaluate | ||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||
| 1445 | sub Marpa::R2::Internal::MetaAST_Nodes::Symbol::evaluate { | ||||||||||||||||||||||||||||
| 1446 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1447 | 0 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||
| 1448 | 0 | return $symbol->evaluate($parse); | |||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||
| 1451 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol::name { | ||||||||||||||||||||||||||||
| 1452 | 2289 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1453 | 2289 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||
| 1456 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol::event_name { | ||||||||||||||||||||||||||||
| 1457 | 136 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1458 | 136 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||
| 1459 | } | ||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||
| 1461 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol::names { | ||||||||||||||||||||||||||||
| 1462 | 136 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1463 | 136 | return $self->[2]->names($parse); | |||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||
| 1466 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol_name::evaluate { | ||||||||||||||||||||||||||||
| 1467 | 4138 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1468 | 4138 | return $self->[2]; | |||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||
| 1471 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol_name::name { | ||||||||||||||||||||||||||||
| 1472 | 4138 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1473 | 4138 | return $self->evaluate($parse)->name($parse); | |||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||
| 1476 | sub Marpa::R2::Internal::MetaAST_Nodes::symbol_name::names { | ||||||||||||||||||||||||||||
| 1477 | 136 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1478 | 136 | return [ $self->name($parse) ]; | |||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||
| 1481 | sub Marpa::R2::Internal::MetaAST_Nodes::adverb_list::evaluate { | ||||||||||||||||||||||||||||
| 1482 | 2363 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1483 | 2363 | my ( undef, undef, $adverb_list_items ) = @{$data}; | |||||||||||||||||||||||||||
| 1484 | 2363 | ▶ | return undef if not defined $adverb_list_items; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1485 | 725 | return $adverb_list_items->evaluate($parse); | |||||||||||||||||||||||||||
| 1486 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::adverb_list::evaluate | ||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||
| 1488 | sub Marpa::R2::Internal::MetaAST_Nodes::null_adverb::evaluate { | ||||||||||||||||||||||||||||
| 1489 | 6 | ▶ | return {}; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||
| 1492 | sub Marpa::R2::Internal::MetaAST_Nodes::adverb_list_items::evaluate { | ||||||||||||||||||||||||||||
| 1493 | 725 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1494 | 725 | my ( undef, undef, @raw_items ) = @{$data}; | |||||||||||||||||||||||||||
| 1495 | 725 | my (@adverb_items) = map { $_->evaluate($parse) } @raw_items; | |||||||||||||||||||||||||||
| 1496 | 725 | return Marpa::R2::Internal::MetaAST::Proto_Alternative->combine( | |||||||||||||||||||||||||||
| 1497 | @adverb_items); | ||||||||||||||||||||||||||||
| 1498 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::adverb_list::evaluate | ||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||
| 1500 | sub Marpa::R2::Internal::MetaAST_Nodes::character_class::event_name { | ||||||||||||||||||||||||||||
| 1501 | 13 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1502 | 13 | my ( $start, $length ) = @{$data}; | |||||||||||||||||||||||||||
| 1503 | 13 | return $parse->substring( $start, $length ); | |||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||
| 1506 | sub Marpa::R2::Internal::MetaAST_Nodes::character_class::names { | ||||||||||||||||||||||||||||
| 1507 | 13 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1508 | 13 | return [ $self->name($parse) ]; | |||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||
| 1511 | sub Marpa::R2::Internal::MetaAST_Nodes::character_class::name { | ||||||||||||||||||||||||||||
| 1512 | 315 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1513 | 315 | return $self->evaluate($parse)->name($parse); | |||||||||||||||||||||||||||
| 1514 | } | ||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||
| 1516 | sub Marpa::R2::Internal::MetaAST_Nodes::character_class::evaluate { | ||||||||||||||||||||||||||||
| 1517 | 315 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1518 | 315 | my $character_class = $values->[2]; | |||||||||||||||||||||||||||
| 1519 | 315 | my $subgrammar = $Marpa::R2::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||
| 1520 | 315 | ▶ | if (( substr $subgrammar, 0, 1 ) eq 'L') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1521 | 307 | return Marpa::R2::Internal::MetaAST::Symbol_List->char_class_to_symbol( | |||||||||||||||||||||||||||
| 1522 | $parse, $character_class ); | ||||||||||||||||||||||||||||
| 1523 | } | ||||||||||||||||||||||||||||
| 1524 | # If here, in G1 | ||||||||||||||||||||||||||||
| 1525 | # Character classes and strings always go into L0, for now | ||||||||||||||||||||||||||||
| 1526 | 8 | my $lexer_symbol = do { | |||||||||||||||||||||||||||
| 1527 | 8 | local $Marpa::R2::Internal::SUBGRAMMAR = 'L0'; | |||||||||||||||||||||||||||
| 1528 | 8 | Marpa::R2::Internal::MetaAST::Symbol_List->char_class_to_symbol( | |||||||||||||||||||||||||||
| 1529 | $parse, $character_class ); | ||||||||||||||||||||||||||||
| 1530 | }; | ||||||||||||||||||||||||||||
| 1531 | 8 | my $lexical_lhs = $parse->internal_lexeme($character_class); | |||||||||||||||||||||||||||
| 1532 | 8 | my $lexical_rhs = $lexer_symbol->names($parse); | |||||||||||||||||||||||||||
| 1533 | 8 | my %lexical_rule = ( | |||||||||||||||||||||||||||
| 1534 | lhs => $lexical_lhs, | ||||||||||||||||||||||||||||
| 1535 | rhs => $lexical_rhs, | ||||||||||||||||||||||||||||
| 1536 | mask => [1], | ||||||||||||||||||||||||||||
| 1537 | ); | ||||||||||||||||||||||||||||
| 1538 | 8 | push @{ $parse->{rules}->{L0} }, \%lexical_rule; | |||||||||||||||||||||||||||
| 1539 | 8 | my $g1_symbol = | |||||||||||||||||||||||||||
| 1540 | Marpa::R2::Internal::MetaAST::Symbol_List->new($lexical_lhs); | ||||||||||||||||||||||||||||
| 1541 | 8 | return $g1_symbol; | |||||||||||||||||||||||||||
| 1542 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::character_class::evaluate | ||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||
| 1544 | sub Marpa::R2::Internal::MetaAST_Nodes::single_quoted_string::evaluate { | ||||||||||||||||||||||||||||
| 1545 | 580 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 1546 | 580 | my ( undef, undef, $string ) = @{$values}; | |||||||||||||||||||||||||||
| 1547 | 580 | my @symbols = (); | |||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||
| 1549 | 580 | my $end_of_string = rindex $string, q{'}; | |||||||||||||||||||||||||||
| 1550 | 580 | my $unmodified_string = substr $string, 0, $end_of_string+1; | |||||||||||||||||||||||||||
| 1551 | 580 | my $raw_flags = substr $string, $end_of_string+1; | |||||||||||||||||||||||||||
| 1552 | 580 | my $flags = Marpa::R2::Internal::MetaAST::flag_string_to_flags($raw_flags); | |||||||||||||||||||||||||||
| 1553 | 580 | my $subgrammar = $Marpa::R2::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||
| 1555 | # If we are currently in a lexical grammar, the strings go there | ||||||||||||||||||||||||||||
| 1556 | # If we are currently in G1, the strings always go into L0 | ||||||||||||||||||||||||||||
| 1557 | 580 | ▶ | my $lexical_grammar = $subgrammar eq 'G1' ? 'L0' : $subgrammar; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||
| 1559 | 580 | for my $char_class ( | |||||||||||||||||||||||||||
| 1560 | 938 | map { '[' . ( quotemeta $_ ) . ']' . $flags } split //xms, | |||||||||||||||||||||||||||
| 1561 | substr $unmodified_string, | ||||||||||||||||||||||||||||
| 1562 | 1, -1 | ||||||||||||||||||||||||||||
| 1563 | ) | ||||||||||||||||||||||||||||
| 1564 | { | ||||||||||||||||||||||||||||
| 1565 | 938 | local $Marpa::R2::Internal::SUBGRAMMAR = $lexical_grammar; | |||||||||||||||||||||||||||
| 1566 | 938 | my $symbol = | |||||||||||||||||||||||||||
| 1567 | Marpa::R2::Internal::MetaAST::Symbol_List->char_class_to_symbol( | ||||||||||||||||||||||||||||
| 1568 | $parse, $char_class ); | ||||||||||||||||||||||||||||
| 1569 | 938 | push @symbols, $symbol; | |||||||||||||||||||||||||||
| 1570 | } ## end for my $char_class ( map { '[' . ( quotemeta $_ ) . ']'...}) | ||||||||||||||||||||||||||||
| 1571 | 580 | my $list = Marpa::R2::Internal::MetaAST::Symbol_List->combine(@symbols); | |||||||||||||||||||||||||||
| 1572 | 580 | ▶ | return $list if $Marpa::R2::Internal::SUBGRAMMAR ne 'G1'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1573 | 272 | my $lexical_lhs = $parse->internal_lexeme($string); | |||||||||||||||||||||||||||
| 1574 | 272 | my $lexical_rhs = $list->names($parse); | |||||||||||||||||||||||||||
| 1575 | my %lexical_rule = ( | ||||||||||||||||||||||||||||
| 1576 | lhs => $lexical_lhs, | ||||||||||||||||||||||||||||
| 1577 | rhs => $lexical_rhs, | ||||||||||||||||||||||||||||
| 1578 | description => "Internal rule for single-quoted string $string", | ||||||||||||||||||||||||||||
| 1579 | 272 | mask => [ map { ; 1 } @{$lexical_rhs} ], | |||||||||||||||||||||||||||
| 1580 | ); | ||||||||||||||||||||||||||||
| 1581 | 272 | push @{ $parse->{rules}->{$lexical_grammar} }, \%lexical_rule; | |||||||||||||||||||||||||||
| 1582 | 272 | my $g1_symbol = | |||||||||||||||||||||||||||
| 1583 | Marpa::R2::Internal::MetaAST::Symbol_List->new($lexical_lhs); | ||||||||||||||||||||||||||||
| 1584 | 272 | return $g1_symbol; | |||||||||||||||||||||||||||
| 1585 | } ## end sub Marpa::R2::Internal::MetaAST_Nodes::single_quoted_string::evaluate | ||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||
| 1587 | package Marpa::R2::Internal::MetaAST::Symbol_List; | ||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||
| 1589 | 150 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||
| 1591 | sub new { | ||||||||||||||||||||||||||||
| 1592 | 3710 | ▶ | my ( $class, $name ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1593 | 3710 | return bless { names => [ q{} . $name ], mask => [1] }, $class; | |||||||||||||||||||||||||||
| 1594 | } | ||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||
| 1596 | sub combine { | ||||||||||||||||||||||||||||
| 1597 | 5231 | ▶ | my ( $class, @lists ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
combine: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1598 | 5231 | my $self = {}; | |||||||||||||||||||||||||||
| 1599 | 5231 | $self->{names} = [ map { @{ $_->names() } } @lists ]; | |||||||||||||||||||||||||||
| 1600 | 5231 | $self->{mask} = [ map { @{ $_->mask() } } @lists ]; | |||||||||||||||||||||||||||
| 1601 | 5231 | return bless $self, $class; | |||||||||||||||||||||||||||
| 1602 | } ## end sub combine | ||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||
| 1604 | sub Marpa::R2::Internal::MetaAST::char_class_to_re { | ||||||||||||||||||||||||||||
| 1605 | 7115 | ▶ | my ($cc_components) = @_; | ||||||||||||||||||||||||||
|
Subroutine
char_class_to_re: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||
| 1606 | 7115 | ▶ | die if ref $cc_components ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1607 | 7115 | my ( $char_class, $flags ) = @{$cc_components}; | |||||||||||||||||||||||||||
| 1608 | 7115 | ▶ | $flags = $flags ? '(' . q{?} . $flags . ')' : q{}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1609 | 7115 | my $regex; | |||||||||||||||||||||||||||
| 1610 | my $error; | ||||||||||||||||||||||||||||
| 1611 | 7115 | ▶ | if ( not defined eval { $regex = qr/$flags$char_class/xms; 1; } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1612 | 0 | $error = qq{Problem in evaluating character class: "$char_class"\n}; | |||||||||||||||||||||||||||
| 1613 | 0 | ▶ | $error .= qq{ Flags were "$flags"\n} if $flags; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1614 | 0 | $error .= $EVAL_ERROR; | |||||||||||||||||||||||||||
| 1615 | } | ||||||||||||||||||||||||||||
| 1616 | 7115 | return $regex, $error; | |||||||||||||||||||||||||||
| 1617 | } | ||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||
| 1619 | sub Marpa::R2::Internal::MetaAST::flag_string_to_flags { | ||||||||||||||||||||||||||||
| 1620 | 1833 | ▶ | my ($raw_flag_string) = @_; | ||||||||||||||||||||||||||
|
Subroutine
flag_string_to_flags: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 1621 | 1833 | ▶ | return q{} if not $raw_flag_string; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1622 | 29 | my @raw_flags = split m/:/xms, $raw_flag_string; | |||||||||||||||||||||||||||
| 1623 | 29 | my %flags = (); | |||||||||||||||||||||||||||
| 1624 | 29 | RAW_FLAG: for my $raw_flag (@raw_flags) { | |||||||||||||||||||||||||||
| 1625 | 35 | ▶ | next RAW_FLAG if not $raw_flag; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1626 | 29 | ▶ | if ( $raw_flag eq 'i' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1627 | 28 | $flags{'i'} = 1; | |||||||||||||||||||||||||||
| 1628 | 28 | next RAW_FLAG; | |||||||||||||||||||||||||||
| 1629 | } | ||||||||||||||||||||||||||||
| 1630 | 1 | ▶ | if ( $raw_flag eq 'ic' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1631 | 1 | $flags{'i'} = 1; | |||||||||||||||||||||||||||
| 1632 | 1 | next RAW_FLAG; | |||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||
| 1634 | Carp::croak( | ||||||||||||||||||||||||||||
| 1635 | 0 | qq{Bad flag for character class\n}, | |||||||||||||||||||||||||||
| 1636 | qq{ Flag string was $raw_flag_string\n}, | ||||||||||||||||||||||||||||
| 1637 | qq{ Bad flag was $raw_flag\n} | ||||||||||||||||||||||||||||
| 1638 | ); | ||||||||||||||||||||||||||||
| 1639 | } ## end RAW_FLAG: for my $raw_flag (@raw_flags) | ||||||||||||||||||||||||||||
| 1640 | 29 | my $cooked_flags = join q{}, sort keys %flags; | |||||||||||||||||||||||||||
| 1641 | 29 | return $cooked_flags; | |||||||||||||||||||||||||||
| 1642 | } ## end sub flag_string_to_flags | ||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||
| 1644 | # Return the character class symbol name, | ||||||||||||||||||||||||||||
| 1645 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||
| 1646 | sub char_class_to_symbol { | ||||||||||||||||||||||||||||
| 1647 | 1253 | ▶ | my ( $class, $parse, $char_class ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
char_class_to_symbol: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||
| 1649 | 1253 | my $end_of_char_class = rindex $char_class, q{]}; | |||||||||||||||||||||||||||
| 1650 | 1253 | my $unmodified_char_class = substr $char_class, 0, $end_of_char_class+1; | |||||||||||||||||||||||||||
| 1651 | 1253 | my $raw_flags = substr $char_class, $end_of_char_class+1; | |||||||||||||||||||||||||||
| 1652 | 1253 | my $flags = Marpa::R2::Internal::MetaAST::flag_string_to_flags($raw_flags); | |||||||||||||||||||||||||||
| 1653 | 1253 | my $subgrammar = $Marpa::R2::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||
| 1655 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||
| 1656 | 1253 | my $symbol_name = '[' . $unmodified_char_class . $flags . ']'; | |||||||||||||||||||||||||||
| 1657 | 1253 | ▶ | $parse->{character_classes} //= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$parse->{"character_classes"} //= {}
MC/DC100%1/1
$parse->{"character_classes"} //= {}
$parse->{"character_classes"}
Truth table100%2/2
A
A= $parse->{"character_classes"}
| |||||||||||||||||||||||||||||
| 1658 | 1253 | my $cc_hash = $parse->{character_classes}; | |||||||||||||||||||||||||||
| 1659 | 1253 | my ( undef, $symbol ) = $cc_hash->{$symbol_name}; | |||||||||||||||||||||||||||
| 1660 | 1253 | ▶ | if ( not defined $symbol ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1661 | |||||||||||||||||||||||||||||
| 1662 | 1253 | my $cc_components = [$unmodified_char_class, $flags]; | |||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||
| 1664 | # Fast fail on badly formed char_class -- we re-evaluate the regex just in time | ||||||||||||||||||||||||||||
| 1665 | # before we register characters. | ||||||||||||||||||||||||||||
| 1666 | 1253 | my ( $regex, $eval_error ) = | |||||||||||||||||||||||||||
| 1667 | Marpa::R2::Internal::MetaAST::char_class_to_re($cc_components); | ||||||||||||||||||||||||||||
| 1668 | 1253 | ▶ | Carp::croak( 'Bad Character class: ', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1669 | $char_class, "\n", 'Perl said ', $eval_error ) | ||||||||||||||||||||||||||||
| 1670 | if not $regex; | ||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||
| 1672 | 1253 | $symbol = | |||||||||||||||||||||||||||
| 1673 | Marpa::R2::Internal::MetaAST::Symbol_List->new($symbol_name); | ||||||||||||||||||||||||||||
| 1674 | 1253 | $cc_hash->{$symbol_name} = [ $cc_components, $symbol ]; | |||||||||||||||||||||||||||
| 1675 | 1253 | $parse->symbol_names_set( | |||||||||||||||||||||||||||
| 1676 | $symbol_name, | ||||||||||||||||||||||||||||
| 1677 | $subgrammar, | ||||||||||||||||||||||||||||
| 1678 | { dsl_form => $char_class, | ||||||||||||||||||||||||||||
| 1679 | display_form => $char_class, | ||||||||||||||||||||||||||||
| 1680 | description => "Character class: $char_class" | ||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||
| 1682 | ); | ||||||||||||||||||||||||||||
| 1683 | } ## end if ( not defined $symbol ) | ||||||||||||||||||||||||||||
| 1684 | 1253 | return $symbol; | |||||||||||||||||||||||||||
| 1685 | } ## end sub char_class_to_symbol | ||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||
| 1687 | sub Marpa::R2::Internal::MetaAST::Parse::symbol_names_set { | ||||||||||||||||||||||||||||
| 1688 | 2034 | ▶ | my ( $parse, $symbol, $subgrammar, $args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
symbol_names_set: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 1689 | 2034 | ▶ | my $symbol_type = $subgrammar eq 'G1' ? 'G1' : 'L'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1690 | 2034 | for my $arg_type (keys %{$args}) { | |||||||||||||||||||||||||||
| 1691 | 6025 | my $value = $args->{$arg_type}; | |||||||||||||||||||||||||||
| 1692 | 6025 | $parse->{symbols}->{$symbol_type}->{$symbol}->{$arg_type} = $value; | |||||||||||||||||||||||||||
| 1693 | } | ||||||||||||||||||||||||||||
| 1694 | } | ||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||
| 1696 | # Return the priotized symbol name, | ||||||||||||||||||||||||||||
| 1697 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||
| 1698 | sub Marpa::R2::Internal::MetaAST::Parse::prioritized_symbol { | ||||||||||||||||||||||||||||
| 1699 | 370 | ▶ | my ( $parse, $base_symbol, $priority ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
prioritized_symbol: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||
| 1701 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||
| 1702 | 370 | my $symbol_name = $base_symbol . '[' . $priority . ']'; | |||||||||||||||||||||||||||
| 1703 | my $symbol_data = | ||||||||||||||||||||||||||||
| 1704 | 370 | ▶ | $parse->{symbols}->{$Marpa::R2::Internal::SUBGRAMMAR eq 'G1' ? 'G1' : 'L'}->{$symbol_name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1705 | 370 | ▶ | return $symbol_name if defined $symbol_data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1706 | 72 | ▶ | my $display_form = | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1707 | ( $base_symbol =~ m/\s/xms ) ? "<$base_symbol>" : $base_symbol; | ||||||||||||||||||||||||||||
| 1708 | 72 | $parse->symbol_names_set( | |||||||||||||||||||||||||||
| 1709 | $symbol_name, | ||||||||||||||||||||||||||||
| 1710 | $Marpa::R2::Internal::SUBGRAMMAR, | ||||||||||||||||||||||||||||
| 1711 | { legacy_name => $base_symbol, | ||||||||||||||||||||||||||||
| 1712 | dsl_form => $base_symbol, | ||||||||||||||||||||||||||||
| 1713 | display_form => $display_form, | ||||||||||||||||||||||||||||
| 1714 | description => "<$base_symbol> at priority $priority" | ||||||||||||||||||||||||||||
| 1715 | } | ||||||||||||||||||||||||||||
| 1716 | ); | ||||||||||||||||||||||||||||
| 1717 | 72 | return $symbol_name; | |||||||||||||||||||||||||||
| 1718 | } ## end sub Marpa::R2::Internal::MetaAST::Parse::prioritized_symbol | ||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||
| 1720 | # Return the prioritized symbol name, | ||||||||||||||||||||||||||||
| 1721 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||
| 1722 | sub Marpa::R2::Internal::MetaAST::Parse::internal_lexeme { | ||||||||||||||||||||||||||||
| 1723 | 280 | ▶ | my ( $parse, $dsl_form, @grammars ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
internal_lexeme: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||
| 1725 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||
| 1726 | 280 | my $lexical_lhs_index = $parse->{lexical_lhs_index}++; | |||||||||||||||||||||||||||
| 1727 | 280 | my $lexical_symbol = "[Lex-$lexical_lhs_index]"; | |||||||||||||||||||||||||||
| 1728 | 280 | my %names = ( | |||||||||||||||||||||||||||
| 1729 | dsl_form => $dsl_form, | ||||||||||||||||||||||||||||
| 1730 | display_form => $dsl_form, | ||||||||||||||||||||||||||||
| 1731 | description => qq{Internal lexical symbol for "$dsl_form"} | ||||||||||||||||||||||||||||
| 1732 | ); | ||||||||||||||||||||||||||||
| 1733 | 280 | $parse->symbol_names_set( $lexical_symbol, $_, \%names ) for qw(G1 L); | |||||||||||||||||||||||||||
| 1734 | 280 | return $lexical_symbol; | |||||||||||||||||||||||||||
| 1735 | } ## end sub Marpa::R2::Internal::MetaAST::Parse::internal_lexeme | ||||||||||||||||||||||||||||
| 1736 | |||||||||||||||||||||||||||||
| 1737 | sub name { | ||||||||||||||||||||||||||||
| 1738 | 315 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 1739 | 315 | my $names = $self->{names}; | |||||||||||||||||||||||||||
| 1740 | Marpa::R2::exception( 'list->name() on symbol list of length ', | ||||||||||||||||||||||||||||
| 1741 | 0 | scalar @{$names} ) | |||||||||||||||||||||||||||
| 1742 | 315 | ▶ | if scalar @{$names} != 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1743 | 315 | return $self->{names}->[0]; | |||||||||||||||||||||||||||
| 1744 | } ## end sub name | ||||||||||||||||||||||||||||
| 1745 | 8626 | ▶ | sub names { return shift->{names} } | ||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1746 | 8346 | ▶ | sub mask { return shift->{mask} } | ||||||||||||||||||||||||||
|
Subroutine
mask: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||
| 1748 | sub mask_set { | ||||||||||||||||||||||||||||
| 1749 | 77 | ▶ | my ( $self, $mask ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
mask_set: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 1750 | 77 | return $self->{mask} = [ map {$mask} @{ $self->{mask} } ]; | |||||||||||||||||||||||||||
| 1751 | } | ||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||
| 1753 | 150 | 1; | |||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||
| 1755 | # vim: expandtab shiftwidth=4: | ||||||||||||||||||||||||||||