Branch Coverage

blib/lib/Marpa/R2/Grammar.pm
Criterion Covered Total %
branch 260 416 62.5


line true false branch
110 0 675 unless ($ref_type)
115 0 675 if ($ref_type ne "HASH")
143 0 675 if (my(@bad_options) = grep({not exists $grammar_options->{$_};} keys %{$args;}))
156 542 133 if (defined(my $value = $args->{'_internal_'}))
160 276 399 if (defined(my $value = $args->{'trace_file_handle'}))
166 0 675 if (defined(my $value = $args->{'default_rank'}))
167 0 0 if $grammar_c->is_precomputed
176 544 131 if (defined(my $value = $args->{'symbols'}))
177 0 544 if $grammar_c->is_precomputed
180 0 544 if ref $value ne "HASH"
188 61 614 if (defined(my $value = $args->{'terminals'}))
189 0 61 if $grammar_c->is_precomputed
192 0 61 if ref $value ne "ARRAY"
199 639 36 if (defined(my $value = $args->{'start'}))
200 0 639 if $grammar_c->is_precomputed
209 3 672 if (defined(my $value = $args->{'source'}))
210 0 3 if $grammar_c->is_precomputed
213 0 3 if ref $value ne "SCALAR"
219 639 36 if (defined(my $value = $args->{'rules'}))
220 0 639 if $grammar_c->is_precomputed
227 0 638 if (ref $value eq "ARRAY" and scalar @{$value;} == 1 and not ref $value->[0])
233 1 638 unless (ref $value)
236 0 639 if (defined $deprecated_source and defined $stuifzand_source)
242 1 638 if (defined $deprecated_source)
247 0 638 if ref $value ne "ARRAY"
251 0 638 if $grammar->[10] ne "standard"
261 4 665 if (defined $stuifzand_source)
264 0 4 if $grammar->[10] ne "stuifzand"
278 9 660 if (exists $args->{'default_empty_action'})
284 17 652 if (defined(my $value = $args->{'actions'}))
288 110 559 if (defined(my $value = $args->{'bless_package'}))
292 4 665 if (defined(my $value = $args->{'action_object'}))
296 57 612 if (defined(my $value = $args->{'default_action'}))
300 9 660 if (defined(my $value = $args->{'infinite_action'}))
301 0 9 if ($value and $grammar_c->is_precomputed)
302 0 0 unless say {$trace_fh;} "\"infinite_action\" option is useless after grammar is precomputed"
310 0 9 unless exists $allowed_values->{$value}
315 8 661 if (defined(my $value = $args->{'warnings'}))
316 0 8 if ($value and $grammar_c->is_precomputed)
317 0 0 unless say {$trace_fh;} "\"warnings\" option is useless after grammar is precomputed"
324 0 669 if (defined(my $value = $args->{'inaccessible_ok'}))
325 0 0 if ($value and $grammar_c->is_precomputed)
326 0 0 unless say {$trace_fh;} "\"inaccessible_ok\" option is useless after grammar is precomputed"
333 0 0 if ($ref_value eq "")
337 0 0 if ($ref_value eq "ARRAY")
349 0 669 if (defined(my $value = $args->{'unproductive_ok'}))
350 0 0 if ($value and $grammar_c->is_precomputed)
351 0 0 unless say {$trace_fh;} "\"unproductive_ok\" option is useless after grammar is precomputed"
357 0 0 if ($ref_value eq "")
361 0 0 if ($ref_value eq "ARRAY")
380 0 0 if (length $final_character != 1)
384 0 0 if ($final_character eq "]")
385 0 0 if $boolean
390 0 0 unless (exists $DEFAULT_SYMBOLS_RESERVED{$final_character})
396 0 0 $boolean ? :
408 0 98 if ($problems)
416 0 98 if $grammar_c->is_precomputed
426 12 85 if ($precompute_result < 0)
428 0 12 unless (defined $precompute_error_code)
434 0 12 if $precompute_error_code == $Marpa::R2::Error::PRECOMPUTED
439 8 4 if $precompute_error_code == $Marpa::R2::Error::GRAMMAR_HAS_CYCLE
444 4 93 if ($precompute_error_code != $Marpa::R2::Error::NONE)
448 0 4 if ($precompute_error_code == $Marpa::R2::Error::NO_RULES)
452 1 3 if ($precompute_error_code == $Marpa::R2::Error::NULLING_TERMINAL)
458 1 0 if ($event_type eq "MARPA_EVENT_NULLING_TERMINAL")
468 1 2 if ($precompute_error_code == $Marpa::R2::Error::COUNTED_NULLABLE)
474 1 0 if ($event_type eq "MARPA_EVENT_COUNTED_NULLABLE")
488 0 2 if ($precompute_error_code == $Marpa::R2::Error::NO_START_SYMBOL)
491 1 1 if ($precompute_error_code == $Marpa::R2::Error::START_NOT_LHS)
496 1 0 if ($precompute_error_code == $Marpa::R2::Error::UNPRODUCTIVE_START)
511 1638 0 if defined $rules->[$rule_id]
532 0 8 if ($event_type ne "MARPA_EVENT_LOOP_RULES")
541 6 87 if ($loop_rule_count and $infinite_action ne "quiet")
545 0 16 unless print {$trace_fh;} "Cycle found involving rule: ", $grammar->brief_rule($rule_id), "\n"
550 0 6 if $infinite_action eq "fatal"
557 92 1 if ($grammar->[9] and ref(my $ok = $grammar->[19]) eq "HASH")
574 2 2 if $symbol =~ /\]/msx
575 0 2 if $ok->{$symbol}
576 0 2 unless say {$trace_fh;} "Inaccessible symbol: $symbol"
584 92 1 if ($grammar->[9] and ref(my $ok = $grammar->[20]) eq "HASH")
601 0 0 if $symbol =~ /\]/msx
602 0 0 if $ok->{$symbol}
603 0 0 unless say {$trace_fh;} "Unproductive symbol: $symbol"
609 0 93 if $grammar->[12]
627 0 534 if ($problems)
635 0 534 if $grammar_c->is_precomputed
636 0 534 if ($grammar_c->force_valued < 0)
648 2 532 if ($precompute_result < 0)
650 0 2 unless (defined $precompute_error_code)
656 0 2 if $precompute_error_code == $Marpa::R2::Error::PRECOMPUTED
661 0 2 if $precompute_error_code == $Marpa::R2::Error::GRAMMAR_HAS_CYCLE
666 2 532 if ($precompute_error_code != $Marpa::R2::Error::NONE)
670 0 2 if ($precompute_error_code == $Marpa::R2::Error::NO_RULES)
674 0 2 if ($precompute_error_code == $Marpa::R2::Error::NULLING_TERMINAL)
680 0 0 if ($event_type eq "MARPA_EVENT_NULLING_TERMINAL")
690 1 1 if ($precompute_error_code == $Marpa::R2::Error::COUNTED_NULLABLE)
696 1 0 if ($event_type eq "MARPA_EVENT_COUNTED_NULLABLE")
710 0 1 if ($precompute_error_code == $Marpa::R2::Error::NO_START_SYMBOL)
713 0 1 if ($precompute_error_code == $Marpa::R2::Error::START_NOT_LHS)
719 1 0 if $precompute_error_code == $Marpa::R2::Error::UNPRODUCTIVE_START
732 29967 0 if defined $rules->[$rule_id]
753 0 0 if ($event_type ne "MARPA_EVENT_LOOP_RULES")
762 0 532 if ($loop_rule_count and $infinite_action ne "quiet")
766 0 0 unless print {$trace_fh;} "Cycle found involving rule: ", $grammar->brief_rule($rule_id), "\n"
771 0 0 if $infinite_action eq "fatal"
792 0 7 if $symbol_name =~ /\]/msx
796 5 2 if $treatment eq "ok"
798 2 0 if $treatment eq "fatal"
799 0 0 unless say {$trace_fh;} $message
806 530 0 if ($grammar->[9] and ref(my $ok = $grammar->[20]) eq "HASH")
823 0 0 if $symbol =~ /\]/msx
824 0 0 if $ok->{$symbol}
825 0 0 unless say {$trace_fh;} "Unproductive symbol: $symbol"
831 0 530 if (defined $cc_hash)
853 0 1 if ($problems)
886 0 3902 unless defined $symbol
888 820 3082 if defined $text
891 91 2991 $text =~ /\s/msx ? :
904 0 75 unless $grammar_c->symbol_is_productive($symbol_id)
906 0 75 unless $grammar_c->symbol_is_accessible($symbol_id)
908 2 73 if $grammar_c->symbol_is_nulling($symbol_id)
909 33 42 if $grammar_c->symbol_is_terminal($symbol_id)
911 35 40 if scalar @tag_list
983 0 659 unless defined $rule
985 658 1 if defined $name
1005 1 2 $minimum <= 0 ? :
3 128 defined $minimum ? :
1016 16 71 if $grammar_c->rule_length($rule_id) == 0
1017 18 69 unless $grammar->rule_is_used($rule_id)
1018 0 87 unless $grammar_c->rule_is_productive($rule_id)
1019 0 87 unless $grammar_c->rule_is_accessible($rule_id)
1020 2 85 if $rule->[2]
1025 20 67 if (@comment)
1103 1 30 if (defined $minimum)
1104 0 1 $minimum <= 0 ? :
1107 0 31 if $dot_position < 0
1115 0 1 unless defined $name
1120 0 1 unless defined $symbol_id
1123 0 1 $grammar_c->symbol_is_terminal($symbol_id) ? :
1130 172690 0 defined $symbol_name ? :
1156 87254 31031 if (defined $symbol_id)
1164 0 55774 if ($property eq "semantics")
1169 0 55774 if ($property eq "bless")
1174 103 55671 if ($property eq "terminal")
1179 0 55671 if ($property eq "rank")
1181 0 0 if not &Scalar::Util::looks_like_number($value) or int $value != $value
1187 18780 36891 if ($property eq "description")
1192 18051 18840 if ($property eq "dsl_form")
1197 60 18780 if ($property eq "legacy_name")
1202 18780 0 if ($property eq "display_form")
1207 0 0 if ($property eq "if_inaccessible")
1225 0 23908 if (my $type = ref $name)
1229 5128 18780 unless ($grammar->[11])
1231 0 5128 if ($DEFAULT_SYMBOLS_RESERVED{$final_symbol})
1252 31382 219 if ($ref_rule eq "HASH")
1256 219 0 if ($ref_rule eq "ARRAY")
1259 0 219 if ($arg_count > 4 or $arg_count < 1)
1263 0 0 defined $_ ? :
1297 0 31661 unless defined $grammar and defined $options
1319 10222 130726 if ($option eq "name")
1320 12463 118263 if ($option eq "tag")
1321 31657 86606 if ($option eq "rhs")
1322 31661 54945 if ($option eq "lhs")
1323 9840 45105 if ($option eq "action")
1324 8275 36830 if ($option eq "bless")
1325 64 36766 if ($option eq "rank")
1326 4 36762 if ($option eq "null_ranking")
1330 1735 35027 if ($option eq "min")
1331 328 34699 if ($option eq "separator")
1335 232 34467 if ($option eq "proper")
1339 15 34452 if ($option eq "keep")
1340 19423 15029 if ($option eq "mask")
1341 15029 0 if ($option eq "description")
1345 0 31661 if (defined $min and not &Scalar::Util::looks_like_number($min))
1355 30079 1582 $grammar_is_internal ? :
1364 0 31661 if (not $rhs_ref_type or $rhs_ref_type ne "ARRAY")
1365 0 0 $rhs_ref_type ? :
1373 0 31661 unless (defined $lhs_name)
1377 0 64 if (defined $rank and !&Scalar::Util::looks_like_number($rank) || int $rank != $rank)
1387 0 31661 if ($null_ranking ne "high" and $null_ranking ne "low")
1392 0 31661 if (scalar @rule_problems)
1410 63985 3396 $grammar_is_internal ? :
1418 0 31661 if (defined $separator_name and $is_ordinary_rule)
1419 0 0 if (defined $separator_name)
1431 29926 1735 if ($is_ordinary_rule) { }
1441 0 1735 if scalar @{$rhs_names;} != 1
1444 328 1407 if (defined $separator_name)
1445 313 15 $grammar_is_internal ? :
1470 6 31655 if (not defined $base_rule_id or $base_rule_id < 0)
1474 3 3 $error_code == $Marpa::R2::Error::DUPLICATE_RULE ? :
1483 29920 1735 if ($is_ordinary_rule)
1486 10500 19420 unless (defined $mask and $grammar_is_internal)
1496 2 31653 $null_ranking eq 'high' ? :
1500 9781 21874 if (defined $rule_name)
1503 12463 19192 if (defined $slif_tag)
1507 0 12463 if ($rule_id_by_tag->{$slif_tag})
1513 8275 23380 if (defined $blessing)
1516 15028 16627 if (defined $description)
1527 1 5 if $lhs_name =~ / /
1528 1 5 / / ? :
1542 0 632 if (defined $named_arg_start_name and defined $start_id)
1548 629 3 if (defined $named_arg_start_name)
1550 0 629 unless defined $start_id
1555 2 1 if (defined $default_start_id)
1564 0 631 unless (defined $grammar_c->start_symbol_set($start_id))
1588 10 27 if $grammar_c->_marpa_g_nsy_is_nulling($isy_id)
1591 10 27 if scalar @tag_list
1614 58 0 if (my $rh_length = $grammar_c->_marpa_g_irl_length($irl_id))