Branch Coverage

blib/lib/Marpa/PP/Grammar.pm
Criterion Covered Total %
branch 333 452 73.6


line true false branch
259 0 0 if $phase == 0
261 0 0 if $phase == 1
263 0 0 if $phase == 2
320 0 6 if ($false_eval)
324 4 2 if ($fatal_error)
327 2 4 if ($warnings_count)
332 0 6 unless (scalar @problems)
348 4 2 if ($fatal_error)
425 0 115 if (not $ref_type or $ref_type ne 'HASH')
432 0 115 if (my(@bad_options) = grep({not $_ ~~ ['action_object', 'actions', 'cycle_ranking_action', 'infinite_action', 'default_action', 'default_null_value', 'inaccessible_ok', 'lhs_terminals', 'rules', 'start', 'strip', 'symbols', 'terminals', 'trace_file_handle', 'trace_rules', 'unproductive_ok', 'warnings'];} keys %{$args;}))
441 7 108 if (defined(my $value = $$args{'trace_file_handle'}))
446 0 115 if (defined(my $value = $$args{'trace_rules'}))
448 0 0 if ($value)
451 0 0 unless say {$trace_fh;} 'Setting trace_rules'
453 0 0 if ($rule_count)
454 0 0 unless say {$trace_fh;} "Warning: Setting trace_rules after $rule_count rules have been defined"
467 12 103 if (defined(my $value = $$args{'symbols'}))
468 0 12 if $phase >= 2
471 0 12 if ref $value ne 'HASH'
480 7 108 if (defined(my $value = $$args{'lhs_terminals'}))
481 0 7 if $phase >= 2
489 58 57 if (defined(my $value = $$args{'terminals'}))
490 0 58 if $phase >= 2
493 0 58 if ref $value ne 'ARRAY'
502 81 34 if (defined(my $value = $$args{'start'}))
503 0 81 if $phase >= 2
509 82 33 if (defined(my $value = $$args{'rules'}))
510 0 82 if $phase >= 2
513 0 82 if ref $value ne 'ARRAY'
520 30 84 if (defined(my $value = $$args{'default_null_value'}))
525 15 99 if (defined(my $value = $$args{'actions'}))
529 1 113 if (defined(my $value = $$args{'action_object'}))
533 0 114 if (defined(my $value = $$args{'cycle_ranking_action'}))
538 51 63 if (defined(my $value = $$args{'default_action'}))
542 44 70 if (defined(my $value = $$args{'strip'}))
546 8 106 if (defined(my $value = $$args{'infinite_action'}))
547 0 8 if ($value and $phase >= 2)
549 0 0 unless say {$trace_fh;} '"infinite_action" option is useless after grammar is precomputed'
554 0 8 unless $value ~~ ['warn', 'quiet', 'fatal']
560 9 105 if (defined(my $value = $$args{'warnings'}))
561 0 9 if ($value and $phase >= 2)
563 0 0 unless say {$trace_fh;} '"warnings" option is useless after grammar is precomputed'
570 0 114 if (defined(my $value = $$args{'inaccessible_ok'}))
571 0 0 if ($value and $phase >= 2)
573 0 0 unless say {$trace_fh;} '"inaccessible_ok" option is useless after grammar is precomputed'
598 0 114 if (defined(my $value = $$args{'unproductive_ok'}))
599 0 0 if ($value and $phase >= 2)
601 0 0 unless say {$trace_fh;} '"unproductive_ok" option is useless after grammar is precomputed'
665 0 81 if ($problems)
677 0 81 if ($phase == 2)
681 0 81 if ($phase != 1)
692 1 80 if ($distinguished and not $lhs_terminals_ok)
696 60 20 if $distinguished
697 6 14 unless ($lhs_terminals_ok)
701 0 14 if (has_empty_rule($grammar))
710 0 79 unless nullable($grammar)
712 0 76 unless check_start($grammar)
726 75 1 if ($$grammar[11] and ref(my $ok = $$grammar[26]) eq 'HASH')
743 0 2 if $symbol =~ /\]/msx
744 0 2 if $$ok{$symbol}
745 0 2 unless say {$trace_fh;} "Inaccessible symbol: $symbol"
750 75 1 if ($$grammar[11] and ref(my $ok = $$grammar[27]) eq 'HASH')
767 0 0 if $symbol =~ /\]/msx
768 0 0 if $$ok{$symbol}
769 0 0 unless say {$trace_fh;} "Unproductive symbol: $symbol"
774 75 1 if ($$grammar[11])
781 990 1 unless $$symbol[14]
784 0 1 if $$symbol[5]
786 0 1 unless say {$trace_fh;} qq[Zero length sequence for symbol without null value: "$symbol_name"]
795 32 44 if ($$grammar[9])
824 1 1 if ($problems)
842 10 85 if ($stripped) { }
855 32 63 if ($nullable)
869 118 262 unless exists $$symbol[$offset]
871 170 92 if ($reverse)
872 57 205 if ($value)
895 1 2 if scalar grep({$#{$_;} < 14;} @{$symbols;})
902 1 2 unless exists $$grammar[25]
915 1 2 if scalar grep({$#{$_;} < 14;} @{$symbols;})
925 1 2 if scalar grep({$#{$_;} < 14;} @{$symbols;})
958 197 22 if (@{$rhs;})
977 0 0 unless (defined $original_rule)
978 0 0 if defined $dot_position
991 0 0 unless (defined $chaf_start)
992 0 0 if defined $dot_position
1015 0 0 if ($chaf_end < $#rhs_names)
1021 0 0 $dot_position >= scalar @{$chaf_rhs;} ? :
1045 22 159 unless (@{$rhs;})
1047 15 166 if ($stripped)
1063 30 1056 unless exists $$rule[$offset]
1065 513 543 if ($reverse)
1066 923 133 unless $value
1070 79 102 if ($$rule[6] or $$rule[7])
1079 124 57 if (@comment)
1116 0 415 if ($dot_position < 0)
1125 415 808 if ($position == $dot_position)
1129 415 808 unless defined $name
1140 3 376 if (not defined $item) { }
1165 18 63 if ($at_nulling)
1168 18 63 if (@properties)
1180 32 51 $symbol_name eq '' ? :
1190 1 3 unless exists $$grammar[23]
1216 57 88 if $$state[7]
1218 27 118 if $$state[6]
1220 84 61 if scalar @tags
1223 145 0 if (exists $$state[8])
1231 0 145 if ($stripped)
1233 0 145 unless $verbose
1235 81 64 if (exists $$state[4])
1241 69 165 unless (ref $to_state)
1271 0 1 unless defined $name
1274 0 1 unless defined $symbol_id
1277 1 0 unless $$symbol[7]
1289 1769 876 if (defined(my $symbol_id = $$symbol_hash{$name}))
1293 876 1769 unless (defined $symbol)
1315 0 2504 if (my $type = ref $name)
1319 0 2504 if $name =~ /\]\z/msx
1328 0 141 unless ($property ~~ ['terminal', 'ranking_action', 'null_value'])
1331 124 17 if ($property eq 'terminal')
1334 17 124 if ($property eq 'null_value')
1383 0 1409 if ($rhs_length & -134217728)
1407 1271 138 @{$rhs;} ? :
1409 0 1409 if ($action and $nulling)
1443 226 3088 if $new_rule_id ~~ \@{$rhs_rule_ids;}
1447 0 1409 if ($trace_rules)
1451 0 0 unless print {$trace_fh;} 'Added rule #', $#{$rules;}, ': ', $$lhs[1], ' -> ', join(' ', map({$$_[1];} @{$rhs;})), "\n"
1468 0 201 if ($arg_count > 4 or $arg_count < 1)
1469 0 0 defined $_ ? :
1509 0 800 unless defined $grammar and defined $options
1543 0 800 if (not $rhs_ref_type or $rhs_ref_type ne 'ARRAY')
1544 0 0 $rhs_ref_type ? :
1549 0 800 unless (defined $lhs_name)
1552 800 0 unless scalar @problems
1574 1 799 if exists $$rule_signature_hash{$rule_signature}
1579 772 27 if (scalar @{$rhs_names;} == 0 or not defined $min)
1581 0 772 if (defined $separator_name)
1619 11 16 if ($min == 0)
1630 1 10 if ($action)
1634 0 11 if ($ranking_action)
1642 0 27 if scalar @{$rhs_names;} != 1
1649 15 12 if (defined $separator_name)
1676 9 18 if (defined $separator and not $proper_separation)
1691 15 12 defined $separator ? :
1729 1 78 unless defined $start_name
1731 0 78 if (my $ref_type = ref $start_name)
1741 0 78 unless defined $start_id
1745 0 78 unless $start
1752 1 77 unless ($$start[11])
1757 1 76 unless (scalar @{$lh_rule_ids;})
1789 0 873 if defined $$rule[15]
1805 1021 661 if defined $$symbol[10]
1854 456 461 unless defined &List::Util::first(sub { not defined &List::Util::first(sub { not $$_[11]; } , @{$$rules[$_][2];}); } , @{$$symbol[8];})
1878 3 881 if defined &List::Util::first(sub { not $$_[11]; } , @{$$rule[2];})
1890 64 0 if scalar @{$$rule[2];}
1902 61 463 if $$symbol[7]
1920 0 1 unless $$symbol[7]
1923 0 1 unless scalar @{$$symbol[8];}
1939 168 185 if scalar @{$$symbol[8];}
1961 0 155 if $$symbol[3]
1964 8 147 if $$symbol[7]
1973 112 16 unless $$rh_symbol[3]
2011 27 287 if $$symbol[6]
2027 943 421 unless $$rh_symbol[6]
2037 138 149 unless $nullable
2057 1 754 if ($nullable and $counted)
2065 1 79 if ($counted_nullable_count)
2088 267 1120 unless $$rule[3]
2096 1631 312 unless ($$rhs_symbol[6])
2100 541 1090 if defined $non_nulling_symbol
2112 30 549 unless defined $non_nulling_symbol
2137 449156 18472 unless $unit_derivation[$derived_id][$id]
2141 15682 2790 if $unit_derivation[$start_id][$id]
2158 531 18 if $start_symbol_id != $derived_symbol_id and not $unit_derivation[$derived_symbol_id][$start_symbol_id]
2207 12 6 if ($warn_on_infinite and defined $warning_rule)
2208 0 12 unless print {$trace_fh;} 'Cycle found involving rule: ', Marpa::PP::brief_rule($warning_rule), "\n"
2215 7 69 if (scalar @{$infinite_rules;})
2216 0 7 if $infinite_is_fatal
2236 29 47 if (defined(my $start_alias = $$start[2]))
2271 267 1120 unless $useful
2293 76 3888 unless (defined $item)
2301 0 105 unless $$start_rule[3]
2316 1120 2768 unless (defined $next_symbol)
2321 430 2338 if ($$next_symbol[3])
2342 769 3253 unless $$predicted_rule[3]
2387 6744 549379 unless defined $work_list_entry
2392 381335 168044 if defined $NFA_state_seen[$NFA_id]
2400 2311 165733 if ($$NFA_state[4])
2410 75770 89963 if ($empty_transitions)
2425 336088 12594332 if defined $NFA_state_seen[$_]
2430 4167 9321 unless scalar @NFA_ids
2436 2079 7242 unless ($AHFA_state)
2446 12165 1245 unless $$NFA_state[5]
2458 105 1140 if ($lhs_is_start)
2499 0 76 if ($tracing)
2512 0 76 unless (defined $initial_NFA_states)
2542 6237 12165 if $symbol eq ''
2617 781 1298 if scalar @{$NFA_states;} != 1
2620 474 824 unless scalar @{$left_hand_sides;}
2632 1 823 unless defined $non_nulling
2638 244 579 unless scalar @{$$non_nulling[8];}
2653 1245 12165 unless defined $symbol
2752 0 742 if $null_alias
2755 0 742 unless $productive
2756 5 737 unless $accessible
2759 31 706 if $nulling
2760 595 111 unless $nullable
2776 25 853 unless $$rule[3]
2781 0 853 unless $productive
2783 5 848 unless $accessible
2796 114 734 unless defined &List::Util::first(sub { not $$_[3]; } , @{$rhs;})
2836 611 123 unless (scalar @proper_nullable_ixes)
2842 0 123 if ($$rule[6])
2847 0 123 if ($$rule[7])
2869 73 88 if (defined $proper_nullable_1_ix)
2897 9 29 if ($proper_nullable_1_ix < $last_nonnullable_ix)
2929 22 139 if $nullable and not defined $proper_nullable_1_ix
2950 29 110 if ($next_subproduction_lhs and $last_nullable_subproduction_ix > $last_nonnullable_ix - $subproduction_start_ix) { }
2960 2 97 $$_[3] ? :
2979 66 73 unless defined $proper_nullable_1_ix
2986 31 42 unless ($nullable)
3019 94 310 if ($next_subproduction_lhs and $$factor_rhs[-1] == $next_subproduction_lhs)
3060 123 38 unless $next_subproduction_lhs
3075 75 1 unless ($start_is_nulling)
3104 1 75 $start_is_nulling ? :
3108 30 46 if ($nulling_old_start)
3110 29 1 if ($new_start_symbol) { }