Branch Coverage

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


line true false branch
110 0 661 unless ($ref_type)
115 0 661 if ($ref_type ne "HASH")
143 0 661 if (my(@bad_options) = grep({not exists $grammar_options->{$_};} keys %{$args;}))
156 528 133 if (defined(my $value = $args->{'_internal_'}))
160 269 392 if (defined(my $value = $args->{'trace_file_handle'}))
166 0 661 if (defined(my $value = $args->{'default_rank'}))
167 0 0 if $grammar_c->is_precomputed
176 530 131 if (defined(my $value = $args->{'symbols'}))
177 0 530 if $grammar_c->is_precomputed
180 0 530 if ref $value ne "HASH"
188 61 600 if (defined(my $value = $args->{'terminals'}))
189 0 61 if $grammar_c->is_precomputed
192 0 61 if ref $value ne "ARRAY"
199 625 36 if (defined(my $value = $args->{'start'}))
200 0 625 if $grammar_c->is_precomputed
209 3 658 if (defined(my $value = $args->{'source'}))
210 0 3 if $grammar_c->is_precomputed
213 0 3 if ref $value ne "SCALAR"
219 625 36 if (defined(my $value = $args->{'rules'}))
220 0 625 if $grammar_c->is_precomputed
227 0 624 if (ref $value eq "ARRAY" and scalar @{$value;} == 1 and not ref $value->[0])
233 1 624 unless (ref $value)
236 0 625 if (defined $deprecated_source and defined $stuifzand_source)
242 1 624 if (defined $deprecated_source)
247 0 624 if ref $value ne "ARRAY"
251 0 624 if $grammar->[10] ne "standard"
261 4 651 if (defined $stuifzand_source)
264 0 4 if $grammar->[10] ne "stuifzand"
278 9 646 if (exists $args->{'default_empty_action'})
284 17 638 if (defined(my $value = $args->{'actions'}))
288 107 548 if (defined(my $value = $args->{'bless_package'}))
292 4 651 if (defined(my $value = $args->{'action_object'}))
296 57 598 if (defined(my $value = $args->{'default_action'}))
300 9 646 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 647 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 655 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 655 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 520 if ($problems)
635 0 520 if $grammar_c->is_precomputed
636 0 520 if ($grammar_c->force_valued < 0)
648 2 518 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 518 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 28830 0 if defined $rules->[$rule_id]
753 0 0 if ($event_type ne "MARPA_EVENT_LOOP_RULES")
762 0 518 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 516 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 516 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 48914 0 defined $symbol_name ? :
1156 84044 29937 if (defined $symbol_id)
1164 0 53712 if ($property eq "semantics")
1169 0 53712 if ($property eq "bless")
1174 103 53609 if ($property eq "terminal")
1179 0 53609 if ($property eq "rank")
1181 0 0 if not &Scalar::Util::looks_like_number($value) or int $value != $value
1187 18087 35522 if ($property eq "description")
1192 17375 18147 if ($property eq "dsl_form")
1197 60 18087 if ($property eq "legacy_name")
1202 18087 0 if ($property eq "display_form")
1207 0 0 if ($property eq "if_inaccessible")
1225 0 23215 if (my $type = ref $name)
1229 5128 18087 unless ($grammar->[11])
1231 0 5128 if ($DEFAULT_SYMBOLS_RESERVED{$final_symbol})
1252 30245 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 30524 unless defined $grammar and defined $options
1319 9857 125882 if ($option eq "name")
1320 12004 113878 if ($option eq "tag")
1321 30520 83358 if ($option eq "rhs")
1322 30524 52834 if ($option eq "lhs")
1323 9468 43366 if ($option eq "action")
1324 7948 35418 if ($option eq "bless")
1325 52 35366 if ($option eq "rank")
1326 4 35362 if ($option eq "null_ranking")
1330 1675 33687 if ($option eq "min")
1331 316 33371 if ($option eq "separator")
1335 223 33148 if ($option eq "proper")
1339 15 33133 if ($option eq "keep")
1340 18668 14465 if ($option eq "mask")
1341 14465 0 if ($option eq "description")
1345 0 30524 if (defined $min and not &Scalar::Util::looks_like_number($min))
1355 28942 1582 $grammar_is_internal ? :
1364 0 30524 if (not $rhs_ref_type or $rhs_ref_type ne "ARRAY")
1365 0 0 $rhs_ref_type ? :
1373 0 30524 unless (defined $lhs_name)
1377 0 52 if (defined $rank and !&Scalar::Util::looks_like_number($rank) || int $rank != $rank)
1387 0 30524 if ($null_ranking ne "high" and $null_ranking ne "low")
1392 0 30524 if (scalar @rule_problems)
1410 61523 3396 $grammar_is_internal ? :
1418 0 30524 if (defined $separator_name and $is_ordinary_rule)
1419 0 0 if (defined $separator_name)
1431 28849 1675 if ($is_ordinary_rule) { }
1441 0 1675 if scalar @{$rhs_names;} != 1
1444 316 1359 if (defined $separator_name)
1445 301 15 $grammar_is_internal ? :
1470 6 30518 if (not defined $base_rule_id or $base_rule_id < 0)
1474 3 3 $error_code == $Marpa::R2::Error::DUPLICATE_RULE ? :
1483 28843 1675 if ($is_ordinary_rule)
1486 10178 18665 unless (defined $mask and $grammar_is_internal)
1496 2 30516 $null_ranking eq 'high' ? :
1500 9416 21102 if (defined $rule_name)
1503 12004 18514 if (defined $slif_tag)
1507 0 12004 if ($rule_id_by_tag->{$slif_tag})
1513 7948 22570 if (defined $blessing)
1516 14464 16054 if (defined $description)
1527 1 5 if $lhs_name =~ / /
1528 1 5 / / ? :
1542 0 618 if (defined $named_arg_start_name and defined $start_id)
1548 615 3 if (defined $named_arg_start_name)
1550 0 615 unless defined $start_id
1555 2 1 if (defined $default_start_id)
1564 0 617 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))