Branch Coverage

blib/lib/MarpaX/G4/MarpaGen.pm
Criterion Covered Total %
branch 301 536 56.1


line true false branch
42 0 0 defined $verbosity ? :
58 0 189 unless defined $option
60 0 189 unless exists $self->{'generationoptions'}{$option}
93 0 32 if exists $rules->{$rulename}
106 0 0 unless exists $rules->{$rulename}
122 1 0 unless exists $subrules->{$rulename}
137 0 0 unless exists $self->{'subrules'}{$rulename}
148 0 0 if ($_ eq $subrulename) { }
159 0 0 if ($status)
162 0 0 unless exists $rules->{$subrulename}
173 0 5 unless exists $rules->{$rulename}
184 0 96 unless (exists $rules->{$rulename})
186 0 0 unless defined $parent
198 0 32 unless exists $rules->{$rulename}
208 0 5 unless exists $subrules->{$rulename}
212 5 4 if $sr eq $subrulename
226 14 0 if exists $context->{'level'}
227 0 14 unless defined $level
245 0 360 if ref $token ne "HASH"
248 51 309 if exists $token->{$tag}
262 0 1 if ref $mxtoken ne "HASH"
266 0 1 unless (exists $mxtoken->{'class4list'})
279 0 1 if exists $mxtoken->{'grammarstate'}
280 0 1 if exists $mxtoken->{'isFragmentOrChild'}
285 0 0 if (exists $mxtoken->{'rhs'} and exists $mxtoken->{'rhs'}{'token'})
288 0 0 if (ref $token eq "")
301 0 0 $case =~ /^U/i ? :
331 0 0 if ($lcp =~ /[A-Z]/i) { }
336 0 0 if length $rest > 0
337 0 0 if length $uctoken > 1
344 0 0 if length $uctoken > 1
354 17 4 if $string =~ /^.$/
355 1 3 if $string =~ /^\\[^u]$/i
356 0 3 if $string =~ /^\\u[0-9A-F]{4,4}$/i
357 0 3 if $string =~ /^\\u\{[0-9A-F]{5,5}\}$/i
365 62 9 unless exists $rule->{'class4list'}
367 0 0 if $rulename =~ /^[a-z]$/i and $s =~ /([a-z])([a-z])/i and uc "$1" eq "$2" || lc "$1" eq "$2"
378 30 30 unless exists $rule->{'class4list'}
381 1 6 if $string =~ /([a-z])([a-z])/i and uc "$1" eq "$2" || lc "$1" eq "$2"
382 21 8 unless $string =~ /[a-z]/i
383 5 3 if $string =~ /[0-9]/i
392 3 18 unless isSingleChar($literal)
404 0 0 if $begr->{'type'} ne "literal" or $endr->{'type'} ne "literal"
409 0 0 unless isSingleChar($begr) and isSingleChar($endr)
420 0 120 unless exists $tracker->{'status'}
422 90 30 if (not exists $mxelement->{'class4list'} or $tracker->{'status'} == -1) { }
436 0 60 unless exists $tracker->{'status'}
438 45 15 if (not exists $mxelement->{'keywordfragment'} or $tracker->{'status'} == -1) { }
452 8 10 unless exists $context->{'subruleindex'}{$rulename}{'index'}
457 4 14 if (defined $cardinality and $cardinality eq "?")
478 0 18 if (defined $negation)
488 14 4 if exists $context->{'subruleindex'}{$rulename}{'grammarstate'}
489 7 11 if exists $context->{'subruleindex'}{$rulename}{'isFragmentOrChild'}
494 4 14 if defined $cardinality and $cardinality eq "?"
504 0 18 if exists $mxelement->{'class4list'} and not defined $cardinality
505 14 4 if exists $context->{'subruleindex'}{$rulename}{'grammarstate'}
506 7 11 if exists $context->{'subruleindex'}{$rulename}{'isFragmentOrChild'}
529 0 40 if (ref $token eq "HASH" and exists $token->{'comment'} and not $self->testoption("stripallcomments"))
531 0 0 if ref $token->{'comment'} ne ""
540 0 40 if (ref $token eq "")
547 9 31 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "tokengroup")
554 0 31 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "rulegroup")
563 21 10 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "literal")
567 18 3 if defined $class4list
570 9 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "class")
574 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "regex")
578 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "range")
582 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "value")
586 1 0 if (ref $token eq "HASH" and exists $token->{'token'})
590 0 0 if (ref $token eq "HASH" and exists $token->{'action'})
594 0 0 if (ref $token eq "HASH" and exists $token->{'comment'})
607 1 39 if (defined $negation)
619 0 40 if (defined $cardinality)
627 0 40 if defined $alternative
628 0 40 if scalar @$comments > 0 and not $self->testoption("stripallcomments")
637 0 0 if ref $nonterminal ne "HASH"
643 0 0 if (exists $nonterminal->{'rhs'})
669 0 6 if ref $mxtoken ne "HASH"
670 0 6 if $cardinality eq "?"
672 0 6 if $cardinality =~ /[+*]\?/ and $self->testoption("shiftlazytogreedy")
673 0 6 if $cardinality =~ /[+*]\?/
675 1 5 unless defined $options
680 5 1 if (exists $mxtoken->{'rhs'})
683 0 5 if ref $rhs ne "HASH"
684 0 5 if not exists $rhs->{'token'} or ref $rhs->{'token'} ne ""
686 0 5 unless defined $self->checkMarpaRuleExists($rhs->{'token'})
690 5 0 if ($abortatfirstlevel) { }
695 0 5 unless $self->isSubrule($rulename, $subrulename)
698 5 0 if ($cardinality ne "?")
711 0 0 unless $self->isSubrule($rulename, $subrulename)
715 0 0 if ($rc)
717 0 0 if exists $rule->{'cardinality'}
726 0 1 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "group")
727 0 0 unless exists $mxtoken->{'list'}
731 0 0 if ref $al ne "HASH" or not exists $al->{'list'}
734 0 0 if exists $le->{'type'} and not $le->{'type'} =~ /literal|class/
741 0 1 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "literal")
746 1 0 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "class")
747 0 1 if exists $mxtoken->{'cardinality'}
752 0 0 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "negatedclass")
753 0 0 if exists $mxtoken->{'cardinality'}
779 17 6 if scalar @$alternativelists < 2
787 0 17 if (not exists $branch->{'list'}) { }
794 5 12 if (scalar @$branchlist > 1) { }
803 4 8 if (exists $rhs->{'type'} and $rhs->{'type'} eq "literal")
807 2 2 if (defined $literal) { }
812 0 2 if $matchfound
820 12 0 unless $matchfound
825 6 0 unless $filtered
861 37 23 if ref $e eq "HASH" and exists $e->{'rhs'} and not exists $e->{'token'}
862 4 0 if ref $e eq "HASH" and exists $e->{'type'} and exists $e->{'definition'}
867 0 60 if (exists $e->{'comment'} or exists $e->{'action'})
869 0 0 if (exists $e->{'comment'} and not $self->testoption("stripallcomments"))
875 0 0 if (exists $e->{'action'} and not $self->testoption("stripactions"))
877 0 0 $self->testoption('embedactions') ? :
887 0 60 if (ref $e eq "HASH" and not exists $e->{'token'})
889 0 0 if exists $e->{'type'} and $e->{'type'} eq "regex"
895 11 49 if (defined $alternative) { }
897 11 0 if (scalar @$currentlist > 0)
908 0 11 if ($self->testoption('buildkeywords') and $keywordfragment->{'status'} == 0 and $keyword =~ /^[a-z]/i) { }
918 2 9 if $class4list->{'status'} != -1
919 0 11 if exists $metalist->{'state'}
938 12 37 if ($alternativelength > 1)
947 21 39 if (ref $e->{'token'} eq '') { }
957 0 39 if ref $e ne "HASH" or not exists $e->{'token'}
960 0 39 if exists $mxelement->{'type'} and $mxelement->{'type'} eq "ignore"
963 23 16 if defined $keywordfragment
969 0 60 if (exists $mxelement->{'comments'})
974 0 0 if scalar keys %$mxelement == 0
981 31 29 unless defined $il
986 0 60 if exists $mxelement->{'negation'}
988 0 60 if (defined $negation)
997 10 50 if (defined $cardinality)
1004 1 9 if (scalar @$rhslist <= 1 and $self->retagSimpleRule($rulename, $mxelement, $cardinality, $context)) { }
1010 0 1 if (defined $alternative and scalar @$rhslist > 1)
1029 0 9 if ($cardinality ne "?" and not $self->retagSimpleRule($rulename, $mxelement, $cardinality, $context, {"abortatfirstlevel", "true"}))
1031 0 0 if scalar @$rhslist > 1
1032 0 0 if $cardinality ne "?"
1052 26 34 if $alternativelength > 1
1059 0 23 if ($self->testoption("buildkeywords") and $keywordfragment->{'status'} == 0 and $keywordfragment->{'value'} =~ /^[a-z]/i)
1070 23 0 if (scalar @$currentlist > 0)
1073 3 20 if $class4list->{'status'} != -1
1074 1 22 if $groupisLexeme->{'status'} == 0
1075 0 23 if exists $metalist->{'state'}
1082 23 0 if $self->testoption("matchcaseinsensitive")
1087 1 22 if $class4group->{'status'} != -1
1088 1 22 if $groupisLexeme->{'status'} == 0
1101 0 9 if ref $tokengroup ne "HASH" or not exists $tokengroup->{'definition'}
1124 9 14 if (defined $rulestatus)
1129 3 6 if ($rulestatus eq "inprogress")
1130 6 0 if ($rulestatus eq "done")
1132 0 0 if ($rulestatus eq "synthetic" and not $self->checkMarpaRuleExists($rulename))
1144 3 6 if exists $mxrule->{'class4list'}
1153 14 0 if (defined $rightside)
1155 0 14 if ref $rightside ne "ARRAY"
1157 9 5 if exists $rule->{'grammarstate'} and $rule->{'grammarstate'} eq "lexer"
1158 6 8 if exists $rule->{'type'} and $rule->{'type'} eq "fragment"
1172 9 5 if exists $rule->{'grammarstate'} and $rule->{'grammarstate'} eq "lexer"
1173 6 8 if exists $rule->{'type'} and $rule->{'type'} eq "fragment"
1174 1 13 if (exists $rule->{'redirect'})
1202 4 17 if defined $keywordfragment
1238 0 14 unless (exists $rule->{'generationstatus'})
1240 0 0 unless ($status)
1248 0 0 exists $rule->{'grammarstate'} && $rule->{'grammarstate'} =~ /lexer/i ? :
0 0 exists $rule->{'isFragmentOrChild'} ? :
1253 0 1 if $status
1272 1 0 if (not exists $rule->{'generationstatus'} and exists $rule->{'redirect'})
1298 0 1 unless exists $startrule->{'rightsides'}
1316 1 0 if ($outputfile ne '-') { }
1319 0 1 unless open $outf, ">$outputfile"
1333 0 1 if $self->{'is_stdout'}
1340 0 50 unless defined $s
1345 1 49 if $pad < 0
1354 0 0 if ref $comments ne "ARRAY"
1377 0 39 if ref $token ne ""
1381 0 39 if ($self->testoption("matchcaseinsensitive") and $self->isKeywordLetter($token, $rule))
1388 0 39 if exists $rule->{'redirected'}
1397 27 1 unless exists $rule->{'class4list'}
1433 2 0 if (defined $fourmatch)
1434 0 2 unless $fourmatch =~ /00([0-9A-Z][0-9A-Z])/i
1439 0 0 if (defined $bracedmatch)
1440 0 0 unless $bracedmatch =~ /0*([0-9A-Z]{2,2})/i
1474 0 12 if ($classstring =~ /(\\[ux][0-9a-f]+)-(\\[ux][0-9a-f]+)(.*)$/i)
1481 0 12 if ($classstring =~ /(\\[ux][0-9a-f]{2,4})(.*)$/i)
1487 3 9 if ($classstring =~ /([^-])-([^-])(.*)$/)
1491 2 0 unless (exists $$classhash{lc $key} or exists $$classhash{uc $key})
1495 1 1 if $beg =~ /[a-z]/i or $end =~ /[a-z]/i
1500 1 8 if ($classstring =~ /(\\.)(.*)$/)
1502 1 0 unless (exists $characterhash->{$c})
1510 8 0 if ($classstring =~ /(.)(.*)$/)
1512 7 1 unless (exists $$characterhash{lc $c} or exists $$characterhash{uc $c})
1516 6 1 if $c =~ /^[a-z]$/i
1531 21 8 unless $literal =~ /[a-z]/i
1538 4 39 if ($literal =~ /(\\.)(.*)$/)
1543 39 0 if ($literal =~ /(.)(.*)$/)
1546 25 14 if $c =~ /^[a-z]$/i
1569 1 68 if (exists $rhs->{'type'} and $rhs->{'type'} eq "negatedclass")
1570 0 1 unless exists $rhs->{'value'}
1576 0 68 if (exists $rhs->{'deletedafterconversiontoclass'})
1580 0 68 if (exists $rhs->{'type'} and $rhs->{'type'} eq "unsupported")
1584 8 60 if (exists $rhs->{'type'} and $rhs->{'type'} eq "class")
1588 3 5 if ($self->testoption("matchcaseinsensitive") and $self->isAlphaLiteral($value))
1592 3 0 if $normclass->{'isalphaclass'}
1597 21 39 if (exists $rhs->{'type'} and $rhs->{'type'} eq "literal")
1600 0 21 $literal eq q[\\'] ? :
1601 4 17 if ($self->testoption("matchcaseinsensitive") and $self->isAlphaLiteral($literal))
1609 0 39 if (exists $rhs->{'type'} and $rhs->{'type'} eq "action")
1614 39 0 if (exists $rhs->{'rhs'})
1616 0 39 if not exists $rhs->{'token'} or ref $rhs->{'token'} ne ""
1620 0 0 if (exists $rhs->{'token'})
1624 0 0 if (exists $rhs->{'comments'})
1649 0 69 unless exists $options->{'status'}
1654 0 69 if exists $rhs->{'discard'}
1656 0 69 if ref $options ne "HASH" or not exists $options->{'delimiter'}
1661 10 59 if exists $options->{'cardinality'}
1662 0 69 if $cardinality =~ /[+*]\?/ and $self->testoption("shiftlazytogreedy")
1663 0 69 if $cardinality =~ /[+*]\?/
1671 40 29 if exists $options->{'assignop'}
1676 4 65 if (defined $cardinality and $cardinality eq "?")
1684 32 37 if ($status == 0)
1688 11 26 if ($status == 1)
1692 26 0 if ($status == 2)
1720 0 22 unless exists $rule->{'list'}
1727 0 33 unless exists $rulelist->{'list'}
1729 0 33 if (exists $rulelist->{'metalist'})
1735 0 0 if ref $cl eq "ARRAY"
1738 0 0 if (exists $metalist->{'actions'})
1740 0 0 if (not $self->testoption('embedactions')) { }
1744 0 0 if ref $cl eq "ARRAY"
1753 0 0 if ref $cl eq "ARRAY"
1765 1 58 if exists $rhs->{'cardinality'}
1768 1 58 if defined $cardinality
1770 0 59 if (exists $rhs->{'comments'})
1780 0 0 if (exists $rhs->{'type'} and $rhs->{'type'} eq "group" and exists $rhs->{'list'})
1781 0 0 if (exists $rhs->{'class4list'}) { }
1801 0 59 if ($linelen + length($nextclause) > $self->{'indent'} + 3 + 125) { }
1813 0 33 if (defined $actiontext)
1816 0 0 if $padlen < 0
1822 33 0 if length $outputline > 0
1826 0 22 if (exists $options->{'comments'})
1845 0 32 if $self->{'verbosity'}
1856 9 23 if exists $rule->{'cardinality'}
1859 9 23 if defined $cardinality
1860 18 9 if exists $rule->{'isLexeme'} or exists $rule->{'isFragmentOrChild'} or exists $rule->{'grammarstate'}
1873 0 32 if ($self->testoption("buildkeywords") and $self->isKeywordLetter($rulename, $rule))
1882 1 31 if ($self->testoption("fragment2class") and not $rulename =~ /^opt_/ and fragmentEligible2Convert($rule))
1889 22 9 if (exists $rule->{'list'})
1898 0 9 unless length $outputline
1903 9 23 if length $outputline > 0
1930 0 14 unless defined $rule and exists $rule->{'name'} and exists $rule->{'generationstatus'}
1932 1 13 if length $rulename > $indent
1933 6 8 unless exists $subrules->{$rulename}
1936 3 15 if length $subrulename > $indent
1940 0 1 if $indent == -1
1957 0 1 unless defined $startrule
1968 0 1 if not exists $self->{'discarded'} or ref $self->{'discarded'} ne "ARRAY" or scalar @{$self->{'discarded'};} < 1
2026 0 16 if (exists $rule->{'comment'} and not $self->testoption("stripallcomments"))
2029 0 0 if ref $comment ne "ARRAY"
2037 2 14 unless defined $rule and exists $rule->{'name'} and exists $rule->{'generationstatus'}
2041 1 13 unless ($status)
2043 0 1 if $rulename ne $startrulename
2050 4 4 if exists $subrules->{$rulename} and not $subrulestatus and $rulegeneratedoutput
2058 8 6 if (exists $subrules->{$rulename})
2067 8 0 if $subrulegeneratedoutput
2078 18 14 unless exists $g4rule->{'generationstatus'}
2081 14 0 if exists $marparule->{'status'}
2083 0 0 if $self->{'verbosity'}
2101 0 1 if $self->{'verbosity'} > 1