| 1 | # Marpa::R3 is Copyright (C) 2018, Jeffrey Kegler. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # This module is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # under the same terms as Perl 5.10.1. For more details, see the full text | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # of the licenses in the directory LICENSES. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # This program is distributed in the hope that it will be | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # useful, but it is provided "as is" and without any express | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # or implied warranties. For details, see the full text of | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # of the licenses in the directory LICENSES. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | package Marpa::R3::MetaAST; | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 104 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 104 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 104 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 104 | ▶ | use vars qw($VERSION $STRING_VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 104 | $VERSION = '4.001_053'; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 104 | $STRING_VERSION = $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 21 | ## no critic(BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 104 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 23 | ## use critic | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | package Marpa::R3::Internal::MetaAST; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 104 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 291 | ▶ | my ( $class, $p_rules_source ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 291 | my $meta_recce = Marpa::R3::Internal::meta_recce(); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 291 | my $valuer; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 291 | ▶ | eval { $meta_recce->read($p_rules_source) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | or Marpa::R3::exception( "Parse of BNF/Scanless source failed\n", | ||||||||||||||||||||||||||||||||||||||||||
| 35 | $EVAL_ERROR ); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 289 | $valuer = Marpa::R3::Valuer->new( { recognizer => $meta_recce } ); | |||||||||||||||||||||||||||||||||||||||||
| 37 | 289 | my $ambiguity_level = $valuer->ambiguity_level(); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 289 | ▶ | if ( $ambiguity_level != 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $ambiguity_status = $valuer->ambiguous(); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | Marpa::R3::exception( "Parse of BNF/Scanless source failed:\n", | |||||||||||||||||||||||||||||||||||||||||
| 41 | $ambiguity_status ); | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 288 | my $value_ref = $valuer->value(); | |||||||||||||||||||||||||||||||||||||||||
| 44 | 288 | ▶ | Marpa::R3::exception('Parse of BNF/Scanless source failed') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | if not defined $value_ref; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 288 | my $ast = { meta_recce => $meta_recce, top_node => ${$value_ref} }; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 288 | return bless $ast, $class; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | sub Marpa::R3::Internal::MetaAST::Parse::substring { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 18 | ▶ | my ( $parse, $start, $length ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
substring: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 18 | my $meta_slr = $parse->{meta_recce}; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 18 | my ($block_id) = $meta_slr->block_progress(); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 18 | my $string = $meta_slr->literal( $block_id, $start, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 18 | chomp $string; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 18 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } ## end sub Marpa::R3::Internal::MetaAST::Parse::substring | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | sub Marpa::R3::Internal::MetaAST::Parse::line_column { | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my ( $parse, $pos ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
line_column: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return Marpa::R3::Internal::line_column($parse->{p_dsl}, $pos); | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | # Assign symbols, creating "ordinary" symbols if no symbol | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # already exists | ||||||||||||||||||||||||||||||||||||||||||
| 66 | sub Marpa::R3::Internal::MetaAST::Parse::symbol_assign_ordinary { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 7267 | ▶ | my ( $parse, $symbol_name, $subg ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symbol_assign_ordinary: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 7267 | my $wsym = $parse->{symbols}->{$subg}->{$symbol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 7267 | ▶ | return $wsym if $wsym; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | # say STDERR "symbol_assign_ordinary($symbol_name, $subg)"; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 2273 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 72 | dsl_form => $symbol_name, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | name_source => 'lexical' | ||||||||||||||||||||||||||||||||||||||||||
| 74 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 2273 | $parse->xsy_assign( $symbol_name, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | 2273 | $symbol_data = { xsy => $symbol_name }; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 2273 | $parse->symbol_names_set( $symbol_name, $subg, | |||||||||||||||||||||||||||||||||||||||||
| 78 | $symbol_data ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | sub ast_to_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 288 | ▶ | my ($ast, $p_dsl) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ast_to_hash: called CC=26 SCAR=32.6
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 288 | my $xpr_ordinal = 0; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 288 | my $hashed_ast = {}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 288 | $hashed_ast->{meta_recce} = $ast->{meta_recce}; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 288 | bless $hashed_ast, 'Marpa::R3::Internal::MetaAST::Parse'; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 288 | $hashed_ast->{p_dsl} = $p_dsl; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 288 | $hashed_ast->{xpr}->{l0} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 288 | $hashed_ast->{xpr}->{g1} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 288 | $hashed_ast->{rules}->{l0} = []; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 288 | $hashed_ast->{rules}->{g1} = []; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 288 | $hashed_ast->{lexeme_declarations} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 288 | my $declarations = $hashed_ast->{lexeme_declarations}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 288 | my $g1_symbols = $hashed_ast->{symbols}->{g1} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 288 | my ( undef, undef, @statements ) = @{ $ast->{top_node} }; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # This is the last ditch exception catcher | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # It forces all Marpa exceptions to be die's, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # then catches them and rethrows using Carp. | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # The plan is to use die(), with higher levels | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # catching and re-die()'ing after adding | ||||||||||||||||||||||||||||||||||||||||||
| 106 | # helpful location information. After the | ||||||||||||||||||||||||||||||||||||||||||
| 107 | # re-throw it is caught here and passed to | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # Carp. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 288 | my $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 110 | 288 | local $Marpa::R3::JUST_DIE = 1; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 288 | $_->evaluate($hashed_ast) for @statements; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 283 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 113 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 288 | ▶ | Marpa::R3::exception($EVAL_ERROR) if not $eval_ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # Add the G1 augment rule | ||||||||||||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 283 | my $start_lhs = $hashed_ast->{'start_lhs'} | |||||||||||||||||||||||||||||||||||||||||
| 119 | 283 | ▶ | // $hashed_ast->{'first_lhs'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$hashed_ast->{"start_lhs"} // $hashed_ast->{"first_lhs"}
MC/DC0%0/2
$hashed_ast->{"start_lhs"} // $hashed_ast->{"first_lhs"}
$hashed_ast->{"start_lhs"}
$hashed_ast->{"first_lhs"}
Truth table66%2/3
A // B
A= $hashed_ast->{"start_lhs"}B= $hashed_ast->{"first_lhs"}
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 283 | ▶ | Marpa::R3::exception('No rules in SLIF grammar') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | if not defined $start_lhs; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 283 | my $augment_lhs = '[:start:]'; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 283 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 124 | dsl_form => $augment_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 283 | $hashed_ast->xsy_create( $augment_lhs, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 283 | $hashed_ast->symbol_names_set( $augment_lhs, 'g1', { xsy => $augment_lhs } ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 283 | my $rule_data = { | |||||||||||||||||||||||||||||||||||||||||
| 131 | start => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | length => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | lhs => $augment_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 134 | rhs => [$start_lhs], | ||||||||||||||||||||||||||||||||||||||||||
| 135 | subkey => $xpr_ordinal++, | ||||||||||||||||||||||||||||||||||||||||||
| 136 | action => '::first' | ||||||||||||||||||||||||||||||||||||||||||
| 137 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 283 | $hashed_ast->symbol_assign_ordinary($start_lhs, 'g1'); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 283 | my $wrl = $hashed_ast->xpr_create( $rule_data, 'g1' ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 283 | push @{ $hashed_ast->{rules}->{g1} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # If the lexer is empty, create a fake one | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # The fake lexer contains one rule. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # This rule discards everything it matches, but it | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # never matches anything. | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 283 | ▶ | if ( not %{ $hashed_ast->{xpr}->{l0} } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # the unicorn is a pattern which never matches | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 5 | my $unicorn_class = '[[^\\d\\D]]'; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | my $unicorn; | |||||||||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | local $Marpa::R3::Internal::SUBGRAMMAR = 'l0'; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | my $unicorn_symbol = | |||||||||||||||||||||||||||||||||||||||||
| 155 | Marpa::R3::Internal::MetaAST::Symbol_List->char_class_to_symbol( | ||||||||||||||||||||||||||||||||||||||||||
| 156 | $hashed_ast, $unicorn_class ); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 5 | $unicorn = $unicorn_symbol->name(); | |||||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 5 | my $discard_lhs = '[:discard:]'; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 5 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 161 | dsl_form => $discard_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 163 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | $hashed_ast->xsy_assign( $discard_lhs, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | $hashed_ast->symbol_names_set( $discard_lhs, 'l0', | |||||||||||||||||||||||||||||||||||||||||
| 166 | { xsy => $discard_lhs } ); | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | my $rule_data = { | |||||||||||||||||||||||||||||||||||||||||
| 168 | start => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | length => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | lhs => $discard_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | rhs => [$unicorn], | ||||||||||||||||||||||||||||||||||||||||||
| 172 | symbol_as_event => $unicorn, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | subkey => $xpr_ordinal++, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | # 'description' => 'Discard rule for <[[^\\d\\D]]>' | ||||||||||||||||||||||||||||||||||||||||||
| 176 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 5 | my $wrl = $hashed_ast->xpr_create( $rule_data, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 5 | push @{ $hashed_ast->{rules}->{l0} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | # Add the L0 augment rule | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 283 | if (1) { | |||||||||||||||||||||||||||||||||||||||||
| 183 | # Target symbol assumed to exist already | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 283 | my $target_lhs = '[:target:]'; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 283 | ▶ | Marpa::R3::exception('No rules in SLIF L0 grammar') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | if not defined $target_lhs; | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 283 | my $augment_lhs = '[:lex_start:]'; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 283 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 189 | dsl_form => $augment_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 191 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 283 | $hashed_ast->xsy_create( $augment_lhs, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 283 | $hashed_ast->symbol_names_set( $augment_lhs, 'l0', { xsy => $augment_lhs } ); | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 283 | my $rule_data = { | |||||||||||||||||||||||||||||||||||||||||
| 196 | start => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | length => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | lhs => $augment_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | rhs => [$target_lhs], | ||||||||||||||||||||||||||||||||||||||||||
| 200 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 283 | $hashed_ast->symbol_assign_ordinary($target_lhs, 'l0'); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 283 | my $wrl = $hashed_ast->xpr_create( $rule_data, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 203 | 283 | push @{ $hashed_ast->{rules}->{l0} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 283 | my %l0_lhs = (); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 283 | my %l0_rhs = (); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 283 | RULE: for my $rule (values %{$hashed_ast->{xpr}->{l0}}) { | |||||||||||||||||||||||||||||||||||||||||
| 209 | 1786 | my $lhs = $rule->{lhs}; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 1786 | $l0_lhs{$lhs} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 1786 | $l0_rhs{$_} = 1 for @{$rule->{rhs}}; | |||||||||||||||||||||||||||||||||||||||||
| 212 | 1786 | my $separator = $rule->{separator}; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 1786 | ▶ | $l0_rhs{$separator} = 1 if $separator; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 283 | my %g1_lhs = (); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 283 | my %g1_rhs = (); | |||||||||||||||||||||||||||||||||||||||||
| 217 | 283 | RULE: for my $rule (values %{$hashed_ast->{xpr}->{g1}}) { | |||||||||||||||||||||||||||||||||||||||||
| 218 | 1529 | my $lhs = $rule->{lhs}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 1529 | $g1_lhs{$lhs} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 1529 | $g1_rhs{$_} = 1 for @{$rule->{rhs}}; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 1529 | my $separator = $rule->{separator}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1529 | ▶ | $g1_rhs{$separator} = 1 if $separator; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 283 | my %lexeme = (); | |||||||||||||||||||||||||||||||||||||||||
| 227 | 283 | $lexeme{$_} = 'a lexeme in L0' for grep { not $l0_rhs{$_} } keys %l0_lhs; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 283 | $lexeme{$_} = 'a lexeme in G1' for grep { not $g1_lhs{$_} } keys %g1_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 283 | $lexeme{$_} = 'a declared lexeme' for keys %{$declarations}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 283 | LEXEME: for my $lexeme ( sort keys %lexeme ) { | |||||||||||||||||||||||||||||||||||||||||
| 231 | 1174 | ▶ | next LEXEME if $lexeme eq '[:lex_start:]'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 899 | ▶ | $declarations->{$lexeme} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$declarations->{$lexeme} //= {}
MC/DC100%1/1
$declarations->{$lexeme} //= {}
$declarations->{$lexeme}
Truth table100%2/2
A
A= $declarations->{$lexeme}
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 899 | ▶ | if ( $lexeme ne '[:discard:]' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 740 | ▶ | if ( not $l0_lhs{$lexeme} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | my $type = $lexeme{$lexeme}; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 237 | "<$lexeme> is $type, but is not on the LHS of any L0 rule\n", | ||||||||||||||||||||||||||||||||||||||||||
| 238 | " A lexeme must be the LHS of some L0 rule\n" | ||||||||||||||||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | 738 | ▶ | if ( $l0_rhs{$lexeme} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | my $type = $lexeme{$lexeme}; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 244 | "<$lexeme> is $type, but is on the RHS of an L0 rule\n", | ||||||||||||||||||||||||||||||||||||||||||
| 245 | " A lexeme must not be in the RHS of any L0 rule\n" | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 736 | ▶ | if ( $g1_lhs{$lexeme} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | my $type = $lexeme{$lexeme}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 251 | "<$lexeme> is $type, but is on the LHS of a G1 rule\n", | ||||||||||||||||||||||||||||||||||||||||||
| 252 | " A lexeme cannot be the LHS of any G1 rule\n" | ||||||||||||||||||||||||||||||||||||||||||
| 253 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 734 | ▶ | if ( not $g1_rhs{$lexeme} and $lexeme ne '[:lex_start:]') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $g1_rhs{$lexeme} and $lexeme ne "[:lex_start:]"
MC/DC50%1/2
not $g1_rhs{$lexeme} and $lexeme ne "[:lex_start:]"
not $g1_rhs{$lexeme}
$lexeme ne "[:lex_start:]"
Truth table66%2/3
not(A) and B
A= not $g1_rhs{$lexeme}B= $lexeme ne "[:lex_start:]"
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | my $type = $lexeme{$lexeme}; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 2 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 258 | "<$lexeme> is $type, but is not on the RHS of any G1 rule\n", | ||||||||||||||||||||||||||||||||||||||||||
| 259 | " A lexeme must be in the RHS of at least one G1 rule\n" | ||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 891 | my $target_lhs = '[:target:]'; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 891 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 267 | dsl_form => $target_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 269 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 891 | $hashed_ast->xsy_assign( $target_lhs, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 271 | 891 | $hashed_ast->symbol_names_set( $target_lhs, 'l0', | |||||||||||||||||||||||||||||||||||||||||
| 272 | { xsy => $target_lhs } ); | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 891 | my $rule_data = { | |||||||||||||||||||||||||||||||||||||||||
| 275 | start => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 276 | length => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 277 | lhs => $target_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 278 | rhs => [$lexeme], | ||||||||||||||||||||||||||||||||||||||||||
| 279 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 891 | $hashed_ast->symbol_assign_ordinary( $target_lhs, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 891 | my $wrl = $hashed_ast->xpr_create( $rule_data, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 282 | 891 | push @{ $hashed_ast->{rules}->{l0} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 275 | my %stripped_character_classes = (); | |||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 275 | my $character_classes = $hashed_ast->{character_classes}; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 275 | for my $symbol_name ( sort keys %{$character_classes} ) { | |||||||||||||||||||||||||||||||||||||||||
| 290 | 1312 | my ($re) = @{ $character_classes->{$symbol_name} }; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 1312 | $stripped_character_classes{$symbol_name} = $re; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 275 | $hashed_ast->{character_classes} = \%stripped_character_classes; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | # say STDERR Data::Dumper::Dumper($hashed_ast); | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 275 | return $hashed_ast; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } ## end sub ast_to_hash | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | # This class is for pieces of RHS alternatives, as they are | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # being constructed | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 104 | my $PROTO_ALTERNATIVE = 'Marpa::R3::Internal::MetaAST::Proto_Alternative'; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | sub Marpa::R3::Internal::MetaAST::Proto_Alternative::combine { | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 821 | ▶ | my ( $class, @hashes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combine: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 821 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 308 | 821 | for my $hash_to_add (@hashes) { | |||||||||||||||||||||||||||||||||||||||||
| 309 | 941 | for my $key ( keys %{$hash_to_add} ) { | |||||||||||||||||||||||||||||||||||||||||
| 310 | ## expect to be caught and rethrown | ||||||||||||||||||||||||||||||||||||||||||
| 311 | die qq{A Marpa rule contained a duplicate key\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | qq{ The key was "$key"\n} | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 935 | ▶ | if exists $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 935 | $self->{$key} = $hash_to_add->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } ## end for my $key ( keys %{$hash_to_add} ) | ||||||||||||||||||||||||||||||||||||||||||
| 316 | } ## end for my $hash_to_add (@hashes) | ||||||||||||||||||||||||||||||||||||||||||
| 317 | 821 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } ## end sub Marpa::R3::Internal::MetaAST::Proto_Alternative::combine | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | sub Marpa::R3::Internal::MetaAST::Parse::bless_hash_rule { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 2211 | ▶ | my ( $parse, $hash_rule, $blessing, $naming, $original_lhs ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bless_hash_rule: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 2211 | ▶ | return if (substr $Marpa::R3::Internal::SUBGRAMMAR, 0, 1) eq 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 2211 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 2211 | $hash_rule->{name} = $naming; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 2211 | ▶ | return if not defined $blessing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | FIND_BLESSING: { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 130 | ▶ | last FIND_BLESSING if $blessing =~ /\A [\w] /xms; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 28 | ▶ | return if $blessing eq '::undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # Rule may be half-formed, but assume we have lhs | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 28 | ▶ | if ( $blessing eq '::lhs' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 28 | $blessing = $original_lhs; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 28 | ▶ | if ( $blessing =~ / [^ [:alnum:]] /xms ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 337 | qq{"::lhs" blessing only allowed if LHS is whitespace and alphanumerics\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 338 | qq{ LHS was <$original_lhs>\n} | ||||||||||||||||||||||||||||||||||||||||||
| 339 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } ## end if ( $blessing =~ / [^ [:alnum:]] /xms ) | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 28 | $blessing =~ s/[ ]/_/gxms; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 28 | last FIND_BLESSING; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } ## end if ( $blessing eq '::lhs' ) | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | Marpa::R3::exception( qq{Unknown blessing "$blessing"\n} ); | |||||||||||||||||||||||||||||||||||||||||
| 345 | } ## end FIND_BLESSING: | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 130 | $hash_rule->{bless} = $blessing; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 130 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } ## end sub Marpa::R3::Internal::MetaAST::Parse::bless_hash_rule | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 4056 | ▶ | sub Marpa::R3::Internal::MetaAST_Nodes::bare_name::name { return $_[0]->[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | sub Marpa::R3::Internal::MetaAST_Nodes::reserved_action_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 110 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 110 | return $self->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | sub Marpa::R3::Internal::MetaAST_Nodes::reserved_event_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 33 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 33 | my $name = $self->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 33 | $name =~ s/\A : /'/xms; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 33 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | sub Marpa::R3::Internal::MetaAST_Nodes::action_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 488 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 488 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | sub Marpa::R3::Internal::MetaAST_Nodes::alternative_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 10 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 10 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | sub Marpa::R3::Internal::MetaAST_Nodes::event_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 300 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 300 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | sub Marpa::R3::Internal::MetaAST_Nodes::array_descriptor::name { | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 117 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub Marpa::R3::Internal::MetaAST_Nodes::reserved_blessing_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 17 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | sub Marpa::R3::Internal::MetaAST_Nodes::blessing_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 119 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 119 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | sub Marpa::R3::Internal::MetaAST_Nodes::standard_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 163 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | sub Marpa::R3::Internal::MetaAST_Nodes::Perl_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 261 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | sub Marpa::R3::Internal::MetaAST_Nodes::lhs::name { | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 1854 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 1854 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 1854 | return $symbol->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | # After development, delete this | ||||||||||||||||||||||||||||||||||||||||||
| 407 | sub Marpa::R3::Internal::MetaAST_Nodes::lhs::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return $values->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | sub Marpa::R3::Internal::MetaAST_Nodes::quantifier::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 318 | ▶ | my ($data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 318 | return $data->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | sub Marpa::R3::Internal::MetaAST_Nodes::op_declare::op { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 1854 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 1854 | return $values->[2]->op(); | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | sub Marpa::R3::Internal::MetaAST_Nodes::op_declare_match::op { | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 905 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 905 | return $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | sub Marpa::R3::Internal::MetaAST_Nodes::op_declare_bnf::op { | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 1087 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 1087 | return $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | sub Marpa::R3::Internal::MetaAST_Nodes::bracketed_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 581 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | 581 | my ( undef, undef, $bracketed_name ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | # normalize whitespace | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 581 | $bracketed_name =~ s/\A [<] \s*//xms; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 581 | $bracketed_name =~ s/ \s* [>] \z//xms; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 581 | $bracketed_name =~ s/ \s+ / /gxms; | |||||||||||||||||||||||||||||||||||||||||
| 440 | 581 | return $bracketed_name; | |||||||||||||||||||||||||||||||||||||||||
| 441 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::bracketed_name::name | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | sub Marpa::R3::Internal::MetaAST_Nodes::single_quoted_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 216 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 216 | my ( undef, undef, $single_quoted_name ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | # normalize whitespace | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 216 | $single_quoted_name =~ s/\A ['] \s*//xms; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 216 | $single_quoted_name =~ s/ \s* ['] \z//xms; | |||||||||||||||||||||||||||||||||||||||||
| 450 | 216 | $single_quoted_name =~ s/ \s+ / /gxms; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 216 | return $single_quoted_name; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::single_quoted_name::name | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | sub Marpa::R3::Internal::MetaAST_Nodes::parenthesized_rhs_primary_list::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||||||||||
| 456 | 77 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 77 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 77 | my @symbol_lists = map { $_->evaluate($parse); } @values; | |||||||||||||||||||||||||||||||||||||||||
| 459 | 77 | my $flattened_list = | |||||||||||||||||||||||||||||||||||||||||
| 460 | Marpa::R3::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 77 | $flattened_list->mask_set(0); | |||||||||||||||||||||||||||||||||||||||||
| 462 | 77 | return $flattened_list; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::parenthesized_rhs_primary_list::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | sub Marpa::R3::Internal::MetaAST_Nodes::rhs::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 1798 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 1798 | my ( $start, $length, @values ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 1798 | my $rhs = eval { | |||||||||||||||||||||||||||||||||||||||||
| 469 | 1798 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 1798 | my $flattened_list = | |||||||||||||||||||||||||||||||||||||||||
| 471 | Marpa::R3::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 1798 | bless { | |||||||||||||||||||||||||||||||||||||||||
| 473 | rhs => $flattened_list->names($parse), | ||||||||||||||||||||||||||||||||||||||||||
| 474 | mask => $flattened_list->mask() | ||||||||||||||||||||||||||||||||||||||||||
| 475 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 476 | $PROTO_ALTERNATIVE; | ||||||||||||||||||||||||||||||||||||||||||
| 477 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 1798 | ▶ | if ( not $rhs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 482 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 483 | q{ RHS involved was }, | ||||||||||||||||||||||||||||||||||||||||||
| 484 | $parse->substring( $start, $length ) | ||||||||||||||||||||||||||||||||||||||||||
| 485 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } ## end if ( not $rhs ) | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 1798 | return $rhs; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::rhs::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | sub Marpa::R3::Internal::MetaAST_Nodes::rhs_primary::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 3069 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 3069 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 3069 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 3069 | return Marpa::R3::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | |||||||||||||||||||||||||||||||||||||||||
| 495 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::rhs_primary::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | sub Marpa::R3::Internal::MetaAST_Nodes::rhs_primary_list::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 498 | 77 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 77 | my ( undef, undef, @values ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 77 | my @symbol_lists = map { $_->evaluate($parse) } @values; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 77 | return Marpa::R3::Internal::MetaAST::Symbol_List->combine(@symbol_lists); | |||||||||||||||||||||||||||||||||||||||||
| 502 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::rhs_primary_list::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | sub Marpa::R3::Internal::MetaAST_Nodes::action::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 488 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 488 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 488 | return bless { action => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | sub Marpa::R3::Internal::MetaAST_Nodes::blessing::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 511 | 119 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 119 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 513 | 119 | return bless { bless => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | sub Marpa::R3::Internal::MetaAST_Nodes::naming::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 10 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 10 | my ( undef, undef, $child ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 10 | return bless { name => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | sub Marpa::R3::Internal::MetaAST_Nodes::right_association::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 9 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 9 | return bless { assoc => 'R' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | sub Marpa::R3::Internal::MetaAST_Nodes::left_association::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | return bless { assoc => 'L' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | sub Marpa::R3::Internal::MetaAST_Nodes::group_association::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 533 | 10 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 10 | return bless { assoc => 'G' }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | sub Marpa::R3::Internal::MetaAST_Nodes::eager_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 21 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 21 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 21 | return bless { eager => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | sub Marpa::R3::Internal::MetaAST_Nodes::event_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 139 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | 139 | return bless { event => ( $values->[2]->event() ) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | sub Marpa::R3::Internal::MetaAST_Nodes::event_initialization::event { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 300 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 300 | my $event_name = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 551 | 300 | my $event_initializer = $values->[3]; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 300 | return [$event_name->name(), $event_initializer->on_or_off()], | |||||||||||||||||||||||||||||||||||||||||
| 553 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::event_specification::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | sub Marpa::R3::Internal::MetaAST_Nodes::proper_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 556 | 4 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 557 | 4 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 4 | return bless { proper => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | sub Marpa::R3::Internal::MetaAST_Nodes::pause_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 562 | 61 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 61 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 61 | return bless { pause => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | sub Marpa::R3::Internal::MetaAST_Nodes::priority_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 2 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 2 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 2 | return bless { priority => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | sub Marpa::R3::Internal::MetaAST_Nodes::rank_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 51 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 51 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 51 | return bless { rank => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | sub Marpa::R3::Internal::MetaAST_Nodes::null_ranking_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 2 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 2 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 2 | return bless { null_ranking => $child->value() }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | sub Marpa::R3::Internal::MetaAST_Nodes::null_ranking_constant::value { | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 2 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | sub Marpa::R3::Internal::MetaAST_Nodes::before_or_after::value { | ||||||||||||||||||||||||||||||||||||||||||
| 590 | 61 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | sub Marpa::R3::Internal::MetaAST_Nodes::event_initializer::on_or_off | ||||||||||||||||||||||||||||||||||||||||||
| 594 | { | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 300 | ▶ | my ($values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_or_off: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 300 | my (undef, undef, $is_activated) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 597 | 300 | ▶ | return 1 if not defined $is_activated; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 105 | my (undef, undef, $on_or_off) = @{$is_activated}; | |||||||||||||||||||||||||||||||||||||||||
| 599 | 105 | ▶ | return $on_or_off eq 'on' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | sub Marpa::R3::Internal::MetaAST_Nodes::boolean::value { | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 25 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | sub Marpa::R3::Internal::MetaAST_Nodes::signed_integer::value { | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 53 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | sub Marpa::R3::Internal::MetaAST_Nodes::separator_specification::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 19 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 19 | my $child = $values->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 613 | 19 | return bless { separator => $child->name($parse) }, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | sub Marpa::R3::Internal::MetaAST_Nodes::adverb_item::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 941 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 941 | my $child = $values->[2]->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 619 | 941 | return bless $child, $PROTO_ALTERNATIVE; | |||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | sub Marpa::R3::Internal::MetaAST_Nodes::default_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 138 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 138 | my ( $start, $length, undef, $op_declare, $raw_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 625 | 138 | ▶ | my $subgrammar = $op_declare->op() eq q{::=} ? 'g1' : 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 138 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | # A default rule clears the previous default | ||||||||||||||||||||||||||||||||||||||||||
| 629 | 138 | my %default_adverbs = (); | |||||||||||||||||||||||||||||||||||||||||
| 630 | 138 | $parse->{default_adverbs}->{$subgrammar} = \%default_adverbs; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 138 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 633 | 149 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 149 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 138 | $default_adverbs{$key} = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 636 | 138 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 11 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 11 | $default_adverbs{$key} = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 11 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | die qq{Adverb "$key" not allowed in $subgrammar default rule\n}, | |||||||||||||||||||||||||||||||||||||||||
| 643 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 644 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 645 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 646 | 138 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::default_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | sub Marpa::R3::Internal::MetaAST_Nodes::discard_default_statement::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 27 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=5 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 27 | my ( $start, $length, $raw_adverb_list ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 27 | local $Marpa::R3::Internal::SUBGRAMMAR = 'g1'; | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 27 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 655 | 27 | ▶ | if ( exists $parse->{discard_default_adverbs} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 658 | qq{More than one discard default statement is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 659 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 660 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||||||||||||||||
| 661 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 662 | } ## end if ( exists $parse->{discard_default_adverbs} ) | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 27 | $parse->{discard_default_adverbs} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 664 | 27 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 665 | 27 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 666 | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 667 | 27 | $parse->{discard_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 27 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | qq{"$key" adverb not allowed as discard default"}); | |||||||||||||||||||||||||||||||||||||||||
| 672 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 673 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 27 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 675 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::discard_default_statement::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | sub Marpa::R3::Internal::MetaAST_Nodes::lexeme_default_statement::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 43 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 679 | 43 | my ( $start, $length, $raw_adverb_list ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 43 | local $Marpa::R3::Internal::SUBGRAMMAR = 'g1'; | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 43 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 683 | 43 | ▶ | if ( exists $parse->{lexeme_default_adverbs} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 686 | qq{More than one lexeme default statement is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 687 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 688 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||||||||||||||||
| 689 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 690 | } ## end if ( exists $parse->{lexeme_default_adverbs} ) | ||||||||||||||||||||||||||||||||||||||||||
| 691 | 43 | $parse->{lexeme_default_adverbs} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 43 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 693 | 49 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 49 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 43 | $parse->{lexeme_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 696 | 43 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 698 | 6 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 6 | $parse->{lexeme_default_adverbs}->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 6 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | qq{"$key" adverb not allowed as lexeme default"}); | |||||||||||||||||||||||||||||||||||||||||
| 704 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 705 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 43 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 707 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::lexeme_default_statement::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | sub Marpa::R3::Internal::MetaAST_Nodes::inaccessible_statement::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 9 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 9 | my ( $start, $length, $inaccessible_treatment ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 9 | local $Marpa::R3::Internal::SUBGRAMMAR = 'g1'; | |||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | 9 | ▶ | if ( exists $parse->{defaults}->{if_inaccessible} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $problem_rule = $parse->substring( $start, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 717 | qq{More than one inaccessible default statement is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 718 | qq{ This was the rule that caused the problem:\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 719 | qq{ $problem_rule\n} | ||||||||||||||||||||||||||||||||||||||||||
| 720 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 9 | $parse->{defaults}->{if_inaccessible} = $inaccessible_treatment->value(); | |||||||||||||||||||||||||||||||||||||||||
| 723 | 9 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | sub Marpa::R3::Internal::MetaAST_Nodes::inaccessible_treatment::value { | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 9 | ▶ | return $_[0]->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | sub Marpa::R3::Internal::MetaAST_Nodes::priority_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 731 | 1440 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=73 SCAR=48.1
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | my ( $start, $length, $raw_lhs, $op_declare, $raw_priorities ) = | ||||||||||||||||||||||||||||||||||||||||||
| 733 | 1440 | @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | 1440 | ▶ | my $subgrammar = $op_declare->op() eq q{::=} ? 'g1' : 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 736 | 1440 | my $xpr_ordinal = 0; | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 1440 | my $lhs = $raw_lhs->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 739 | 1440 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | 1440 | local $Marpa::R3::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | 1440 | my ( undef, undef, @priorities ) = @{$raw_priorities}; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 1440 | my $priority_count = scalar @priorities; | |||||||||||||||||||||||||||||||||||||||||
| 744 | 1440 | my @working_rules = (); | |||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | 1440 | ▶ | $parse->{rules}->{$subgrammar} //= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parse->{"rules"}{$subgrammar} //= []
MC/DC0%0/1
$parse->{"rules"}{$subgrammar} //= []
$parse->{"rules"}{$subgrammar}
Truth table50%1/2
A
A= $parse->{"rules"}{$subgrammar}
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 1440 | my $rules = $parse->{rules}->{$subgrammar}; | |||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | 1440 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | 1440 | my $xrlid = xrl_create($parse, { | |||||||||||||||||||||||||||||||||||||||||
| 752 | lhs => $lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 753 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 754 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 755 | precedence_count => $priority_count, | ||||||||||||||||||||||||||||||||||||||||||
| 756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 757 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 1438 | ▶ | if ( $priority_count <= 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | ## If there is only one priority | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 1419 | my ( undef, undef, @alternatives ) = @{ $priorities[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 1419 | for my $alternative_ix (0 .. $#alternatives) { | |||||||||||||||||||||||||||||||||||||||||
| 763 | my ($alternative_start, $alternative_length, | ||||||||||||||||||||||||||||||||||||||||||
| 764 | $raw_rhs, $raw_adverb_list | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 1693 | ) = @{$alternatives[$alternative_ix]}; | |||||||||||||||||||||||||||||||||||||||||
| 766 | 1693 | my ( $proto_rule, $adverb_list ); | |||||||||||||||||||||||||||||||||||||||||
| 767 | 1693 | my $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 768 | 1693 | $proto_rule = $raw_rhs->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 769 | 1693 | $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 770 | 1693 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 771 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 772 | 1693 | ▶ | if ( not $eval_ok ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 776 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 777 | qq{ The problem was in this RHS alternative:\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 778 | q{ }, | ||||||||||||||||||||||||||||||||||||||||||
| 779 | $parse->substring( $alternative_start, $alternative_length ), | ||||||||||||||||||||||||||||||||||||||||||
| 780 | "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 781 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 782 | } ## end if ( not $eval_ok ) | ||||||||||||||||||||||||||||||||||||||||||
| 783 | 1693 | my @rhs_names = @{ $proto_rule->{rhs} }; | |||||||||||||||||||||||||||||||||||||||||
| 784 | 1693 | my @mask = @{ $proto_rule->{mask} }; | |||||||||||||||||||||||||||||||||||||||||
| 785 | 1693 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | 1382 | and grep { !$_ } @mask ) | |||||||||||||||||||||||||||||||||||||||||
| 787 | { | ||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 789 | qq{hidden symbols are not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 790 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 1693 | $parse->symbol_assign_ordinary($_, $subgrammar) for $lhs, @rhs_names; | |||||||||||||||||||||||||||||||||||||||||
| 793 | 1693 | ▶ | my %hash_rule = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | start => ( $alternative_ix ? $alternative_start : $start ), | ||||||||||||||||||||||||||||||||||||||||||
| 795 | length => ( $alternative_ix ? $alternative_length : $length ), | ||||||||||||||||||||||||||||||||||||||||||
| 796 | subkey => ++$xpr_ordinal, | ||||||||||||||||||||||||||||||||||||||||||
| 797 | lhs => $lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 798 | rhs => \@rhs_names, | ||||||||||||||||||||||||||||||||||||||||||
| 799 | mask => \@mask, | ||||||||||||||||||||||||||||||||||||||||||
| 800 | xrlid => $xrlid, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | 1693 | my $action; | |||||||||||||||||||||||||||||||||||||||||
| 804 | my $blessing; | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 1693 | my $naming; | |||||||||||||||||||||||||||||||||||||||||
| 806 | 1693 | my $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 1693 | my $rank; | |||||||||||||||||||||||||||||||||||||||||
| 808 | 1693 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 809 | 315 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 315 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 811 | 204 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 812 | 204 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | 111 | ▶ | if ( $key eq 'assoc' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | # OK, but ignored | ||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | 111 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | 48 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 821 | 48 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 63 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 824 | 10 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 825 | 10 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||
| 827 | 53 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | 2 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 2 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 51 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 51 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 51 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | my ( $line, $column ) = | ||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | die qq{Adverb "$key" not allowed in an prioritized rule\n}, | |||||||||||||||||||||||||||||||||||||||||
| 838 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 839 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 1693 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | 1693 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 538 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 845 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 538 | $hash_rule{action} = $action; | |||||||||||||||||||||||||||||||||||||||||
| 847 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||
| 849 | 1693 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | 1693 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | 51 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 853 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 854 | 51 | $hash_rule{rank} = $rank; | |||||||||||||||||||||||||||||||||||||||||
| 855 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||
| 857 | 1693 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 858 | 1693 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 859 | 2 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | qq{null-ranking allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 861 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | $hash_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 863 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 1693 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | 1693 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | and | ||||||||||||||||||||||||||||||||||||||||||
| 868 | ( substr $subgrammar, 0, 1 ) eq 'l' | ||||||||||||||||||||||||||||||||||||||||||
| 869 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 870 | { | ||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 872 | 'bless option not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||||||||||||||||
| 873 | $lhs, '")' | ||||||||||||||||||||||||||||||||||||||||||
| 874 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 1693 | $parse->bless_hash_rule( \%hash_rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 1693 | my $wrl = $parse->xpr_create( \%hash_rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 880 | 1691 | push @{$rules}, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 881 | } ## end for my $alternative (@alternatives) | ||||||||||||||||||||||||||||||||||||||||||
| 882 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 1417 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 884 | } ## end if ( $priority_count <= 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | 19 | for my $priority_ix ( 0 .. $priority_count - 1 ) { | |||||||||||||||||||||||||||||||||||||||||
| 887 | 70 | my $priority = $priority_count - ( $priority_ix + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 888 | 70 | my ( undef, undef, @alternatives ) = @{ $priorities[$priority_ix] }; | |||||||||||||||||||||||||||||||||||||||||
| 889 | 70 | for my $alternative (@alternatives) { | |||||||||||||||||||||||||||||||||||||||||
| 890 | my ($alternative_start, $alternative_length, | ||||||||||||||||||||||||||||||||||||||||||
| 891 | $raw_rhs, $raw_adverb_list | ||||||||||||||||||||||||||||||||||||||||||
| 892 | 105 | ) = @{$alternative}; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 105 | my ( $adverb_list, $rhs ); | |||||||||||||||||||||||||||||||||||||||||
| 894 | 105 | my $eval_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 895 | 105 | $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 896 | 105 | $rhs = $raw_rhs->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 897 | 105 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 898 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 899 | 105 | ▶ | if ( not $eval_ok ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | my $eval_error = $EVAL_ERROR; | |||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | chomp $eval_error; | |||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 903 | qq{$eval_error\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 904 | qq{ The problem was in this RHS alternative:\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 905 | q{ }, | ||||||||||||||||||||||||||||||||||||||||||
| 906 | $parse->substring( $alternative_start, $alternative_length ), | ||||||||||||||||||||||||||||||||||||||||||
| 907 | "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 908 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 909 | } ## end if ( not $eval_ok ) | ||||||||||||||||||||||||||||||||||||||||||
| 910 | 105 | push @working_rules, [ $priority, $rhs, $adverb_list, $alternative_start, $alternative_length ]; | |||||||||||||||||||||||||||||||||||||||||
| 911 | } ## end for my $alternative (@alternatives) | ||||||||||||||||||||||||||||||||||||||||||
| 912 | } ## end for my $priority_ix ( 0 .. $priority_count - 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||
| 914 | # Default mask (all ones) is OK for this rule | ||||||||||||||||||||||||||||||||||||||||||
| 915 | 19 | my @arg0_action = (); | |||||||||||||||||||||||||||||||||||||||||
| 916 | 19 | ▶ | @arg0_action = ( action => '::first' ) if $subgrammar eq 'g1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | # Internal rule top priority rule for <$lhs> | ||||||||||||||||||||||||||||||||||||||||||
| 919 | 19 | $parse->symbol_assign_ordinary($lhs, $subgrammar); | |||||||||||||||||||||||||||||||||||||||||
| 920 | 19 | my @priority_rules = ( | |||||||||||||||||||||||||||||||||||||||||
| 921 | { | ||||||||||||||||||||||||||||||||||||||||||
| 922 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 923 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 924 | lhs => $lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 925 | rhs => [ $parse->prioritized_symbol( $lhs, 0 ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 926 | precedence => -1, | ||||||||||||||||||||||||||||||||||||||||||
| 927 | subkey => ++$xpr_ordinal, | ||||||||||||||||||||||||||||||||||||||||||
| 928 | @arg0_action, | ||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||
| 930 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | # Internal rule for symbol <$lhs> priority transition | ||||||||||||||||||||||||||||||||||||||||||
| 933 | push @priority_rules, | ||||||||||||||||||||||||||||||||||||||||||
| 934 | { | ||||||||||||||||||||||||||||||||||||||||||
| 935 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 936 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 937 | lhs => $parse->prioritized_symbol( $lhs, $_ - 1 ), | ||||||||||||||||||||||||||||||||||||||||||
| 938 | rhs => [ $parse->prioritized_symbol( $lhs, $_ ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 939 | precedence => ($_ - 1), | ||||||||||||||||||||||||||||||||||||||||||
| 940 | subkey => ++$xpr_ordinal, | ||||||||||||||||||||||||||||||||||||||||||
| 941 | @arg0_action | ||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | 19 | for 1 .. $priority_count - 1; | |||||||||||||||||||||||||||||||||||||||||
| 944 | 19 | RULE: for my $priority_rule (@priority_rules) { | |||||||||||||||||||||||||||||||||||||||||
| 945 | 70 | my $wrl = $parse->xpr_create( $priority_rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 946 | 70 | push @{$rules}, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | 19 | RULE: for my $working_rule (@working_rules) { | |||||||||||||||||||||||||||||||||||||||||
| 950 | 105 | my ( $priority, $rhs, $adverb_list, $alternative_start, $alternative_length ) = @{$working_rule}; | |||||||||||||||||||||||||||||||||||||||||
| 951 | 105 | my @new_rhs = @{ $rhs->{rhs} }; | |||||||||||||||||||||||||||||||||||||||||
| 952 | 105 | my @arity = grep { $new_rhs[$_] eq $lhs } 0 .. $#new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 953 | 105 | my $rhs_length = scalar @new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | 105 | my $current_exp = $parse->prioritized_symbol( $lhs, $priority ); | |||||||||||||||||||||||||||||||||||||||||
| 956 | 105 | my @mask = @{ $rhs->{mask} }; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 105 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | { | ||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 960 | 'hidden symbols are not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||||||||||||||||
| 961 | $lhs, '")' | ||||||||||||||||||||||||||||||||||||||||||
| 962 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||
| 964 | 105 | my %new_xs_rule = ( | |||||||||||||||||||||||||||||||||||||||||
| 965 | lhs => $current_exp, | ||||||||||||||||||||||||||||||||||||||||||
| 966 | start => $alternative_start, | ||||||||||||||||||||||||||||||||||||||||||
| 967 | length => $alternative_length, | ||||||||||||||||||||||||||||||||||||||||||
| 968 | subkey => ++$xpr_ordinal, | ||||||||||||||||||||||||||||||||||||||||||
| 969 | xrlid => $xrlid, | ||||||||||||||||||||||||||||||||||||||||||
| 970 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 971 | 105 | $new_xs_rule{mask} = \@mask; | |||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | 105 | my $action; | |||||||||||||||||||||||||||||||||||||||||
| 974 | my $assoc; | ||||||||||||||||||||||||||||||||||||||||||
| 975 | 105 | my $blessing; | |||||||||||||||||||||||||||||||||||||||||
| 976 | 105 | my $naming; | |||||||||||||||||||||||||||||||||||||||||
| 977 | 105 | my $rank; | |||||||||||||||||||||||||||||||||||||||||
| 978 | 105 | my $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 979 | 105 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 980 | 98 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 981 | 98 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 29 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 29 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||
| 985 | 69 | ▶ | if ( $key eq 'assoc' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 986 | 19 | $assoc = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 19 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||
| 989 | 50 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 990 | 50 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 50 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 999 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | die qq{Adverb "$key" not allowed in a prioritized rule\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1007 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||
| 1010 | 105 | ▶ | $assoc //= 'L'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$assoc //= "L"
MC/DC100%1/1
$assoc //= "L"
$assoc
Truth table100%2/2
A
A= $assoc
| |||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | 105 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 105 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | 99 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | 99 | $new_xs_rule{action} = $action; | |||||||||||||||||||||||||||||||||||||||||
| 1018 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 105 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 105 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1023 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | $new_xs_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 1026 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 105 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 105 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1031 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1033 | 0 | $new_xs_rule{rank} = $rank; | |||||||||||||||||||||||||||||||||||||||||
| 1034 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 105 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1037 | 105 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | and ( substr $subgrammar, 0, 1 ) eq 'l' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 1041 | 'bless option not allowed in lexical rules (rules LHS was "', | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | $lhs, '")' | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||
| 1046 | 105 | $parse->bless_hash_rule( \%new_xs_rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 105 | my $next_priority = $priority + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | # This is probably a mis-feature. It probably should be | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | # $next_priority = $priority if $next_priority >= $priority_count; | ||||||||||||||||||||||||||||||||||||||||||
| 1052 | # However, I probably will not change this, because some apps | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | # may be relying on this behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | 105 | ▶ | $next_priority = 0 if $next_priority >= $priority_count; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 105 | my $next_exp = $parse->prioritized_symbol( $lhs, $next_priority); | |||||||||||||||||||||||||||||||||||||||||
| 1057 | 105 | $new_xs_rule{precedence} = $priority; | |||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 105 | ▶ | if ( not scalar @arity ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 28 | $new_xs_rule{rhs} = \@new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 28 | $parse->symbol_assign_ordinary($_, $subgrammar) for @new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 28 | my $wrl = $parse->xpr_create( \%new_xs_rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | 28 | push @{$rules}, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1064 | 28 | next RULE; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||
| 1067 | 77 | ▶ | if ( scalar @arity == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 15 | ▶ | die 'Unnecessary unit rule in priority rule' if $rhs_length == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1069 | 15 | $new_rhs[ $arity[0] ] = $current_exp; | |||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | DO_ASSOCIATION: { | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | 77 | ▶ | if ( $assoc eq 'L' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1073 | 58 | $new_rhs[ $arity[0] ] = $current_exp; | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 58 | for my $rhs_ix ( @arity[ 1 .. $#arity ] ) { | |||||||||||||||||||||||||||||||||||||||||
| 1075 | 53 | $new_rhs[$rhs_ix] = $next_exp; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | 58 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||||||||||||||||
| 1078 | } ## end if ( $assoc eq 'L' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | 19 | ▶ | if ( $assoc eq 'R' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1080 | 9 | $new_rhs[ $arity[-1] ] = $current_exp; | |||||||||||||||||||||||||||||||||||||||||
| 1081 | 9 | for my $rhs_ix ( @arity[ 0 .. $#arity - 1 ] ) { | |||||||||||||||||||||||||||||||||||||||||
| 1082 | 9 | $new_rhs[$rhs_ix] = $next_exp; | |||||||||||||||||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | 9 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||||||||||||||||
| 1085 | } ## end if ( $assoc eq 'R' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | 10 | ▶ | if ( $assoc eq 'G' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 10 | for my $rhs_ix ( @arity[ 0 .. $#arity ] ) { | |||||||||||||||||||||||||||||||||||||||||
| 1088 | 10 | $new_rhs[$rhs_ix] = $parse->prioritized_symbol( $lhs, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | 10 | last DO_ASSOCIATION; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | } ## end if ( $assoc eq 'G' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | die qq{Unknown association type: "$assoc"}; | |||||||||||||||||||||||||||||||||||||||||
| 1093 | } ## end DO_ASSOCIATION: | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 77 | $parse->symbol_assign_ordinary($_, $subgrammar) for @new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 1096 | 77 | $new_xs_rule{rhs} = \@new_rhs; | |||||||||||||||||||||||||||||||||||||||||
| 1097 | 77 | my $wrl = $parse->xpr_create( \%new_xs_rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 77 | push @{$rules}, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1099 | } ## end RULE: for my $working_rule (@working_rules) | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | 19 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1102 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::priority_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||
| 1104 | sub Marpa::R3::Internal::MetaAST_Nodes::empty_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | 96 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=22 SCAR=41.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1106 | my ( $start, $length, $raw_lhs, $op_declare, $raw_adverb_list ) = | ||||||||||||||||||||||||||||||||||||||||||
| 1107 | 96 | @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 96 | ▶ | my $subgrammar = $op_declare->op() eq q{::=} ? 'g1' : 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 96 | my $lhs = $raw_lhs->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1112 | 96 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 96 | local $Marpa::R3::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 96 | my $xrlid = xrl_create($parse, { | |||||||||||||||||||||||||||||||||||||||||
| 1116 | lhs => $lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1118 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1120 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | # description => qq{Empty rule for <$lhs>}, | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | 95 | my %rule = ( | |||||||||||||||||||||||||||||||||||||||||
| 1123 | lhs => $lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1125 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1126 | rhs => [], | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | xrlid => $xrlid, | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | 95 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | 95 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | 95 | my $action; | |||||||||||||||||||||||||||||||||||||||||
| 1134 | my $blessing; | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 95 | my $naming; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | 95 | my $rank; | |||||||||||||||||||||||||||||||||||||||||
| 1137 | 95 | my $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 1138 | 95 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1139 | 30 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 30 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1141 | 30 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | 30 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | 0 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1161 | 0 | die qq{Adverb "$key" not allowed in an empty rule\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1162 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 95 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 95 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | 64 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1168 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | 64 | $rule{action} = $action; | |||||||||||||||||||||||||||||||||||||||||
| 1171 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 95 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1174 | 95 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1175 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | $rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 1179 | } ## end if ( defined $null_ranking ) | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||
| 1181 | 95 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1182 | 95 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1184 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | $rule{rank} = $rank; | |||||||||||||||||||||||||||||||||||||||||
| 1187 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 95 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 95 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 1191 | and ( substr $subgrammar, 0, 1 ) eq 'l' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 1194 | qq{bless option not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1195 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | 95 | $parse->bless_hash_rule( \%rule, $blessing, $naming, $lhs ); | |||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||
| 1199 | 95 | $parse->symbol_assign_ordinary($lhs, $subgrammar); | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 95 | my $wrl = $parse->xpr_create( \%rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 1201 | # mask not needed | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | 95 | push @{ $parse->{rules}->{$subgrammar} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | 95 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::empty_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | sub Marpa::R3::Internal::MetaAST_Nodes::lexeme_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | 89 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=16 SCAR=31.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 89 | my ( $start, $length, $symbol, $unevaluated_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | 89 | my $symbol_name = $symbol->name(); | |||||||||||||||||||||||||||||||||||||||||
| 1213 | 89 | my $declarations = $parse->{lexeme_declarations}->{$symbol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 1214 | 89 | ▶ | if ( defined $declarations ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | die "Duplicate lexeme rule for <$symbol_name>\n", | |||||||||||||||||||||||||||||||||||||||||
| 1217 | " Only one lexeme rule is allowed for each symbol\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | } ## end if ( defined $declarations ) | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||
| 1222 | 89 | my $adverb_list = $unevaluated_adverb_list->evaluate(); | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 89 | my %declarations; | |||||||||||||||||||||||||||||||||||||||||
| 1224 | 89 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1225 | 143 | my $raw_value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 143 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1227 | 0 | $declarations{$key} = $raw_value; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | 143 | ▶ | if ( $key eq 'blessing' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | $declarations{$key} = $raw_value; | |||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | 143 | ▶ | if ( $key eq 'eager' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1235 | 19 | ▶ | $declarations{$key} = 1 if $raw_value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1236 | 19 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | 124 | ▶ | if ( $key eq 'event' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1239 | 61 | $declarations{$key} = $raw_value; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | 61 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | 63 | ▶ | if ( $key eq 'pause' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 61 | ▶ | if ( $raw_value eq 'before' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 12 | $declarations{$key} = -1; | |||||||||||||||||||||||||||||||||||||||||
| 1245 | 12 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | 49 | ▶ | if ( $raw_value eq 'after' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1248 | 49 | $declarations{$key} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | 49 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | die qq{Bad value for "pause" adverb: "$raw_value"}, | |||||||||||||||||||||||||||||||||||||||||
| 1253 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | } ## end if ( $key eq 'pause' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | 2 | ▶ | if ( $key eq 'priority' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 2 | $declarations{$key} = $raw_value + 0; | |||||||||||||||||||||||||||||||||||||||||
| 1258 | 2 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | die qq{"$key" adverb not allowed in lexeme rule"\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1262 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | 89 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1266 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1268 | 0 | die | |||||||||||||||||||||||||||||||||||||||||
| 1269 | qq{"event" adverb not allowed without "pause" adverb in lexeme rule"\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1270 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | } ## end if ( exists $declarations{'event'} and not exists $declarations...) | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | 89 | ▶ | if ( exists $declarations{'pause'} and not exists $declarations{'event'} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $declarations{"pause"} and not exists $declarations{"event"}
MC/DC0%0/2
exists $declarations{"pause"} and not exists $declarations{"event"}
exists $declarations{"pause"}
not exists $declarations{"event"}
Truth table66%2/3
A and not(B)
A= exists $declarations{"pause"}B= not exists $declarations{"event"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1274 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1275 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 0 | die | |||||||||||||||||||||||||||||||||||||||||
| 1277 | qq{"pause" adverb not allowed without "event" adverb in lexeme rule"\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1278 | qq{ Events must be named with the "event" adverb\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | " Location was line $line, column $column\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1280 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1281 | } ## end if ( exists $declarations{'event'} and not exists $declarations...) | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | 89 | $parse->{lexeme_declarations}->{$symbol_name} = \%declarations; | |||||||||||||||||||||||||||||||||||||||||
| 1283 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | 89 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1285 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::lexeme_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||
| 1287 | sub Marpa::R3::Internal::MetaAST_Nodes::statements::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | 12 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1289 | 12 | my ( undef, undef, @statement_list ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1290 | 12 | map { $_->evaluate($parse) } @statement_list; | |||||||||||||||||||||||||||||||||||||||||
| 1291 | 12 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1292 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::statements::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||
| 1294 | sub Marpa::R3::Internal::MetaAST_Nodes::statement::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1295 | 2668 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1296 | 2668 | my ( undef, undef, $child ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1297 | 2668 | $child->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1298 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1299 | 2663 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1300 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::statement::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | sub Marpa::R3::Internal::MetaAST_Nodes::null_statement::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1303 | 25 | ▶ | return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||||||||||
| 1306 | sub Marpa::R3::Internal::MetaAST_Nodes::statement_group::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | 12 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1308 | 12 | my ( undef, undef, $statements ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1309 | 12 | $statements->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1310 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1311 | 12 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||
| 1314 | sub Marpa::R3::Internal::MetaAST_Nodes::start_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | 114 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1316 | 114 | my ( $start, $length, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1317 | 114 | ▶ | if ( defined $parse->{'start_lhs'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1318 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | die qq{There are two start rules\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1320 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | ' The second start rule is ', | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1325 | } ## end if ( defined $parse->{'start_lhs'} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | 114 | $parse->{'start_lhs'} = $symbol->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1327 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | 114 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1329 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::start_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | sub Marpa::R3::Internal::MetaAST_Nodes::discard_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | 196 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1333 | 196 | my ( $start, $length, $symbol, $raw_adverb_list ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||
| 1335 | 196 | local $Marpa::R3::Internal::SUBGRAMMAR = 'l0'; | |||||||||||||||||||||||||||||||||||||||||
| 1336 | 196 | my $discard_lhs = '[:discard:]'; | |||||||||||||||||||||||||||||||||||||||||
| 1337 | 196 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 1338 | dsl_form => $discard_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | 196 | $parse->xsy_assign( $discard_lhs, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1342 | 196 | $parse->symbol_names_set( $discard_lhs, 'l0', { xsy => $discard_lhs } ); | |||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||
| 1344 | 196 | my $rhs = $symbol->names($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1345 | 196 | my $discard_symbol = $rhs->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1346 | 196 | my $rhs_as_event = $symbol->event_name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1347 | 196 | my $adverb_list = $raw_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1348 | 196 | my $event; | |||||||||||||||||||||||||||||||||||||||||
| 1349 | my $eager; | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | 196 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1351 | 53 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1352 | 53 | ▶ | if ( $key eq 'eager' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1353 | 2 | ▶ | $eager = 1 if $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1354 | 2 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | 51 | ▶ | if ( $key eq 'event' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 51 | $event = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1358 | 51 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | qq{"$key" adverb not allowed with discard rule"}); | |||||||||||||||||||||||||||||||||||||||||
| 1362 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 196 | my $discard_symbol_data = $parse->discard_symbol_assign($discard_symbol); | |||||||||||||||||||||||||||||||||||||||||
| 1365 | 196 | ▶ | if ($eager) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1366 | 2 | $discard_symbol_data->{eager} = $eager; | |||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||
| 1369 | # Discard rule | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | 196 | my %rule_hash = ( | |||||||||||||||||||||||||||||||||||||||||
| 1371 | lhs => $discard_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1372 | rhs => [$discard_symbol], | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1374 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1375 | symbol_as_event => $rhs_as_event | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | 196 | ▶ | $rule_hash{event} = $event if defined $event; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1378 | 196 | my $wrl = $parse->xpr_create( \%rule_hash, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 1379 | 196 | push @{ $parse->{rules}->{l0} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1380 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | 196 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1382 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::discard_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||
| 1384 | sub Marpa::R3::Internal::MetaAST_Nodes::quantified_rule::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | 318 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=29 SCAR=37.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1386 | my ( $start, $length, $lhs, $op_declare, $rhs, $quantifier, | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | $proto_adverb_list ) | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | 318 | = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||
| 1390 | 318 | ▶ | my $subgrammar = $op_declare->op() eq q{::=} ? 'g1' : 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 318 | my $lhs_name = $lhs->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1393 | 318 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 318 | local $Marpa::R3::Internal::SUBGRAMMAR = $subgrammar; | |||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 318 | my $quantifier_string = $quantifier->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1397 | 318 | my $xrlid = xrl_create($parse, { | |||||||||||||||||||||||||||||||||||||||||
| 1398 | lhs => $lhs_name, | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||
| 1404 | 318 | my $adverb_list = $proto_adverb_list->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1405 | 318 | my $default_adverbs = $parse->{default_adverbs}->{$subgrammar}; | |||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||
| 1407 | # Some properties of the sequence rule will not be altered | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | # no matter how complicated this gets | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | 318 | ▶ | my %sequence_rule = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1410 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | xrlid => $xrlid, | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | rhs => [ $rhs->name($parse) ], | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | min => ( $quantifier_string eq q{+} ? 1 : 0 ) | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 318 | my $action; | |||||||||||||||||||||||||||||||||||||||||
| 1418 | my $blessing; | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | 318 | my $naming; | |||||||||||||||||||||||||||||||||||||||||
| 1420 | 318 | my $separator; | |||||||||||||||||||||||||||||||||||||||||
| 1421 | 318 | my $proper; | |||||||||||||||||||||||||||||||||||||||||
| 1422 | 318 | my $rank; | |||||||||||||||||||||||||||||||||||||||||
| 1423 | 318 | my $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 1424 | 318 | ADVERB: for my $key ( keys %{$adverb_list} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1425 | 71 | my $value = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1426 | 71 | ▶ | if ( $key eq 'action' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 44 | $action = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1428 | 44 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1430 | 27 | ▶ | if ( $key eq 'bless' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1431 | 4 | $blessing = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1432 | 4 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1434 | 23 | ▶ | if ( $key eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | $naming = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | 23 | ▶ | if ( $key eq 'proper' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1439 | 4 | $proper = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1440 | 4 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | 19 | ▶ | if ( $key eq 'rank' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | $rank = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1444 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1446 | 19 | ▶ | if ( $key eq 'null_ranking' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | $null_ranking = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | 19 | ▶ | if ( $key eq 'separator' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1451 | 19 | $separator = $adverb_list->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 1452 | 19 | next ADVERB; | |||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1455 | 0 | die qq{Adverb "$key" not allowed in quantified rule\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1456 | ' Rule was ', $parse->substring( $start, $length ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | } ## end ADVERB: for my $key ( keys %{$adverb_list} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||
| 1459 | # mask not needed | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | 318 | $sequence_rule{lhs} = $lhs_name; | |||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||
| 1462 | 318 | ▶ | $sequence_rule{separator} = $separator | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1463 | if defined $separator; | ||||||||||||||||||||||||||||||||||||||||||
| 1464 | 318 | ▶ | $sequence_rule{proper} = $proper if defined $proper; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | 318 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1467 | 318 | ▶ | if ( defined $action ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1468 | 79 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1469 | qq{actions not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1470 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | 79 | $sequence_rule{action} = $action; | |||||||||||||||||||||||||||||||||||||||||
| 1472 | } ## end if ( defined $action ) | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||
| 1474 | 318 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1475 | 318 | ▶ | if ( defined $null_ranking ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1476 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1477 | qq{null-ranking not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1478 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | $sequence_rule{null_ranking} = $null_ranking; | |||||||||||||||||||||||||||||||||||||||||
| 1480 | } ## end if ( defined $null_ranking ) | ||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||
| 1482 | 318 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1483 | 318 | ▶ | if ( defined $rank ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 0 | ▶ | Marpa::R3::exception( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1485 | qq{ranks not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | ) if ( substr $subgrammar, 0, 1 ) eq 'l'; | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | $sequence_rule{rank} = $rank; | |||||||||||||||||||||||||||||||||||||||||
| 1488 | } ## end if ( defined $rank ) | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||
| 1490 | 318 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1491 | 318 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 1492 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 1494 | qq{bless option not allowed in lexical rules (rule's LHS was "$lhs")} | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | 318 | $parse->symbol_assign_ordinary($_, $subgrammar) for $lhs_name, @{$sequence_rule{rhs}}; | |||||||||||||||||||||||||||||||||||||||||
| 1498 | 318 | ▶ | $parse->symbol_assign_ordinary($separator, $subgrammar) if defined $separator; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1499 | 318 | $parse->bless_hash_rule( \%sequence_rule, $blessing, $naming, $lhs_name ); | |||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||
| 1501 | 318 | my $wrl = $parse->xpr_create( \%sequence_rule, $subgrammar ); | |||||||||||||||||||||||||||||||||||||||||
| 1502 | 318 | push @{ $parse->{rules}->{$subgrammar} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | 318 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||
| 1506 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::quantified_rule::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||
| 1508 | sub Marpa::R3::Internal::MetaAST_Nodes::completion_event_declaration::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1509 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | 60 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1511 | 60 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1512 | 60 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||||||||||||||||
| 1513 | 60 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1514 | 60 | ▶ | if ( defined $completion_events->{$symbol_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1515 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1516 | 0 | die qq{Completion event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1517 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1518 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||||||||||||||||
| 1519 | "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1520 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1521 | } ## end if ( defined $completion_events->{$symbol_name} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1522 | 60 | $completion_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||||||||||||||||
| 1523 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1524 | 60 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1525 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::completion_event_declaration::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||
| 1527 | sub Marpa::R3::Internal::MetaAST_Nodes::nulled_event_declaration::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | 46 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1529 | 46 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1530 | 46 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||||||||||||||||
| 1531 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | 46 | ▶ | if ( defined $nulled_events->{$symbol_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | die qq{nulled event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1535 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1538 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1539 | } ## end if ( defined $nulled_events->{$symbol_name} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1540 | 46 | $nulled_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||||||||||||||||
| 1541 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | 46 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1543 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::nulled_event_declaration::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||
| 1545 | sub Marpa::R3::Internal::MetaAST_Nodes::prediction_event_declaration::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1546 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | 55 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1548 | 55 | my ( $start, $length, $raw_event, $raw_symbol_name ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1549 | 55 | my $symbol_name = $raw_symbol_name->name(); | |||||||||||||||||||||||||||||||||||||||||
| 1550 | 55 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1551 | 55 | ▶ | if ( defined $prediction_events->{$symbol_name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | my ( $line, $column ) = $parse->{meta_recce}->line_column($start); | |||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | die qq{prediction event for symbol "$symbol_name" declared twice\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1554 | qq{ That is not allowed\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1555 | ' Second declaration was ', $parse->substring( $start, $length ), | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | " Problem occurred at line $line, column $column\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | } ## end if ( defined $prediction_events->{$symbol_name} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | 55 | $prediction_events->{$symbol_name} = $raw_event->event(); | |||||||||||||||||||||||||||||||||||||||||
| 1560 | ## no critic(Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | 55 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 1562 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::prediction_event_declaration::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||
| 1564 | sub Marpa::R3::Internal::MetaAST_Nodes::alternatives::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1565 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1566 | 0 | return bless [ map { $_->evaluate( $_, $parse ) } @{$values} ], | |||||||||||||||||||||||||||||||||||||||||
| 1567 | ref $values; | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||
| 1570 | sub Marpa::R3::Internal::MetaAST_Nodes::alternative::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 0 | my ( $start, $length, $rhs, $adverbs ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | my $alternative = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1574 | Marpa::R3::Internal::MetaAST::Proto_Alternative->combine( | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | map { $_->evaluate($parse) } $rhs, $adverbs ); | |||||||||||||||||||||||||||||||||||||||||
| 1576 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | if ( not $alternative ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | Marpa::R3::exception( | |||||||||||||||||||||||||||||||||||||||||
| 1579 | $EVAL_ERROR, "\n", | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | q{ Alternative involved was }, | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | $parse->substring( $start, $length ) | ||||||||||||||||||||||||||||||||||||||||||
| 1582 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | } ## end if ( not $alternative ) | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | 0 | return $alternative; | |||||||||||||||||||||||||||||||||||||||||
| 1585 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::alternative::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | |||||||||||||||||||||||||||||||||||||||||||
| 1587 | sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::names { | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | 196 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1589 | 196 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1590 | 196 | return $symbol->names($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||||||||||||||||
| 1593 | sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::name { | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | 337 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 337 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1596 | 337 | return $symbol->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||
| 1599 | sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::event_name { | ||||||||||||||||||||||||||||||||||||||||||
| 1600 | 196 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1601 | 196 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1602 | 196 | return $symbol->event_name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1604 | |||||||||||||||||||||||||||||||||||||||||||
| 1605 | sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::literal { | ||||||||||||||||||||||||||||||||||||||||||
| 1606 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
literal: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1607 | 0 | my ( $start, $length ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1608 | 0 | return $parse->substring($start, $length); | |||||||||||||||||||||||||||||||||||||||||
| 1609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | |||||||||||||||||||||||||||||||||||||||||||
| 1611 | sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1612 | 2155 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1613 | 2155 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1614 | 2155 | return Marpa::R3::Internal::MetaAST::Symbol_List->new( | |||||||||||||||||||||||||||||||||||||||||
| 1615 | $symbol->name($parse) ); | ||||||||||||||||||||||||||||||||||||||||||
| 1616 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::single_symbol::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||
| 1618 | sub Marpa::R3::Internal::MetaAST_Nodes::Symbol::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | my ( undef, undef, $symbol ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1621 | 0 | return $symbol->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||
| 1624 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol::name { | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | 2266 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1626 | 2266 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||
| 1629 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol::event_name { | ||||||||||||||||||||||||||||||||||||||||||
| 1630 | 178 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1631 | 178 | return $self->[2]->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||
| 1634 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol::names { | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | 178 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1636 | 178 | return $self->[2]->names($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||
| 1639 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol_name::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | 4637 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1641 | 4637 | return $self->[2]; | |||||||||||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||
| 1644 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol_name::name { | ||||||||||||||||||||||||||||||||||||||||||
| 1645 | 4637 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1646 | 4637 | return $self->evaluate($parse)->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||
| 1649 | sub Marpa::R3::Internal::MetaAST_Nodes::symbol_name::names { | ||||||||||||||||||||||||||||||||||||||||||
| 1650 | 178 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1651 | 178 | return [ $self->name($parse) ]; | |||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||
| 1654 | sub Marpa::R3::Internal::MetaAST_Nodes::adverb_list::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1655 | 2704 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1656 | 2704 | my ( undef, undef, $adverb_list_items ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1657 | 2704 | ▶ | return undef if not defined $adverb_list_items; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1658 | 821 | return $adverb_list_items->evaluate($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1659 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::adverb_list::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||
| 1661 | sub Marpa::R3::Internal::MetaAST_Nodes::null_adverb::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | 6 | ▶ | return {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||||||||||
| 1665 | sub Marpa::R3::Internal::MetaAST_Nodes::adverb_list_items::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1666 | 821 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1667 | 821 | my ( undef, undef, @raw_items ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1668 | 821 | my (@adverb_items) = map { $_->evaluate($parse) } @raw_items; | |||||||||||||||||||||||||||||||||||||||||
| 1669 | 821 | return Marpa::R3::Internal::MetaAST::Proto_Alternative->combine( | |||||||||||||||||||||||||||||||||||||||||
| 1670 | @adverb_items); | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::adverb_list::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||
| 1673 | sub Marpa::R3::Internal::MetaAST_Nodes::character_class::event_name { | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | 18 | ▶ | my ( $data, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
event_name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1675 | 18 | my ( $start, $length ) = @{$data}; | |||||||||||||||||||||||||||||||||||||||||
| 1676 | 18 | return $parse->substring( $start, $length ); | |||||||||||||||||||||||||||||||||||||||||
| 1677 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||
| 1679 | sub Marpa::R3::Internal::MetaAST_Nodes::character_class::names { | ||||||||||||||||||||||||||||||||||||||||||
| 1680 | 18 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1681 | 18 | return [ $self->name($parse) ]; | |||||||||||||||||||||||||||||||||||||||||
| 1682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||||||||||||||||
| 1684 | sub Marpa::R3::Internal::MetaAST_Nodes::character_class::name { | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | 447 | ▶ | my ( $self, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1686 | 447 | return $self->evaluate($parse)->name($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | sub Marpa::R3::Internal::MetaAST_Nodes::character_class::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | 447 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 447 | my ( $start, $length, $character_class ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1692 | 447 | my $subgrammar = $Marpa::R3::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||||||||||||||||
| 1693 | 447 | ▶ | if ( ( substr $subgrammar, 0, 1 ) eq 'l' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1694 | 430 | return Marpa::R3::Internal::MetaAST::Symbol_List->char_class_to_symbol( | |||||||||||||||||||||||||||||||||||||||||
| 1695 | $parse, $character_class ); | ||||||||||||||||||||||||||||||||||||||||||
| 1696 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||
| 1698 | # If here, in G1 | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | # Character classes and strings always go into L0, for now | ||||||||||||||||||||||||||||||||||||||||||
| 1700 | 17 | my $lexer_symbol = do { | |||||||||||||||||||||||||||||||||||||||||
| 1701 | 17 | local $Marpa::R3::Internal::SUBGRAMMAR = 'l0'; | |||||||||||||||||||||||||||||||||||||||||
| 1702 | 17 | Marpa::R3::Internal::MetaAST::Symbol_List->char_class_to_symbol( $parse, | |||||||||||||||||||||||||||||||||||||||||
| 1703 | $character_class ); | ||||||||||||||||||||||||||||||||||||||||||
| 1704 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1705 | 17 | my $lexical_lhs = $parse->internal_lexeme($character_class); | |||||||||||||||||||||||||||||||||||||||||
| 1706 | 17 | my $lexical_rhs = $lexer_symbol->names($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1707 | 17 | my %lexical_rule = ( | |||||||||||||||||||||||||||||||||||||||||
| 1708 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1710 | lhs => $lexical_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1711 | rhs => $lexical_rhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1712 | mask => [1], | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1714 | 17 | my $wrl = $parse->xpr_create( \%lexical_rule, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 1715 | 17 | push @{ $parse->{rules}->{l0} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1716 | 17 | my $g1_symbol = | |||||||||||||||||||||||||||||||||||||||||
| 1717 | Marpa::R3::Internal::MetaAST::Symbol_List->new($lexical_lhs); | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | 17 | return $g1_symbol; | |||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||
| 1721 | sub Marpa::R3::Internal::MetaAST_Nodes::single_quoted_string::evaluate { | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | 837 | ▶ | my ( $values, $parse ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1723 | 837 | my ( $start, $length, $string ) = @{$values}; | |||||||||||||||||||||||||||||||||||||||||
| 1724 | 837 | my @symbols = (); | |||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||
| 1726 | 837 | my $end_of_string = rindex $string, q{'}; | |||||||||||||||||||||||||||||||||||||||||
| 1727 | 837 | my $unmodified_string = substr $string, 0, $end_of_string+1; | |||||||||||||||||||||||||||||||||||||||||
| 1728 | 837 | my $raw_flags = substr $string, $end_of_string+1; | |||||||||||||||||||||||||||||||||||||||||
| 1729 | 837 | my $flags = Marpa::R3::Internal::MetaAST::flag_string_to_flags($raw_flags); | |||||||||||||||||||||||||||||||||||||||||
| 1730 | 837 | my $subgrammar = $Marpa::R3::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||
| 1732 | # If we are currently in a lexical grammar, the strings go there | ||||||||||||||||||||||||||||||||||||||||||
| 1733 | # If we are currently in G1, the strings always go into L0 | ||||||||||||||||||||||||||||||||||||||||||
| 1734 | 837 | ▶ | my $lexical_grammar = $subgrammar eq 'g1' ? 'l0' : $subgrammar; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||
| 1736 | 837 | for my $char_class ( | |||||||||||||||||||||||||||||||||||||||||
| 1737 | 1299 | map { '[' . ( quotemeta $_ ) . ']' . $flags } split //xms, | |||||||||||||||||||||||||||||||||||||||||
| 1738 | substr $unmodified_string, | ||||||||||||||||||||||||||||||||||||||||||
| 1739 | 1, -1 | ||||||||||||||||||||||||||||||||||||||||||
| 1740 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1741 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1742 | 1299 | local $Marpa::R3::Internal::SUBGRAMMAR = $lexical_grammar; | |||||||||||||||||||||||||||||||||||||||||
| 1743 | 1299 | my $symbol = | |||||||||||||||||||||||||||||||||||||||||
| 1744 | Marpa::R3::Internal::MetaAST::Symbol_List->char_class_to_symbol( | ||||||||||||||||||||||||||||||||||||||||||
| 1745 | $parse, $char_class ); | ||||||||||||||||||||||||||||||||||||||||||
| 1746 | 1299 | push @symbols, $symbol; | |||||||||||||||||||||||||||||||||||||||||
| 1747 | } ## end for my $char_class ( map { '[' . ( quotemeta $_ ) . ']'...}) | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | 837 | my $list = Marpa::R3::Internal::MetaAST::Symbol_List->combine(@symbols); | |||||||||||||||||||||||||||||||||||||||||
| 1749 | 837 | ▶ | return $list if $Marpa::R3::Internal::SUBGRAMMAR ne 'g1'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1750 | 331 | my $lexical_lhs = $parse->{lexeme_for_string}->{$string}; | |||||||||||||||||||||||||||||||||||||||||
| 1751 | 331 | ▶ | if (not defined $lexical_lhs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1752 | 276 | $lexical_lhs = $parse->internal_lexeme($string); | |||||||||||||||||||||||||||||||||||||||||
| 1753 | 276 | $parse->{lexeme_for_string}->{$string}= $lexical_lhs; | |||||||||||||||||||||||||||||||||||||||||
| 1754 | 276 | my $lexical_rhs = $list->names($parse); | |||||||||||||||||||||||||||||||||||||||||
| 1755 | my %lexical_rule = ( | ||||||||||||||||||||||||||||||||||||||||||
| 1756 | start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | length => $length, | ||||||||||||||||||||||||||||||||||||||||||
| 1758 | lhs => $lexical_lhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | rhs => $lexical_rhs, | ||||||||||||||||||||||||||||||||||||||||||
| 1760 | # description => "Internal rule for single-quoted string $string", | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | 276 | mask => [ map { ; 1 } @{$lexical_rhs} ], | |||||||||||||||||||||||||||||||||||||||||
| 1762 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1763 | 276 | my $wrl = $parse->xpr_create( \%lexical_rule, 'l0' ); | |||||||||||||||||||||||||||||||||||||||||
| 1764 | 276 | push @{ $parse->{rules}->{$lexical_grammar} }, $wrl; | |||||||||||||||||||||||||||||||||||||||||
| 1765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | 331 | my $g1_symbol = | |||||||||||||||||||||||||||||||||||||||||
| 1767 | Marpa::R3::Internal::MetaAST::Symbol_List->new($lexical_lhs); | ||||||||||||||||||||||||||||||||||||||||||
| 1768 | 331 | return $g1_symbol; | |||||||||||||||||||||||||||||||||||||||||
| 1769 | } ## end sub Marpa::R3::Internal::MetaAST_Nodes::single_quoted_string::evaluate | ||||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||
| 1771 | package Marpa::R3::Internal::MetaAST::Symbol_List; | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||
| 1773 | 104 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||
| 1775 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 1776 | 4254 | ▶ | my ( $class, $name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1777 | 4254 | return bless { names => [ q{} . $name ], mask => [1] }, $class; | |||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||
| 1780 | sub combine { | ||||||||||||||||||||||||||||||||||||||||||
| 1781 | 5858 | ▶ | my ( $class, @lists ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
combine: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1782 | 5858 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1783 | 5858 | $self->{names} = [ map { @{ $_->names() } } @lists ]; | |||||||||||||||||||||||||||||||||||||||||
| 1784 | 5858 | $self->{mask} = [ map { @{ $_->mask() } } @lists ]; | |||||||||||||||||||||||||||||||||||||||||
| 1785 | 5858 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 1786 | } ## end sub combine | ||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||
| 1788 | sub Marpa::R3::Internal::MetaAST::flag_string_to_flags { | ||||||||||||||||||||||||||||||||||||||||||
| 1789 | 2588 | ▶ | my ($raw_flag_string) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flag_string_to_flags: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1790 | 2588 | ▶ | return q{} if not $raw_flag_string; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1791 | 36 | my @raw_flags = split m/:/xms, $raw_flag_string; | |||||||||||||||||||||||||||||||||||||||||
| 1792 | 36 | my %flags = (); | |||||||||||||||||||||||||||||||||||||||||
| 1793 | 36 | RAW_FLAG: for my $raw_flag (@raw_flags) { | |||||||||||||||||||||||||||||||||||||||||
| 1794 | 44 | ▶ | next RAW_FLAG if not $raw_flag; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1795 | 36 | ▶ | if ( $raw_flag eq 'i' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1796 | 34 | $flags{'i'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1797 | 34 | next RAW_FLAG; | |||||||||||||||||||||||||||||||||||||||||
| 1798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1799 | 2 | ▶ | if ( $raw_flag eq 'ic' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1800 | 2 | $flags{'i'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1801 | 2 | next RAW_FLAG; | |||||||||||||||||||||||||||||||||||||||||
| 1802 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1803 | Carp::croak( | ||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | qq{Bad flag for character class\n}, | |||||||||||||||||||||||||||||||||||||||||
| 1805 | qq{ Flag string was $raw_flag_string\n}, | ||||||||||||||||||||||||||||||||||||||||||
| 1806 | qq{ Bad flag was $raw_flag\n} | ||||||||||||||||||||||||||||||||||||||||||
| 1807 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | } ## end RAW_FLAG: for my $raw_flag (@raw_flags) | ||||||||||||||||||||||||||||||||||||||||||
| 1809 | 36 | my $cooked_flags = join q{}, sort keys %flags; | |||||||||||||||||||||||||||||||||||||||||
| 1810 | 36 | return $cooked_flags; | |||||||||||||||||||||||||||||||||||||||||
| 1811 | } ## end sub flag_string_to_flags | ||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||
| 1813 | # Return the character class symbol name, | ||||||||||||||||||||||||||||||||||||||||||
| 1814 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||||||||||||||||
| 1815 | sub char_class_to_symbol { | ||||||||||||||||||||||||||||||||||||||||||
| 1816 | 1751 | ▶ | my ( $class, $parse, $char_class ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
char_class_to_symbol: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||||||||||||
| 1818 | 1751 | my $end_of_char_class = rindex $char_class, q{]}; | |||||||||||||||||||||||||||||||||||||||||
| 1819 | 1751 | my $unmodified_char_class = substr $char_class, 0, $end_of_char_class + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1820 | 1751 | my $raw_flags = substr $char_class, $end_of_char_class + 1; | |||||||||||||||||||||||||||||||||||||||||
| 1821 | 1751 | my $flags = Marpa::R3::Internal::MetaAST::flag_string_to_flags($raw_flags); | |||||||||||||||||||||||||||||||||||||||||
| 1822 | 1751 | my $subgrammar = $Marpa::R3::Internal::SUBGRAMMAR; | |||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||
| 1824 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||||||||||||||||
| 1825 | 1751 | my $symbol_name = '[' . $unmodified_char_class . $flags . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 1826 | 1751 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1827 | 1751 | my $cc_hash = $parse->{character_classes}; | |||||||||||||||||||||||||||||||||||||||||
| 1828 | 1751 | my ( undef, $symbol ) = $cc_hash->{$symbol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 1829 | 1751 | ▶ | if ( not defined $symbol ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1830 | |||||||||||||||||||||||||||||||||||||||||||
| 1831 | 1751 | my $cc_components = [ $unmodified_char_class, $flags ]; | |||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||
| 1833 | 1751 | $symbol = Marpa::R3::Internal::MetaAST::Symbol_List->new($symbol_name); | |||||||||||||||||||||||||||||||||||||||||
| 1834 | 1751 | $cc_hash->{$symbol_name} = [ $cc_components, $symbol ]; | |||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||
| 1836 | # description => "Character class: $char_class" | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | 1751 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 1838 | dsl_form => $char_class, | ||||||||||||||||||||||||||||||||||||||||||
| 1839 | name_source => 'internal', | ||||||||||||||||||||||||||||||||||||||||||
| 1840 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||
| 1842 | # description => "Character class: $char_class" | ||||||||||||||||||||||||||||||||||||||||||
| 1843 | 1751 | $parse->xsy_create( $symbol_name, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1844 | 1751 | $symbol_data = { xsy => $symbol_name }; | |||||||||||||||||||||||||||||||||||||||||
| 1845 | 1751 | $parse->symbol_names_set( $symbol_name, $subgrammar, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1846 | } ## end if ( not defined $symbol ) | ||||||||||||||||||||||||||||||||||||||||||
| 1847 | 1751 | return $symbol; | |||||||||||||||||||||||||||||||||||||||||
| 1848 | } ## end sub char_class_to_symbol | ||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||
| 1850 | sub Marpa::R3::Internal::MetaAST::Parse::symbol_names_set { | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | 6481 | ▶ | my ( $parse, $symbol, $subgrammar, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
symbol_names_set: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1852 | 6481 | ▶ | my $symbol_type = $subgrammar eq 'g1' ? 'g1' : 'l0'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1853 | 6481 | my $wsyid = $parse->{next_wsyid}++; | |||||||||||||||||||||||||||||||||||||||||
| 1854 | 6481 | $parse->{symbols}->{$symbol_type}->{$symbol}->{wsyid} = $wsyid; | |||||||||||||||||||||||||||||||||||||||||
| 1855 | 6481 | for my $arg_type (keys %{$args}) { | |||||||||||||||||||||||||||||||||||||||||
| 1856 | 6551 | my $value = $args->{$arg_type}; | |||||||||||||||||||||||||||||||||||||||||
| 1857 | 6551 | $parse->{symbols}->{$symbol_type}->{$symbol}->{$arg_type} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1858 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1859 | 6481 | return $parse->{symbols}->{$symbol_type}->{$symbol}; | |||||||||||||||||||||||||||||||||||||||||
| 1860 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||
| 1862 | # Return the priotized symbol name, | ||||||||||||||||||||||||||||||||||||||||||
| 1863 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||||||||||||||||
| 1864 | sub Marpa::R3::Internal::MetaAST::Parse::prioritized_symbol { | ||||||||||||||||||||||||||||||||||||||||||
| 1865 | 341 | ▶ | my ( $parse, $base_symbol, $priority ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prioritized_symbol: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||
| 1867 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | 341 | my $symbol_name = $base_symbol . '[' . $priority . ']'; | |||||||||||||||||||||||||||||||||||||||||
| 1869 | my $current_symbol_data = | ||||||||||||||||||||||||||||||||||||||||||
| 1870 | $parse->{symbols} | ||||||||||||||||||||||||||||||||||||||||||
| 1871 | ->{ $Marpa::R3::Internal::SUBGRAMMAR eq 'g1' ? 'g1' : 'l0' } | ||||||||||||||||||||||||||||||||||||||||||
| 1872 | 341 | ▶ | ->{$symbol_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1873 | 341 | ▶ | return $symbol_name if defined $current_symbol_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1874 | |||||||||||||||||||||||||||||||||||||||||||
| 1875 | # description => "<$base_symbol> at priority $priority" | ||||||||||||||||||||||||||||||||||||||||||
| 1876 | 70 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 1877 | dsl_form => $base_symbol, | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | name_source => 'lexical', | ||||||||||||||||||||||||||||||||||||||||||
| 1879 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1880 | 70 | $parse->xsy_assign( $base_symbol, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1881 | 70 | $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 1882 | xsy => $base_symbol, | ||||||||||||||||||||||||||||||||||||||||||
| 1883 | precedence => $priority, | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | 70 | $parse->symbol_names_set( $symbol_name, $Marpa::R3::Internal::SUBGRAMMAR, | |||||||||||||||||||||||||||||||||||||||||
| 1886 | $symbol_data ); | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | 70 | return $symbol_name; | |||||||||||||||||||||||||||||||||||||||||
| 1888 | } ## end sub Marpa::R3::Internal::MetaAST::Parse::prioritized_symbol | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||
| 1890 | sub Marpa::R3::Internal::MetaAST::Parse::discard_symbol_assign { | ||||||||||||||||||||||||||||||||||||||||||
| 1891 | 196 | ▶ | my ( $parse, $symbol_name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
discard_symbol_assign: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||
| 1893 | my $current_symbol_data = | ||||||||||||||||||||||||||||||||||||||||||
| 1894 | 196 | $parse->{symbols}->{'l0'}->{$symbol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 1895 | 196 | ▶ | return $symbol_name if defined $current_symbol_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1896 | |||||||||||||||||||||||||||||||||||||||||||
| 1897 | 143 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 1898 | dsl_form => $symbol_name, | ||||||||||||||||||||||||||||||||||||||||||
| 1899 | name_source => 'lexical', | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | 143 | $parse->xsy_assign( $symbol_name, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1902 | 143 | $symbol_data = { xsy => $symbol_name }; | |||||||||||||||||||||||||||||||||||||||||
| 1903 | 143 | return $parse->symbol_names_set( $symbol_name, 'l0', $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 1904 | } ## end sub Marpa::R3::Internal::MetaAST::Parse::prioritized_symbol | ||||||||||||||||||||||||||||||||||||||||||
| 1905 | |||||||||||||||||||||||||||||||||||||||||||
| 1906 | sub Marpa::R3::Internal::MetaAST::Parse::xsy_create { | ||||||||||||||||||||||||||||||||||||||||||
| 1907 | 4732 | ▶ | my ( $parse, $symbol_name, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xsy_create: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1908 | 4732 | my $xsy_data = $parse->{xsy}->{$symbol_name} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||
| 1910 | # Do I need to copy any more? | ||||||||||||||||||||||||||||||||||||||||||
| 1911 | # Can't I just use $args? | ||||||||||||||||||||||||||||||||||||||||||
| 1912 | 4732 | for my $datum (keys %{$args}) { | |||||||||||||||||||||||||||||||||||||||||
| 1913 | 9464 | my $value = $args->{$datum}; | |||||||||||||||||||||||||||||||||||||||||
| 1914 | 9464 | $xsy_data->{$datum} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 1915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1916 | 4732 | return $xsy_data; | |||||||||||||||||||||||||||||||||||||||||
| 1917 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||||||||||||||||
| 1919 | sub Marpa::R3::Internal::MetaAST::Parse::xsy_assign { | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | 3871 | ▶ | my ( $parse, $symbol_name, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xsy_assign: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1921 | 3871 | my $xsy_data = $parse->{xsy}->{$symbol_name}; | |||||||||||||||||||||||||||||||||||||||||
| 1922 | 3871 | ▶ | return $xsy_data if $xsy_data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1923 | 2415 | return $parse->xsy_create( $symbol_name, $args ); | |||||||||||||||||||||||||||||||||||||||||
| 1924 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||
| 1926 | # eXternal RuLe | ||||||||||||||||||||||||||||||||||||||||||
| 1927 | # At the moment, these are only for rules which can share | ||||||||||||||||||||||||||||||||||||||||||
| 1928 | # a LHS with a precedenced rule. | ||||||||||||||||||||||||||||||||||||||||||
| 1929 | sub Marpa::R3::Internal::MetaAST::xrl_create { | ||||||||||||||||||||||||||||||||||||||||||
| 1930 | 1854 | ▶ | my ( $parse, $new_xrl ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xrl_create: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1931 | 1854 | my $lhs = $new_xrl->{lhs}; | |||||||||||||||||||||||||||||||||||||||||
| 1932 | 1854 | my $start = $new_xrl->{start}; | |||||||||||||||||||||||||||||||||||||||||
| 1933 | 1854 | my $length = $new_xrl->{length}; | |||||||||||||||||||||||||||||||||||||||||
| 1934 | 1854 | ▶ | $new_xrl->{precedence_count} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$new_xrl->{"precedence_count"} //= 1
MC/DC100%1/1
$new_xrl->{"precedence_count"} //= 1
$new_xrl->{"precedence_count"}
Truth table100%2/2
A
A= $new_xrl->{"precedence_count"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1935 | 1854 | my $xrlid = sprintf '%s@%d+%d', $lhs, $start, $length; | |||||||||||||||||||||||||||||||||||||||||
| 1936 | 1854 | my $xrls_by_lhs = $parse->{xrls_by_lhs}->{$lhs}; | |||||||||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||||||||||
| 1938 | 1854 | my $earlier_xrl = $xrls_by_lhs->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1939 | 1854 | ▶ | if ( $earlier_xrl | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$earlier_xrl and $earlier_xrl->{"precedence_count"} > 1 || $new_xrl->{"precedence_count"} > 1
$earlier_xrl->{"precedence_count"} > 1 or $new_xrl->{"precedence_count"} > 1
MC/DC66%2/3
$earlier_xrl and $earlier_xrl->{"precedence_count"} > 1 || $new_xrl->{"precedence_count"} > 1
$earlier_xrl
$earlier_xrl->{"precedence_count"} > 1
$new_xrl->{"precedence_count"} > 1
Truth table75%3/4
A and B or C
A= $earlier_xrlB= $earlier_xrl->{"precedence_count"} > 1C= $new_xrl->{"precedence_count"} > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1940 | and $earlier_xrl->{precedence_count} > 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1941 | || $new_xrl->{precedence_count} > 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 1942 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||
| 1944 | # If there was an earlier precedenced xrl | ||||||||||||||||||||||||||||||||||||||||||
| 1945 | # that needed to be unique for this LHS, | ||||||||||||||||||||||||||||||||||||||||||
| 1946 | # it was the only pre-existing xrl. | ||||||||||||||||||||||||||||||||||||||||||
| 1947 | # That's because we will never add another one, once it is on | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | # list of XRLs by LHS. | ||||||||||||||||||||||||||||||||||||||||||
| 1949 | Marpa::R3::Internal::X->new( | ||||||||||||||||||||||||||||||||||||||||||
| 1950 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1951 | desc => 'LHS not unique when required', | ||||||||||||||||||||||||||||||||||||||||||
| 1952 | xrl1 => $earlier_xrl, | ||||||||||||||||||||||||||||||||||||||||||
| 1953 | xrl2 => $new_xrl, | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | to_string => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 1955 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1956 | 3 | my @string = ('Precedenced LHS not unique'); | |||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||
| 1958 | 3 | my $pos1 = $self->{xrl1}->{start}; | |||||||||||||||||||||||||||||||||||||||||
| 1959 | 3 | my $len1 = $self->{xrl1}->{length}; | |||||||||||||||||||||||||||||||||||||||||
| 1960 | push @string, | ||||||||||||||||||||||||||||||||||||||||||
| 1961 | Marpa::R3::Internal::substr_as_2lines( | ||||||||||||||||||||||||||||||||||||||||||
| 1962 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 1963 | $self->{xrl1}->{precedence_count} > 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | ? 'First precedenced rule' | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | : 'First rule' | ||||||||||||||||||||||||||||||||||||||||||
| 1966 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | $parse->{p_dsl}, | ||||||||||||||||||||||||||||||||||||||||||
| 1968 | 3 | ▶ | $pos1, $len1, 74 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1969 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1970 | |||||||||||||||||||||||||||||||||||||||||||
| 1971 | 3 | my $pos2 = $self->{xrl2}->{start}; | |||||||||||||||||||||||||||||||||||||||||
| 1972 | 3 | my $len2 = $self->{xrl2}->{length}; | |||||||||||||||||||||||||||||||||||||||||
| 1973 | push @string, | ||||||||||||||||||||||||||||||||||||||||||
| 1974 | Marpa::R3::Internal::substr_as_2lines( | ||||||||||||||||||||||||||||||||||||||||||
| 1975 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 1976 | $self->{xrl2}->{precedence_count} > 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1977 | ? 'Second precedenced rule' | ||||||||||||||||||||||||||||||||||||||||||
| 1978 | : 'Second rule' | ||||||||||||||||||||||||||||||||||||||||||
| 1979 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | $parse->{p_dsl}, | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | 3 | ▶ | $pos2, $len2, 74 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1982 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1983 | 3 | push @string, q{}; | |||||||||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||||||||||
| 1985 | 3 | return join "\n", @string; | |||||||||||||||||||||||||||||||||||||||||
| 1986 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | 3 | )->throw(); | |||||||||||||||||||||||||||||||||||||||||
| 1989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1990 | |||||||||||||||||||||||||||||||||||||||||||
| 1991 | 1851 | my $xrl_by_id = $parse->{xrl}->{$xrlid} = $new_xrl; | |||||||||||||||||||||||||||||||||||||||||
| 1992 | 1851 | push @{ $parse->{xrls_by_lhs}->{$lhs} }, $new_xrl; | |||||||||||||||||||||||||||||||||||||||||
| 1993 | 1851 | return $xrlid; | |||||||||||||||||||||||||||||||||||||||||
| 1994 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||||||||||||||||
| 1996 | sub Marpa::R3::Internal::MetaAST::Parse::xpr_create { | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | 4232 | ▶ | my ( $parse, $args, $subgrammar ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
xpr_create: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||||||||||||||||
| 1999 | # The eXternal ALTernative is the argument hash, | ||||||||||||||||||||||||||||||||||||||||||
| 2000 | # slightly adjusted. | ||||||||||||||||||||||||||||||||||||||||||
| 2001 | 4232 | ▶ | $subgrammar //= 'g1'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$subgrammar //= "g1"
MC/DC0%0/1
$subgrammar //= "g1"
$subgrammar
Truth table50%1/2
A
A= $subgrammar
| |||||||||||||||||||||||||||||||||||||||||||
| 2002 | 4232 | ▶ | $args->{subgrammar} //= $subgrammar; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args->{"subgrammar"} //= $subgrammar
MC/DC0%0/2
$args->{"subgrammar"} //= $subgrammar
$args->{"subgrammar"}
$subgrammar
Truth table33%1/3
A //= B
A= $args->{"subgrammar"}B= $subgrammar
| |||||||||||||||||||||||||||||||||||||||||||
| 2003 | 4232 | ▶ | $args->{subkey} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"subkey"} //= 0
MC/DC100%1/1
$args->{"subkey"} //= 0
$args->{"subkey"}
Truth table100%2/2
A
A= $args->{"subkey"}
| |||||||||||||||||||||||||||||||||||||||||||
| 2004 | 4232 | my $rule_id = join q{,}, $subgrammar, $args->{lhs}, @{$args->{rhs}}; | |||||||||||||||||||||||||||||||||||||||||
| 2005 | 4232 | my $hash_by_xprid = $parse->{xpr}->{$subgrammar}; | |||||||||||||||||||||||||||||||||||||||||
| 2006 | 4232 | ▶ | if ( exists $hash_by_xprid->{$rule_id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2007 | 2 | my $other_xpr = $hash_by_xprid->{$rule_id}; | |||||||||||||||||||||||||||||||||||||||||
| 2008 | 2 | my $pos1 = $other_xpr->{start}; | |||||||||||||||||||||||||||||||||||||||||
| 2009 | 2 | my $len1 = $other_xpr->{length}; | |||||||||||||||||||||||||||||||||||||||||
| 2010 | 2 | my $pos2 = $args->{start}; | |||||||||||||||||||||||||||||||||||||||||
| 2011 | 2 | my $len2 = $args->{length}; | |||||||||||||||||||||||||||||||||||||||||
| 2012 | my @string = ( | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | "Duplicate rules:", | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | Marpa::R3::Internal::substr_as_2lines( | ||||||||||||||||||||||||||||||||||||||||||
| 2015 | 'First rule', $parse->{p_dsl}, $pos1, $len1, 74 | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 2017 | Marpa::R3::Internal::substr_as_2lines( | ||||||||||||||||||||||||||||||||||||||||||
| 2018 | 2 | 'Second rule', $parse->{p_dsl}, $pos2, $len2, 74 | |||||||||||||||||||||||||||||||||||||||||
| 2019 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 2020 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2021 | 2 | Marpa::R3::exception( join "\n", @string, q{} ); | |||||||||||||||||||||||||||||||||||||||||
| 2022 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2023 | 4230 | $hash_by_xprid->{$rule_id} = $args; | |||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||
| 2025 | # Now create the initial working rule | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | 4230 | my %wrl = ( | |||||||||||||||||||||||||||||||||||||||||
| 2027 | xprid => $rule_id, | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | subgrammar => $subgrammar, | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2030 | # Shallow copy | ||||||||||||||||||||||||||||||||||||||||||
| 2031 | 4230 | for my $field ( | |||||||||||||||||||||||||||||||||||||||||
| 2032 | qw(lhs action priority rank | ||||||||||||||||||||||||||||||||||||||||||
| 2033 | null_ranking min separator proper ) | ||||||||||||||||||||||||||||||||||||||||||
| 2034 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 2035 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2036 | 33840 | ▶ | $wrl{$field} = $args->{$field} if defined $args->{$field}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | # 'rhs' needs special treatment -- | ||||||||||||||||||||||||||||||||||||||||||
| 2039 | # a deeper code and creation of the xpr_dot field | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2041 | 4230 | my $rhs = $args->{rhs}; | |||||||||||||||||||||||||||||||||||||||||
| 2042 | 4230 | my $xpr_datum = $rhs; | |||||||||||||||||||||||||||||||||||||||||
| 2043 | 4230 | my @array = @{$rhs}; | |||||||||||||||||||||||||||||||||||||||||
| 2044 | 4230 | $wrl{rhs} = \@array; | |||||||||||||||||||||||||||||||||||||||||
| 2045 | 4230 | $wrl{xpr_dot} = [0 .. (scalar @array) ]; | |||||||||||||||||||||||||||||||||||||||||
| 2046 | 4230 | $wrl{xpr_top} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 2047 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||
| 2049 | # Return the initial working rule | ||||||||||||||||||||||||||||||||||||||||||
| 2050 | 4230 | return \%wrl; | |||||||||||||||||||||||||||||||||||||||||
| 2051 | |||||||||||||||||||||||||||||||||||||||||||
| 2052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | |||||||||||||||||||||||||||||||||||||||||||
| 2054 | # Return the prioritized symbol name, | ||||||||||||||||||||||||||||||||||||||||||
| 2055 | # after ensuring everything is set up properly | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | sub Marpa::R3::Internal::MetaAST::Parse::internal_lexeme { | ||||||||||||||||||||||||||||||||||||||||||
| 2057 | 293 | ▶ | my ( $parse, $dsl_form, @grammars ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
internal_lexeme: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||||||||||||||||
| 2059 | # character class symbol name always start with TWO left square brackets | ||||||||||||||||||||||||||||||||||||||||||
| 2060 | 293 | my $lexical_lhs_index = $parse->{lexical_lhs_index}++; | |||||||||||||||||||||||||||||||||||||||||
| 2061 | 293 | my $lexical_symbol = "[Lex-$lexical_lhs_index]"; | |||||||||||||||||||||||||||||||||||||||||
| 2062 | |||||||||||||||||||||||||||||||||||||||||||
| 2063 | # description => qq{Internal lexical symbol for "$dsl_form"} | ||||||||||||||||||||||||||||||||||||||||||
| 2064 | 293 | my $symbol_data = { | |||||||||||||||||||||||||||||||||||||||||
| 2065 | dsl_form => $dsl_form, | ||||||||||||||||||||||||||||||||||||||||||
| 2066 | name_source => 'internal' | ||||||||||||||||||||||||||||||||||||||||||
| 2067 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2068 | 293 | $parse->xsy_assign( $lexical_symbol, $symbol_data ); | |||||||||||||||||||||||||||||||||||||||||
| 2069 | 293 | $symbol_data = { xsy => $lexical_symbol }; | |||||||||||||||||||||||||||||||||||||||||
| 2070 | 293 | $parse->symbol_names_set( $lexical_symbol, $_, $symbol_data ) for qw(g1 l0); | |||||||||||||||||||||||||||||||||||||||||
| 2071 | 293 | return $lexical_symbol; | |||||||||||||||||||||||||||||||||||||||||
| 2072 | } ## end sub Marpa::R3::Internal::MetaAST::Parse::internal_lexeme | ||||||||||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||||||||||
| 2074 | sub name { | ||||||||||||||||||||||||||||||||||||||||||
| 2075 | 452 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 2076 | 452 | my $names = $self->{names}; | |||||||||||||||||||||||||||||||||||||||||
| 2077 | Marpa::R3::exception( 'list->name() on symbol list of length ', | ||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | scalar @{$names} ) | |||||||||||||||||||||||||||||||||||||||||
| 2079 | 452 | ▶ | if scalar @{$names} != 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2080 | 452 | return $self->{names}->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 2081 | } ## end sub name | ||||||||||||||||||||||||||||||||||||||||||
| 2082 | 9605 | ▶ | sub names { return shift->{names} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2083 | 9312 | ▶ | sub mask { return shift->{mask} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mask: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||
| 2085 | sub mask_set { | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | 77 | ▶ | my ( $self, $mask ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mask_set: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2087 | 77 | return $self->{mask} = [ map {$mask} @{ $self->{mask} } ]; | |||||||||||||||||||||||||||||||||||||||||
| 2088 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2089 | |||||||||||||||||||||||||||||||||||||||||||
| 2090 | 104 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2091 | |||||||||||||||||||||||||||||||||||||||||||
| 2092 | # vim: expandtab shiftwidth=4: | ||||||||||||||||||||||||||||||||||||||||||