Branch Coverage

blib/lib/MarpaX/G4/MarpaGen.pm
Criterion Covered Total %
branch 300 530 56.6


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}
119 0 0 unless exists $self->{'subrules'}{$rulename}
127 0 0 if ($_ eq $subrulename) { }
138 0 0 if ($status)
141 0 0 unless exists $rules->{$subrulename}
152 0 5 unless exists $rules->{$rulename}
163 0 96 unless (exists $rules->{$rulename})
165 0 0 unless defined $parent
177 0 32 unless exists $rules->{$rulename}
187 0 5 unless exists $subrules->{$rulename}
191 5 4 if $sr eq $subrulename
205 14 0 if exists $context->{'level'}
206 0 14 unless defined $level
224 8 10 unless exists $context->{'subruleindex'}{$rulename}{'index'}
229 4 14 if (defined $cardinality and $cardinality eq "?")
243 0 360 if ref $token ne "HASH"
246 51 309 if exists $token->{$tag}
260 0 1 if ref $mxtoken ne "HASH"
264 0 1 unless (exists $mxtoken->{'class4list'})
277 0 1 if exists $mxtoken->{'grammarstate'}
278 0 1 if exists $mxtoken->{'isFragmentOrChild'}
283 0 0 if (exists $mxtoken->{'rhs'} and exists $mxtoken->{'rhs'}{'token'})
286 0 0 if (ref $token eq "")
299 0 0 $case =~ /^U/i ? :
329 0 0 if ($lcp =~ /[A-Z]/i) { }
334 0 0 if length $rest > 0
335 0 0 if length $uctoken > 1
342 0 0 if length $uctoken > 1
352 17 4 if $string =~ /^.$/
353 1 3 if $string =~ /^\\[^u]$/i
354 0 3 if $string =~ /^\\u[0-9A-F]{4,4}$/i
355 0 3 if $string =~ /^\\u\{[0-9A-F]{5,5}\}$/i
363 62 9 unless exists $rule->{'class4list'}
365 0 0 if $rulename =~ /^[a-z]$/i and $s =~ /([a-z])([a-z])/i and uc "$1" eq "$2" || lc "$1" eq "$2"
376 30 30 unless exists $rule->{'class4list'}
379 1 6 if $string =~ /([a-z])([a-z])/i and uc "$1" eq "$2" || lc "$1" eq "$2"
380 21 8 unless $string =~ /[a-z]/i
381 5 3 if $string =~ /[0-9]/i
390 3 18 unless isSingleChar($literal)
402 0 0 if $begr->{'type'} ne "literal" or $endr->{'type'} ne "literal"
407 0 0 unless isSingleChar($begr) and isSingleChar($endr)
418 0 120 unless exists $tracker->{'status'}
420 90 30 if (not exists $mxelement->{'class4list'} or $tracker->{'status'} == -1) { }
434 0 60 unless exists $tracker->{'status'}
436 45 15 if (not exists $mxelement->{'keywordfragment'} or $tracker->{'status'} == -1) { }
457 0 18 if (defined $negation)
467 14 4 if exists $context->{'subruleindex'}{$rulename}{'grammarstate'}
468 7 11 if exists $context->{'subruleindex'}{$rulename}{'isFragmentOrChild'}
473 4 14 if defined $cardinality and $cardinality eq "?"
483 0 18 if exists $mxelement->{'class4list'} and not defined $cardinality
484 14 4 if exists $context->{'subruleindex'}{$rulename}{'grammarstate'}
485 7 11 if exists $context->{'subruleindex'}{$rulename}{'isFragmentOrChild'}
497 1 0 unless exists $subrules->{$rulename}
523 0 40 if (ref $token eq "HASH" and exists $token->{'comment'} and not $self->testoption("stripallcomments"))
525 0 0 if ref $token->{'comment'} ne ""
534 0 40 if (ref $token eq "")
541 9 31 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "tokengroup")
548 0 31 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "rulegroup")
557 21 10 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "literal")
563 18 3 if defined $class4list
575 9 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "class")
579 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "regex")
583 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "range")
587 0 1 if (ref $token eq "HASH" and exists $token->{'type'} and $token->{'type'} eq "value")
591 1 0 if (ref $token eq "HASH" and exists $token->{'token'})
595 0 0 if (ref $token eq "HASH" and exists $token->{'action'})
599 0 0 if (ref $token eq "HASH" and exists $token->{'comment'})
612 1 39 if (defined $negation)
624 0 40 if (defined $cardinality)
632 0 40 if defined $alternative
633 0 40 if scalar @$comments > 0 and not $self->testoption("stripallcomments")
642 0 0 if ref $nonterminal ne "HASH"
648 0 0 if (exists $nonterminal->{'rhs'})
674 0 6 if ref $mxtoken ne "HASH"
675 0 6 if $cardinality eq "?"
677 0 6 if $cardinality =~ /[+*]\?/ and $self->testoption("shiftlazytogreedy")
678 0 6 if $cardinality =~ /[+*]\?/
683 5 1 if (exists $mxtoken->{'rhs'})
686 0 5 if ref $rhs ne "HASH"
687 0 5 if not exists $rhs->{'token'} or ref $rhs->{'token'} ne ""
689 0 5 unless defined $self->checkMarpaRuleExists($rhs->{'token'})
693 5 0 if ($abortatfirstlevel) { }
698 0 5 unless $self->isSubrule($rulename, $subrulename)
701 5 0 if ($cardinality ne "?")
714 0 0 unless $self->isSubrule($rulename, $subrulename)
718 0 0 if ($rc)
720 0 0 if exists $rule->{'cardinality'}
729 0 1 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "group")
730 0 0 unless exists $mxtoken->{'list'}
734 0 0 if ref $al ne "HASH" or not exists $al->{'list'}
737 0 0 if exists $le->{'type'} and not $le->{'type'} =~ /literal|class/
744 0 1 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "literal")
749 1 0 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "class")
750 0 1 if exists $mxtoken->{'cardinality'}
755 0 0 if (exists $mxtoken->{'type'} and $mxtoken->{'type'} eq "negatedclass")
756 0 0 if exists $mxtoken->{'cardinality'}
782 17 6 if scalar @$alternativelists < 2
790 0 17 if (not exists $branch->{'list'}) { }
797 5 12 if (scalar @$branchlist > 1) { }
806 4 8 if (exists $rhs->{'type'} and $rhs->{'type'} eq "literal")
810 2 2 if (defined $literal) { }
815 0 2 if $matchfound
823 12 0 unless $matchfound
828 6 0 unless $filtered
864 37 23 if ref $e eq "HASH" and exists $e->{'rhs'} and not exists $e->{'token'}
865 4 0 if ref $e eq "HASH" and exists $e->{'type'} and exists $e->{'definition'}
870 0 60 if (exists $e->{'comment'} or exists $e->{'action'})
872 0 0 if (exists $e->{'comment'} and not $self->testoption("stripallcomments"))
878 0 0 if (exists $e->{'action'} and not $self->testoption("stripactions"))
880 0 0 $self->testoption('embedactions') ? :
890 0 60 if (ref $e eq "HASH" and not exists $e->{'token'})
892 0 0 if exists $e->{'type'} and $e->{'type'} eq "regex"
898 11 49 if (defined $alternative) { }
900 11 0 if (scalar @$currentlist > 0)
911 0 11 if ($self->testoption('buildkeywords') and $keywordfragment->{'status'} == 0 and $keyword =~ /^[a-z]/i) { }
921 2 9 if $class4list->{'status'} != -1
922 0 11 if exists $metalist->{'state'}
941 12 37 if ($alternativelength > 1)
950 21 39 if (ref $e->{'token'} eq '') { }
960 0 39 if ref $e ne "HASH" or not exists $e->{'token'}
963 0 39 if exists $mxelement->{'type'} and $mxelement->{'type'} eq "ignore"
966 23 16 if defined $keywordfragment
972 0 60 if (exists $mxelement->{'comments'})
977 0 0 if scalar keys %$mxelement == 0
984 31 29 unless defined $il
989 0 60 if exists $mxelement->{'negation'}
991 0 60 if (defined $negation)
1000 10 50 if (defined $cardinality)
1007 1 9 if (scalar @$rhslist <= 1 and $self->retagSimpleRule($rulename, $mxelement, $cardinality, $context)) { }
1012 0 1 if (defined $alternative)
1014 0 0 if scalar @$rhslist > 1
1031 0 9 if ($cardinality ne "?" and not $self->retagSimpleRule($rulename, $mxelement, $cardinality, $context, {"abortatfirstlevel", "true"}))
1033 0 0 if scalar @$rhslist > 1
1034 0 0 if $cardinality ne "?"
1054 26 34 if $alternativelength > 1
1061 0 23 if ($self->testoption("buildkeywords") and $keywordfragment->{'status'} == 0 and $keywordfragment->{'value'} =~ /^[a-z]/i)
1072 23 0 if (scalar @$currentlist > 0)
1075 3 20 if $class4list->{'status'} != -1
1076 1 22 if $groupisLexeme->{'status'} == 0
1077 0 23 if exists $metalist->{'state'}
1084 23 0 if $self->testoption("matchcaseinsensitive")
1089 1 22 if $class4group->{'status'} != -1
1090 1 22 if $groupisLexeme->{'status'} == 0
1103 0 9 if ref $tokengroup ne "HASH" or not exists $tokengroup->{'definition'}
1126 9 14 if (defined $rulestatus)
1128 0 9 if ($rulestatus eq "synthetic" and not $self->checkMarpaRuleExists($rulename))
1139 3 6 if ($rulestatus eq "inprogress")
1140 6 0 if ($rulestatus eq "done")
1145 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'})
1201 4 17 if defined $keywordfragment
1237 0 14 unless (exists $rule->{'generationstatus'})
1239 0 0 unless ($status)
1247 0 0 exists $rule->{'grammarstate'} && $rule->{'grammarstate'} =~ /lexer/i ? :
0 0 exists $rule->{'isFragmentOrChild'} ? :
1252 0 1 if $status
1271 1 0 if (not exists $rule->{'generationstatus'} and exists $rule->{'redirect'})
1297 0 1 unless exists $startrule->{'rightsides'}
1315 1 0 if ($outputfile ne '-') { }
1318 0 1 unless open $outf, ">$outputfile"
1332 0 1 if $self->{'is_stdout'}
1339 0 50 unless defined $s
1344 1 49 if $pad < 0
1353 0 0 if ref $comments ne "ARRAY"
1376 0 39 if ref $token ne ""
1380 0 39 if ($self->testoption("matchcaseinsensitive") and $self->isKeywordLetter($token, $rule))
1387 0 39 if exists $rule->{'redirected'}
1396 27 1 unless exists $rule->{'class4list'}
1437 0 12 if ($classstring =~ /(\\u[0-9a-f]+)-(\\u[0-9a-f]+)(.*)$/i)
1444 0 12 if ($classstring =~ /(\\u[0-9a-f]{4,4})(.*)$/i)
1450 3 9 if ($classstring =~ /([^-])-([^-])(.*)$/)
1454 2 0 unless (exists $$classhash{lc $key} or exists $$classhash{uc $key})
1458 1 1 if $beg =~ /[a-z]/i or $end =~ /[a-z]/i
1463 1 8 if ($classstring =~ /(\\.)(.*)$/)
1465 1 0 unless (exists $characterhash->{$c})
1473 8 0 if ($classstring =~ /(.)(.*)$/)
1475 7 1 unless (exists $$characterhash{lc $c} or exists $$characterhash{uc $c})
1479 6 1 if $c =~ /^[a-z]$/i
1494 21 8 unless $literal =~ /[a-z]/i
1501 4 39 if ($literal =~ /(\\.)(.*)$/)
1506 39 0 if ($literal =~ /(.)(.*)$/)
1509 25 14 if $c =~ /^[a-z]$/i
1525 27 42 if exists $rhs->{'isLexeme'}
1533 1 68 if (exists $rhs->{'type'} and $rhs->{'type'} eq "negatedclass")
1534 0 1 unless exists $rhs->{'value'}
1538 0 68 if (exists $rhs->{'deletedafterconversiontoclass'})
1542 0 68 if (exists $rhs->{'type'} and $rhs->{'type'} eq "unsupported")
1546 8 60 if (exists $rhs->{'type'} and $rhs->{'type'} eq "class")
1549 3 5 if ($self->testoption("matchcaseinsensitive") and $self->isAlphaLiteral($value))
1553 3 0 if $normclass->{'isalphaclass'}
1558 21 39 if (exists $rhs->{'type'} and $rhs->{'type'} eq "literal")
1560 0 21 $literal eq q[\\'] ? :
1561 4 17 if ($self->testoption("matchcaseinsensitive") and $self->isAlphaLiteral($literal))
1569 0 39 if (exists $rhs->{'type'} and $rhs->{'type'} eq "action")
1574 39 0 if (exists $rhs->{'rhs'})
1576 0 39 if not exists $rhs->{'token'} or ref $rhs->{'token'} ne ""
1580 0 0 if (exists $rhs->{'token'})
1584 0 0 if (exists $rhs->{'comments'})
1609 0 69 unless exists $options->{'status'}
1614 0 69 if exists $rhs->{'discard'}
1616 0 69 if ref $options ne "HASH" or not exists $options->{'delimiter'}
1621 10 59 if exists $options->{'cardinality'}
1622 0 69 if $cardinality =~ /[+*]\?/ and $self->testoption("shiftlazytogreedy")
1623 0 69 if $cardinality =~ /[+*]\?/
1631 40 29 if exists $options->{'assignop'}
1636 4 65 if (defined $cardinality and $cardinality eq "?")
1643 32 37 if ($status == 0)
1647 11 26 if ($status == 1)
1651 26 0 if ($status == 2)
1679 0 22 unless exists $rule->{'list'}
1686 0 33 unless exists $rulelist->{'list'}
1688 0 33 if (exists $rulelist->{'metalist'})
1694 0 0 if ref $cl eq "ARRAY"
1697 0 0 if (exists $metalist->{'actions'})
1699 0 0 if (not $self->testoption('embedactions')) { }
1703 0 0 if ref $cl eq "ARRAY"
1712 0 0 if ref $cl eq "ARRAY"
1724 1 58 if exists $rhs->{'cardinality'}
1727 1 58 if defined $cardinality
1729 0 59 if (exists $rhs->{'comments'})
1738 0 0 if (exists $rhs->{'type'} and $rhs->{'type'} eq "group" and exists $rhs->{'list'})
1739 0 0 if (exists $rhs->{'class4list'}) { }
1759 0 59 if ($linelen + length($nextclause) > $self->{'indent'} + 3 + 125) { }
1771 0 33 if (defined $actiontext)
1774 0 0 if $padlen < 0
1780 33 0 if length $outputline > 0
1784 0 22 if (exists $options->{'comments'})
1803 0 32 if $self->{'verbosity'}
1814 9 23 if exists $rule->{'cardinality'}
1817 9 23 if defined $cardinality
1818 18 9 if exists $rule->{'isLexeme'} or exists $rule->{'isFragmentOrChild'} or exists $rule->{'grammarstate'}
1831 0 32 if ($self->testoption("buildkeywords") and $self->isKeywordLetter($rulename, $rule))
1840 1 31 if ($self->testoption("fragment2class") and not $rulename =~ /^opt_/ and fragmentEligible2Convert($rule))
1847 22 9 if (exists $rule->{'list'})
1856 0 9 unless length $outputline
1861 9 23 if length $outputline > 0
1888 0 14 unless defined $rule and exists $rule->{'name'} and exists $rule->{'generationstatus'}
1890 1 13 if length $rulename > $indent
1891 6 8 unless exists $subrules->{$rulename}
1894 3 15 if length $subrulename > $indent
1898 0 1 if $indent == -1
1915 0 1 unless defined $startrule
1926 0 1 if not exists $self->{'discarded'} or ref $self->{'discarded'} ne "ARRAY" or scalar @{$self->{'discarded'};} < 1
1985 0 16 if (exists $rule->{'comment'} and not $self->testoption("stripallcomments"))
1988 0 0 if ref $comment ne "ARRAY"
1996 2 14 unless defined $rule and exists $rule->{'name'} and exists $rule->{'generationstatus'}
2000 1 13 unless ($status)
2002 0 1 if $rulename ne $startrulename
2009 4 4 if exists $subrules->{$rulename} and not $subrulestatus and $rulegeneratedoutput
2017 8 6 if (exists $subrules->{$rulename})
2026 8 0 if $subrulegeneratedoutput
2037 18 14 unless exists $g4rule->{'generationstatus'}
2040 14 0 if exists $marparule->{'status'}
2042 0 0 if $self->{'verbosity'}
2060 0 1 if $self->{'verbosity'} > 1