| 1 | # Hoon "tidy" utility | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | no warnings 'recursion'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | package MarpaX::Hoonlint; | ||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Scalar::Util qw(looks_like_number weaken); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use MarpaX::Hoonlint::yahc; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use vars qw($VERSION $STRING_VERSION @ISA $DEBUG); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 7 | $VERSION = '1.010000'; | |||||||||||||||||||||||||||||||
| 19 | 7 | $STRING_VERSION = $VERSION; | |||||||||||||||||||||||||||||||
| 20 | ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||||||
| 21 | 7 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||
| 22 | ## use critic | ||||||||||||||||||||||||||||||||
| 23 | 7 | $DEBUG = 0; | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 7 | my %separator = qw( | |||||||||||||||||||||||||||||||
| 26 | hyf4jSeq DOT | ||||||||||||||||||||||||||||||||
| 27 | singleQuoteCord gon4k | ||||||||||||||||||||||||||||||||
| 28 | dem4k gon4k | ||||||||||||||||||||||||||||||||
| 29 | timePeriodKernel DOT | ||||||||||||||||||||||||||||||||
| 30 | optBonzElements GAP | ||||||||||||||||||||||||||||||||
| 31 | optWideBonzElements ACE | ||||||||||||||||||||||||||||||||
| 32 | till5dSeq GAP | ||||||||||||||||||||||||||||||||
| 33 | wyde5dSeq ACE | ||||||||||||||||||||||||||||||||
| 34 | gash5d FAS | ||||||||||||||||||||||||||||||||
| 35 | togaElements ACE | ||||||||||||||||||||||||||||||||
| 36 | wide5dJogs wide5dJoggingSeparator | ||||||||||||||||||||||||||||||||
| 37 | rope5d DOT | ||||||||||||||||||||||||||||||||
| 38 | rick5d GAP | ||||||||||||||||||||||||||||||||
| 39 | wideRick5d commaAce | ||||||||||||||||||||||||||||||||
| 40 | ruck5d GAP | ||||||||||||||||||||||||||||||||
| 41 | wideRuck5d commaAce | ||||||||||||||||||||||||||||||||
| 42 | tallTopKidSeq GAP_SEM | ||||||||||||||||||||||||||||||||
| 43 | wideInnerTops ACE | ||||||||||||||||||||||||||||||||
| 44 | wideAttrBody commaAce | ||||||||||||||||||||||||||||||||
| 45 | scriptStyleTailElements GAP | ||||||||||||||||||||||||||||||||
| 46 | moldInfixCol2 COL | ||||||||||||||||||||||||||||||||
| 47 | lusSoilSeq DOG4I | ||||||||||||||||||||||||||||||||
| 48 | hepSoilSeq DOG4I | ||||||||||||||||||||||||||||||||
| 49 | infixDot DOG4I | ||||||||||||||||||||||||||||||||
| 50 | waspElements GAP | ||||||||||||||||||||||||||||||||
| 51 | whap5d GAP | ||||||||||||||||||||||||||||||||
| 52 | hornSeq GAP | ||||||||||||||||||||||||||||||||
| 53 | wideHornSeq ACE | ||||||||||||||||||||||||||||||||
| 54 | fordHoopSeq GAP | ||||||||||||||||||||||||||||||||
| 55 | tall5dSeq GAP | ||||||||||||||||||||||||||||||||
| 56 | wide5dSeq ACE | ||||||||||||||||||||||||||||||||
| 57 | fordFascomElements GAP | ||||||||||||||||||||||||||||||||
| 58 | optFordHithElements FAS | ||||||||||||||||||||||||||||||||
| 59 | fordHoofSeq commaWS | ||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub internalError { | ||||||||||||||||||||||||||||||
|
Subroutine
internalError: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 63 | 0 | my ($instance) = @_; | |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $fileName = $instance->{fileName} // "[No file name]"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$instance->{"fileName"} // "[No file name]"
MC/DC0%0/1
$instance->{"fileName"} // "[No file name]"
$instance->{"fileName"}
Truth table0%0/2
A
A= $instance->{"fileName"}
| |||||||||||||||||||||||||||||||||
| 65 | 0 | my @pieces = ( "$PROGRAM_NAME $fileName: Internal Error\n", @_ ); | |||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | push @pieces, "\n" unless $pieces[$#pieces] =~ m/\n$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 67 | 0 | my ( undef, $codeFilename, $codeLine ) = caller; | |||||||||||||||||||||||||||||||
| 68 | 0 | die join q{}, @pieces, | |||||||||||||||||||||||||||||||
| 69 | "Internal error was at $codeFilename, line $codeLine"; | ||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 8070 | ▶ | sub doNode { | ||||||||||||||||||||||||||||||
|
Subroutine
doNode: called CC=15 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 73 | 8070 | my ( $instance, @argChildren ) = @_; | |||||||||||||||||||||||||||||||
| 74 | 8070 | my $pSource = $instance->{pHoonSource}; | |||||||||||||||||||||||||||||||
| 75 | 8070 | my @results = (); | |||||||||||||||||||||||||||||||
| 76 | 8070 | my $childCount = scalar @argChildren; | |||||||||||||||||||||||||||||||
| 77 | 7 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 78 | 8070 | my $ruleID = $Marpa::R2::Context::rule; | |||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 80 | my ( $lhs, @rhs ) = | ||||||||||||||||||||||||||||||||
| 81 | 8070 | map { $MarpaX::Hoonlint::grammar->symbol_display_form($_) } | |||||||||||||||||||||||||||||||
| 82 | $MarpaX::Hoonlint::grammar->rule_expand($ruleID); | ||||||||||||||||||||||||||||||||
| 83 | 8070 | my ( $first_g1, $last_g1 ) = Marpa::R2::Context::location(); | |||||||||||||||||||||||||||||||
| 84 | 8070 | my ($lhsStart) = | |||||||||||||||||||||||||||||||
| 85 | $MarpaX::Hoonlint::recce->g1_location_to_span( $first_g1 + 1 ); | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 8070 | my $node; | |||||||||||||||||||||||||||||||
| 88 | CREATE_NODE: { | ||||||||||||||||||||||||||||||||
| 89 | 8070 | ▶ | if ( $childCount <= 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 90 | 756 | $node = { | |||||||||||||||||||||||||||||||
| 91 | type => 'null', | ||||||||||||||||||||||||||||||||
| 92 | symbol => $lhs, | ||||||||||||||||||||||||||||||||
| 93 | start => $lhsStart, | ||||||||||||||||||||||||||||||||
| 94 | length => 0, | ||||||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||||||
| 96 | 756 | last CREATE_NODE; | |||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 7314 | my ( $last_g1_start, $last_g1_length ) = | |||||||||||||||||||||||||||||||
| 99 | $MarpaX::Hoonlint::recce->g1_location_to_span($last_g1); | ||||||||||||||||||||||||||||||||
| 100 | 7314 | my $lhsLength = $last_g1_start + $last_g1_length - $lhsStart; | |||||||||||||||||||||||||||||||
| 101 | RESULT: { | ||||||||||||||||||||||||||||||||
| 102 | 7314 | CHILD: for my $childIX ( 0 .. $#argChildren ) { | |||||||||||||||||||||||||||||||
| 103 | 11148 | my $child = $argChildren[$childIX]; | |||||||||||||||||||||||||||||||
| 104 | 11148 | my $refType = ref $child; | |||||||||||||||||||||||||||||||
| 105 | 11148 | ▶ | next CHILD unless $refType eq 'ARRAY'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 3105 | my ( $lexemeStart, $lexemeLength, $lexemeName ) = @{$child}; | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 3105 | ▶ | if ( $lexemeName eq 'TRIPLE_DOUBLE_QUOTE_STRING' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 110 | 0 | my $terminator = q{"""}; | |||||||||||||||||||||||||||||||
| 111 | 0 | my $terminatorPos = index ${$pSource}, | |||||||||||||||||||||||||||||||
| 112 | $terminator, | ||||||||||||||||||||||||||||||||
| 113 | $lexemeStart + $lexemeLength; | ||||||||||||||||||||||||||||||||
| 114 | 0 | $lexemeLength = | |||||||||||||||||||||||||||||||
| 115 | $terminatorPos + ( length $terminator ) - $lexemeStart; | ||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | 3105 | ▶ | if ( $lexemeName eq 'TRIPLE_QUOTE_STRING' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 118 | 0 | my $terminator = q{'''}; | |||||||||||||||||||||||||||||||
| 119 | 0 | my $terminatorPos = index ${$pSource}, | |||||||||||||||||||||||||||||||
| 120 | $terminator, | ||||||||||||||||||||||||||||||||
| 121 | $lexemeStart + $lexemeLength; | ||||||||||||||||||||||||||||||||
| 122 | 0 | $lexemeLength = | |||||||||||||||||||||||||||||||
| 123 | $terminatorPos + ( length $terminator ) - $lexemeStart; | ||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | 3105 | $argChildren[$childIX] = { | |||||||||||||||||||||||||||||||
| 126 | type => 'lexeme', | ||||||||||||||||||||||||||||||||
| 127 | start => $lexemeStart, | ||||||||||||||||||||||||||||||||
| 128 | length => $lexemeLength, | ||||||||||||||||||||||||||||||||
| 129 | symbol => $lexemeName, | ||||||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 7314 | my $lastLocation = $lhsStart; | |||||||||||||||||||||||||||||||
| 134 | 7314 | ▶ | if ( ( scalar @rhs ) != $childCount ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | # This is a non-trivial (that is, longer than one item) sequence rule. | ||||||||||||||||||||||||||||||||
| 137 | 255 | my $childIX = 0; | |||||||||||||||||||||||||||||||
| 138 | 255 | my $lastSeparator; | |||||||||||||||||||||||||||||||
| 139 | 255 | CHILD: for ( ; ; ) { | |||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 558 | my $child = $argChildren[$childIX]; | |||||||||||||||||||||||||||||||
| 142 | 558 | my $childType = $child->{type}; | |||||||||||||||||||||||||||||||
| 143 | 558 | $childIX++; | |||||||||||||||||||||||||||||||
| 144 | ITEM: { | ||||||||||||||||||||||||||||||||
| 145 | 558 | ▶ | if ( defined $lastSeparator ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | my $length = | ||||||||||||||||||||||||||||||||
| 147 | 303 | $child->{start} - $lastSeparator->{start}; | |||||||||||||||||||||||||||||||
| 148 | 303 | $lastSeparator->{length} = $length; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | 558 | push @results, $child; | |||||||||||||||||||||||||||||||
| 151 | 558 | $lastLocation = $child->{start} + $child->{length}; | |||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||
| 153 | 558 | ▶ | last RESULT if $childIX > $#argChildren; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 154 | 303 | my $separator = $separator{$lhs}; | |||||||||||||||||||||||||||||||
| 155 | 303 | ▶ | next CHILD unless $separator; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | 303 | $lastSeparator = { | |||||||||||||||||||||||||||||||
| 157 | type => 'separator', | ||||||||||||||||||||||||||||||||
| 158 | symbol => $separator, | ||||||||||||||||||||||||||||||||
| 159 | start => $lastLocation, | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | # length supplied later | ||||||||||||||||||||||||||||||||
| 162 | }; | ||||||||||||||||||||||||||||||||
| 163 | 303 | push @results, $lastSeparator; | |||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | 0 | last RESULT; | |||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | # All other rules | ||||||||||||||||||||||||||||||||
| 169 | 7059 | CHILD: for my $childIX ( 0 .. $#argChildren ) { | |||||||||||||||||||||||||||||||
| 170 | 10590 | my $child = $argChildren[$childIX]; | |||||||||||||||||||||||||||||||
| 171 | 10590 | push @results, $child; | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | $node = { | ||||||||||||||||||||||||||||||||
| 176 | 7314 | type => 'node', | |||||||||||||||||||||||||||||||
| 177 | ruleID => $ruleID, | ||||||||||||||||||||||||||||||||
| 178 | start => $lhsStart, | ||||||||||||||||||||||||||||||||
| 179 | length => $lhsLength, | ||||||||||||||||||||||||||||||||
| 180 | children => \@results, | ||||||||||||||||||||||||||||||||
| 181 | }; | ||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | # Add weak links | ||||||||||||||||||||||||||||||||
| 185 | 8070 | my $children = $node->{children}; | |||||||||||||||||||||||||||||||
| 186 | 8070 | ▶ | if ( $children and scalar @{$children} >= 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$children and scalar @{$children;} >= 1
MC/DC50%1/2
$children and scalar @{$children;} >= 1
$children
scalar @{$children;} >= 1
Truth table66%2/3
A and B
A= $childrenB= scalar @{$children;} >= 1
| |||||||||||||||||||||||||||||||||
| 187 | 7314 | CHILD: for my $childIX ( 0 .. $#$children ) { | |||||||||||||||||||||||||||||||
| 188 | 11451 | my $child = $children->[$childIX]; | |||||||||||||||||||||||||||||||
| 189 | 11451 | $child->{PARENT} = $node; | |||||||||||||||||||||||||||||||
| 190 | 11451 | weaken( $child->{PARENT} ); | |||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | 7314 | CHILD: for my $childIX ( 1 .. $#$children ) { | |||||||||||||||||||||||||||||||
| 193 | 4137 | my $thisChild = $children->[$childIX]; | |||||||||||||||||||||||||||||||
| 194 | 4137 | my $prevChild = $children->[ $childIX - 1 ]; | |||||||||||||||||||||||||||||||
| 195 | 4137 | $thisChild->{PREV} = $prevChild; | |||||||||||||||||||||||||||||||
| 196 | 4137 | weaken( $thisChild->{PREV} ); | |||||||||||||||||||||||||||||||
| 197 | 4137 | $prevChild->{NEXT} = $thisChild; | |||||||||||||||||||||||||||||||
| 198 | 4137 | weaken( $prevChild->{NEXT} ); | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 8070 | my $nodeCount = $instance->{nodeCount}; | |||||||||||||||||||||||||||||||
| 203 | 8070 | $node->{IX} = $nodeCount; | |||||||||||||||||||||||||||||||
| 204 | 8070 | $instance->{nodeCount} = $nodeCount + 1; | |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 8070 | return $node; | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub describeRange { | ||||||||||||||||||||||||||||||
|
Subroutine
describeRange: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 210 | 0 | my ( $firstLine, $firstColumn, $lastLine, $lastColumn ) = @_; | |||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | return sprintf "@%d:%d-%d:%d", $firstLine, $firstColumn, $lastLine, | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | $lastColumn | ||||||||||||||||||||||||||||||||
| 213 | if $firstLine != $lastLine; | ||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | return sprintf "@%d:%d-%d", $firstLine, $firstColumn, $lastColumn | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | if $firstColumn != $lastColumn; | ||||||||||||||||||||||||||||||||
| 216 | 0 | return sprintf "@%d:%d", $firstLine, $firstColumn; | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | sub describeNodeRange { | ||||||||||||||||||||||||||||||
|
Subroutine
describeNodeRange: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 220 | 0 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 221 | 0 | my $firstPos = $node->{start}; | |||||||||||||||||||||||||||||||
| 222 | 0 | my $length = $node->{length}; | |||||||||||||||||||||||||||||||
| 223 | 0 | my $lastPos = $firstPos + $length; | |||||||||||||||||||||||||||||||
| 224 | 0 | my ( $firstLine, $firstColumn ) = $instance->line_column($firstPos); | |||||||||||||||||||||||||||||||
| 225 | 0 | my ( $lastLine, $lastColumn ) = $instance->line_column($lastPos); | |||||||||||||||||||||||||||||||
| 226 | 0 | return describeRange( $firstLine, $firstColumn, $lastLine, $lastColumn ); | |||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub lexeme { | ||||||||||||||||||||||||||||||
|
Subroutine
lexeme: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my ( $instance, $line, $column ) = @_; | |||||||||||||||||||||||||||||||
| 231 | 0 | my $literal = $instance->literalLine($line); | |||||||||||||||||||||||||||||||
| 232 | 0 | my $lexeme = substr $literal, $column; | |||||||||||||||||||||||||||||||
| 233 | 0 | $lexeme =~ s/[\s].*\z//xms; | |||||||||||||||||||||||||||||||
| 234 | 0 | return $lexeme; | |||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | 300 | ▶ | sub literalNode { | ||||||||||||||||||||||||||||||
|
Subroutine
literalNode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 238 | 300 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 239 | 300 | my $start = $node->{start}; | |||||||||||||||||||||||||||||||
| 240 | 300 | my $length = $node->{length}; | |||||||||||||||||||||||||||||||
| 241 | 300 | return $instance->literal( $start, $length ); | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | 702 | ▶ | sub literalLine { | ||||||||||||||||||||||||||||||
|
Subroutine
literalLine: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 245 | 702 | my ( $instance, $lineNum ) = @_; | |||||||||||||||||||||||||||||||
| 246 | 702 | my $lineToPos = $instance->{lineToPos}; | |||||||||||||||||||||||||||||||
| 247 | 702 | my $startPos = $lineToPos->[$lineNum]; | |||||||||||||||||||||||||||||||
| 248 | 702 | ▶ | $DB::single = 1 if not defined $lineToPos->[ $lineNum + 1 ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 249 | 702 | my $line = | |||||||||||||||||||||||||||||||
| 250 | $instance->literal( $startPos, | ||||||||||||||||||||||||||||||||
| 251 | ( $lineToPos->[ $lineNum + 1 ] - $startPos ) ); | ||||||||||||||||||||||||||||||||
| 252 | 702 | return $line; | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | 1017 | ▶ | sub literal { | ||||||||||||||||||||||||||||||
|
Subroutine
literal: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 256 | 1017 | my ( $instance, $start, $length ) = @_; | |||||||||||||||||||||||||||||||
| 257 | 1017 | my $pSource = $instance->{pHoonSource}; | |||||||||||||||||||||||||||||||
| 258 | 1017 | ▶ | return '' if $start >= length ${$pSource}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 259 | 1017 | return substr ${$pSource}, $start, $length; | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||
| 262 | 1761 | ▶ | sub column { | ||||||||||||||||||||||||||||||
|
Subroutine
column: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 263 | 1761 | my ( $instance, $pos ) = @_; | |||||||||||||||||||||||||||||||
| 264 | 1761 | my $pSource = $instance->{pHoonSource}; | |||||||||||||||||||||||||||||||
| 265 | 1761 | return $pos - ( rindex ${$pSource}, "\n", $pos - 1 ); | |||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | 15 | ▶ | sub maxNumWidth { | ||||||||||||||||||||||||||||||
|
Subroutine
maxNumWidth: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 269 | 15 | my ($instance) = @_; | |||||||||||||||||||||||||||||||
| 270 | 15 | return length q{} . $#{ $instance->{lineToPos} }; | |||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | 12 | ▶ | sub contextDisplay { | ||||||||||||||||||||||||||||||
|
Subroutine
contextDisplay: called CC=9 SCAR=39.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 274 | 12 | my ($instance) = @_; | |||||||||||||||||||||||||||||||
| 275 | 12 | my $pTopicLines = $instance->{topicLines}; | |||||||||||||||||||||||||||||||
| 276 | 12 | my $pMistakeLines = $instance->{mistakeLines}; | |||||||||||||||||||||||||||||||
| 277 | 12 | my $contextSize = $instance->{contextSize}; | |||||||||||||||||||||||||||||||
| 278 | 12 | my $displayDetails = $instance->{displayDetails}; | |||||||||||||||||||||||||||||||
| 279 | 12 | my $lineToPos = $instance->{lineToPos}; | |||||||||||||||||||||||||||||||
| 280 | 12 | my @pieces = (); | |||||||||||||||||||||||||||||||
| 281 | 0 | my %tag = map { $_ => q{>} } keys %{$pTopicLines}; | |||||||||||||||||||||||||||||||
| 282 | 12 | $tag{$_} = q{!} for keys %{$pMistakeLines}; | |||||||||||||||||||||||||||||||
| 283 | 0 | my @sortedLines = sort { $a <=> $b } map { $_ + 0; } keys %tag; | |||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | # say STDERR join " ", __FILE__, __LINE__, "# of sorted lines:", (scalar @sortedLines); | ||||||||||||||||||||||||||||||||
| 286 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper(\@sortedLines); | ||||||||||||||||||||||||||||||||
| 287 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($pMistakeLines); | ||||||||||||||||||||||||||||||||
| 288 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($lineToPos); | ||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | 12 | ▶ | if ( $contextSize <= 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | 12 | for my $lineNum (@sortedLines) { | |||||||||||||||||||||||||||||||
| 292 | 0 | my $mistakeDescs = $pMistakeLines->{$lineNum}; | |||||||||||||||||||||||||||||||
| 293 | 0 | for my $mistakeDesc ( @{$mistakeDescs} ) { | |||||||||||||||||||||||||||||||
| 294 | 0 | my ( $mistake, $desc ) = @{$mistakeDesc}; | |||||||||||||||||||||||||||||||
| 295 | 0 | push @pieces, $desc, "\n"; | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||
| 298 | 12 | return join q{}, @pieces; | |||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | 0 | my $maxNumWidth = $instance->maxNumWidth(); | |||||||||||||||||||||||||||||||
| 302 | 0 | my $lineNumFormat = q{%} . $maxNumWidth . 'd'; | |||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||
| 304 | # Add to @pieces a set of lines to be displayed consecutively | ||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $doConsec = sub () { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||
| 306 | 0 | my ( $start, $end ) = @_; | |||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $start = 1 if $start < 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $end = $#$lineToPos - 1 if $end >= $#$lineToPos; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 309 | 0 | for my $lineNum ( $start .. $end ) { | |||||||||||||||||||||||||||||||
| 310 | 0 | my $startPos = $lineToPos->[$lineNum]; | |||||||||||||||||||||||||||||||
| 311 | 0 | my $line = $instance->literalLine($lineNum); | |||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my $tag = $tag{$lineNum} // q{ }; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$tag{$lineNum} // " "
MC/DC0%0/1
$tag{$lineNum} // " "
$tag{$lineNum}
Truth table0%0/2
A
A= $tag{$lineNum}
| |||||||||||||||||||||||||||||||||
| 313 | 0 | my $mistakeDescs = $pMistakeLines->{$lineNum}; | |||||||||||||||||||||||||||||||
| 314 | 0 | for my $mistakeDesc ( @{$mistakeDescs} ) { | |||||||||||||||||||||||||||||||
| 315 | 0 | my ( $mistake, $desc ) = @{$mistakeDesc}; | |||||||||||||||||||||||||||||||
| 316 | 0 | my $details = $mistake->{details}; | |||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | if ( $details and scalar @{$details} and $displayDetails > 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$details and scalar @{$details;} and $displayDetails > 0
$details and scalar @{$details;}
MC/DC0%0/2
$details and scalar @{$details;} and $displayDetails > 0
$details
$displayDetails > 0
Truth table0%0/3
A and B
A= $detailsB= $displayDetails > 0
| |||||||||||||||||||||||||||||||||
| 318 | 0 | push @pieces, '[ ', $desc, "\n"; | |||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | # detail levels are not currently used, but are for future | ||||||||||||||||||||||||||||||||
| 321 | # extensions. | ||||||||||||||||||||||||||||||||
| 322 | 0 | for my $detailLevel ( @{$details} ) { | |||||||||||||||||||||||||||||||
| 323 | 0 | for my $detail ( @{$detailLevel} ) { | |||||||||||||||||||||||||||||||
| 324 | 0 | push @pieces, q{ }, $detail, "\n"; | |||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||
| 327 | 0 | push @pieces, "]\n"; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | else { | ||||||||||||||||||||||||||||||||
| 330 | 0 | push @pieces, '[ ', $desc, " ]\n"; | |||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | 0 | push @pieces, ( sprintf $lineNumFormat, $lineNum ), $tag, q{ }, | |||||||||||||||||||||||||||||||
| 334 | $line; | ||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | 0 | }; | |||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | 0 | my $lastIX = -1; | |||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | CONSEC_RANGE: while ( $lastIX < $#sortedLines ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 340 | 0 | my $firstIX = $lastIX + 1; | |||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | # Divider line if after first consecutive range | ||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | push @pieces, ( '-' x ( $maxNumWidth + 2 ) ), "\n" if $firstIX > 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 344 | 0 | $lastIX = $firstIX; | |||||||||||||||||||||||||||||||
| 345 | 0 | SET_LAST_IX: while (1) { | |||||||||||||||||||||||||||||||
| 346 | 0 | my $nextIX = $lastIX + 1; | |||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | last SET_LAST_IX if $nextIX > $#sortedLines; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | # We combine lines if by doing so, we make the listing shorter. | ||||||||||||||||||||||||||||||||
| 350 | # This is calculated by | ||||||||||||||||||||||||||||||||
| 351 | # 1.) Taking the current last line. | ||||||||||||||||||||||||||||||||
| 352 | # 2.) Add the context lines for the last and next lines (2*($contextSize-1)) | ||||||||||||||||||||||||||||||||
| 353 | # 3.) Adding 1 for the divider line, which we save if we combine ranges. | ||||||||||||||||||||||||||||||||
| 354 | # 4.) Adding 1 because we test if they abut, not overlap | ||||||||||||||||||||||||||||||||
| 355 | # Doing the arithmetic, we get | ||||||||||||||||||||||||||||||||
| 356 | last SET_LAST_IX | ||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if $sortedLines[$lastIX] + 2 * $contextSize < | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | $sortedLines[$nextIX]; | ||||||||||||||||||||||||||||||||
| 359 | 0 | $lastIX = $nextIX; | |||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||
| 361 | 0 | $doConsec->( | |||||||||||||||||||||||||||||||
| 362 | $sortedLines[$firstIX] - ( $contextSize - 1 ), | ||||||||||||||||||||||||||||||||
| 363 | $sortedLines[$lastIX] + ( $contextSize - 1 ) | ||||||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | 0 | return join q{}, @pieces; | |||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | # Set lists of topic and mistake lines in instance | ||||||||||||||||||||||||||||||||
| 371 | 6 | ▶ | sub reportItem { | ||||||||||||||||||||||||||||||
|
Subroutine
reportItem: called CC=12 SCAR=33.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 372 | 6 | my ( $instance, $mistake, $mistakeDesc, $topicLineArg, $mistakeLineArg ) = | |||||||||||||||||||||||||||||||
| 373 | @_; | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | 6 | my $inclusions = $instance->{inclusions}; | |||||||||||||||||||||||||||||||
| 376 | 6 | my $suppressions = $instance->{suppressions}; | |||||||||||||||||||||||||||||||
| 377 | 6 | my $reportPolicy = $mistake->{policy}; | |||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | # TODO: Is subpolicy everywhere? Can the tag | ||||||||||||||||||||||||||||||||
| 380 | # named argument be eliminated? | ||||||||||||||||||||||||||||||||
| 381 | 6 | my $mistakeSubpolicy = $mistake->{subpolicy}; | |||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | # TODO: Change subpolicy to ALWAYS be an array | ||||||||||||||||||||||||||||||||
| 384 | # and eliminate the following code | ||||||||||||||||||||||||||||||||
| 385 | 6 | my @reportSubpolicy = (); | |||||||||||||||||||||||||||||||
| 386 | SET_SUBPOLICY: { | ||||||||||||||||||||||||||||||||
| 387 | 6 | my $refType = ref $mistakeSubpolicy; | |||||||||||||||||||||||||||||||
| 388 | 6 | ▶ | if ($refType eq 'ARRAY') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 389 | 6 | push @reportSubpolicy, @{$mistakeSubpolicy}; | |||||||||||||||||||||||||||||||
| 390 | 6 | last SET_SUBPOLICY; | |||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | 0 | push @reportSubpolicy, $mistakeSubpolicy; | |||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||
| 394 | 6 | my $reportSubpolicy = join ':', @reportSubpolicy; | |||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||
| 396 | # TODO: Usually a default of parentLine, parentColumn has already | ||||||||||||||||||||||||||||||||
| 397 | # been enforced. This is a mistake and should change. | ||||||||||||||||||||||||||||||||
| 398 | # Add reportLine/reportColumn to all mistakes, and do not use | ||||||||||||||||||||||||||||||||
| 399 | # line/column. (Can line/column be eliminated?) | ||||||||||||||||||||||||||||||||
| 400 | 6 | ▶ | my $reportLine = $mistake->{reportLine} // $mistake->{line}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$mistake->{"reportLine"} // $mistake->{"line"}
MC/DC0%0/2
$mistake->{"reportLine"} // $mistake->{"line"}
$mistake->{"reportLine"}
$mistake->{"line"}
Truth table33%1/3
A // B
A= $mistake->{"reportLine"}B= $mistake->{"line"}
| |||||||||||||||||||||||||||||||||
| 401 | 6 | ▶ | my $reportColumn = $mistake->{reportColumn} // $mistake->{column}; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$mistake->{"reportColumn"} // $mistake->{"column"}
MC/DC0%0/2
$mistake->{"reportColumn"} // $mistake->{"column"}
$mistake->{"reportColumn"}
$mistake->{"column"}
Truth table33%1/3
A // B
A= $mistake->{"reportColumn"}B= $mistake->{"column"}
| |||||||||||||||||||||||||||||||||
| 402 | 6 | my $reportLC = join ':', $reportLine, $reportColumn + 1; | |||||||||||||||||||||||||||||||
| 403 | 6 | my $suppressThisItem = 0; | |||||||||||||||||||||||||||||||
| 404 | 6 | my $excludeThisItem = 0; | |||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||
| 406 | $excludeThisItem = 1 | ||||||||||||||||||||||||||||||||
| 407 | if $inclusions | ||||||||||||||||||||||||||||||||
| 408 | 6 | ▶ | and not $inclusions->{$reportLC}{$reportPolicy}{$reportSubpolicy}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$inclusions and not $inclusions->{$reportLC}{$reportPolicy}{$reportSubpolicy}
MC/DC0%0/2
$inclusions and not $inclusions->{$reportLC}{$reportPolicy}{$reportSubpolicy}
$inclusions
not $inclusions->{$reportLC}{$reportPolicy}{$reportSubpolicy}
Truth table33%1/3
A and not(B)
A= $inclusionsB= not $inclusions->{$reportLC}{$reportPolicy}{$reportSubpolicy}
| |||||||||||||||||||||||||||||||||
| 409 | my $suppression = | ||||||||||||||||||||||||||||||||
| 410 | 6 | $suppressions->{$reportLC}->{$reportPolicy}->{$reportSubpolicy}; | |||||||||||||||||||||||||||||||
| 411 | 6 | ▶ | if ( defined $suppression ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 412 | 6 | $suppressThisItem = 1; | |||||||||||||||||||||||||||||||
| 413 | $instance->{unusedSuppressions}->{$reportLC}->{$reportPolicy} | ||||||||||||||||||||||||||||||||
| 414 | 6 | ->{$reportSubpolicy} = undef; | |||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||
| 417 | 6 | ▶ | return if $excludeThisItem; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 418 | 6 | ▶ | return if $suppressThisItem; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | 0 | my $fileName = $instance->{fileName}; | |||||||||||||||||||||||||||||||
| 421 | 0 | my $mistakeLines = $instance->{mistakeLines}; | |||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | 0 | my $topicLines = $instance->{topicLines}; | |||||||||||||||||||||||||||||||
| 424 | 0 | my @topicLines = (); | |||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | push @topicLines, ref $topicLineArg ? @{$topicLineArg} : $topicLineArg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 426 | push @topicLines, | ||||||||||||||||||||||||||||||||
| 427 | 0 | grep { defined $_ } | |||||||||||||||||||||||||||||||
| 428 | ( $mistakeLineArg, $mistake->{line}, | ||||||||||||||||||||||||||||||||
| 429 | 0 | $mistake->{parentLine}, $reportLine ); | |||||||||||||||||||||||||||||||
| 430 | 0 | for my $topicLine (@topicLines) { | |||||||||||||||||||||||||||||||
| 431 | 0 | $topicLines->{$topicLine} = 1; | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | 0 | my $thisMistakeDescs = $mistakeLines->{$mistakeLineArg}; | |||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $thisMistakeDescs = [] if not defined $thisMistakeDescs; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 436 | 0 | push @{$thisMistakeDescs}, | |||||||||||||||||||||||||||||||
| 437 | [ | ||||||||||||||||||||||||||||||||
| 438 | $mistake, | ||||||||||||||||||||||||||||||||
| 439 | "$fileName $reportLC $reportPolicy $reportSubpolicy $mistakeDesc" | ||||||||||||||||||||||||||||||||
| 440 | ]; | ||||||||||||||||||||||||||||||||
| 441 | 0 | $mistakeLines->{$mistakeLineArg} = $thisMistakeDescs; | |||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | 2673 | ▶ | sub lhsName { | ||||||||||||||||||||||||||||||
|
Subroutine
lhsName: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 446 | 2673 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 447 | 2673 | my $grammar = $instance->{grammar}; | |||||||||||||||||||||||||||||||
| 448 | 2673 | my $type = $node->{type}; | |||||||||||||||||||||||||||||||
| 449 | 2673 | ▶ | return if $type ne 'node'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 450 | 2673 | my $ruleID = $node->{ruleID}; | |||||||||||||||||||||||||||||||
| 451 | 2673 | my ( $lhs, @rhs ) = $grammar->rule_expand($ruleID); | |||||||||||||||||||||||||||||||
| 452 | 2673 | return $grammar->symbol_name($lhs); | |||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||
| 455 | # The "symbol" of a node. Not necessarily unique. | ||||||||||||||||||||||||||||||||
| 456 | 729 | ▶ | sub symbol { | ||||||||||||||||||||||||||||||
|
Subroutine
symbol: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 457 | 729 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 458 | # local $Data::Dumper::Maxdepth = 1; | ||||||||||||||||||||||||||||||||
| 459 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($node); | ||||||||||||||||||||||||||||||||
| 460 | 729 | my $name = $node->{symbol}; | |||||||||||||||||||||||||||||||
| 461 | 729 | ▶ | return $name if defined $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 462 | 705 | my $type = $node->{type}; | |||||||||||||||||||||||||||||||
| 463 | 705 | ▶ | $DB::single = 1 if not $type; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 464 | 705 | ▶ | die Data::Dumper::Dumper($node) if not $type; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 465 | 705 | ▶ | return $instance->lhsName($node) if $type eq 'node'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 466 | 0 | return "[$type]"; | |||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | # Can be used as test of "brick-ness" | ||||||||||||||||||||||||||||||||
| 470 | 1719 | ▶ | sub brickName { | ||||||||||||||||||||||||||||||
|
Subroutine
brickName: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 471 | 1719 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 472 | # local $Data::Dumper::Maxdepth = 1; | ||||||||||||||||||||||||||||||||
| 473 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($node); | ||||||||||||||||||||||||||||||||
| 474 | 1719 | my $type = $node->{type}; | |||||||||||||||||||||||||||||||
| 475 | 1719 | ▶ | return $instance->symbol($node) if $type ne 'node'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 476 | 1719 | my $lhsName = $instance->lhsName($node); | |||||||||||||||||||||||||||||||
| 477 | 1719 | ▶ | return $lhsName if not $instance->{mortarLHS}->{$lhsName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 478 | 615 | return; | |||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||
| 481 | # Return the name of a brick by recursively climbing, | ||||||||||||||||||||||||||||||||
| 482 | # and die if this fails. | ||||||||||||||||||||||||||||||||
| 483 | 399 | ▶ | sub forceBrickName { | ||||||||||||||||||||||||||||||
|
Subroutine
forceBrickName: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 484 | 399 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 485 | 399 | my $brickNode = $instance->brickNode($node); | |||||||||||||||||||||||||||||||
| 486 | 399 | ▶ | return $instance->brickName($brickNode) if $brickNode; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 487 | 0 | $DB::single = 1; | |||||||||||||||||||||||||||||||
| 488 | 0 | die; | |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||
| 491 | # The name of a node for diagnostics purposes. Prefers | ||||||||||||||||||||||||||||||||
| 492 | # "brick" symbols over "mortar" symbols. | ||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub diagName { | ||||||||||||||||||||||||||||||
|
Subroutine
diagName: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 494 | 0 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 495 | 0 | my $brickNode = $instance->brickNode($node); | |||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | return $instance->brickName($brickNode) if $brickNode; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 497 | 0 | return $instance->name($node); | |||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||
| 500 | # The "name" of a node. Not necessarily unique | ||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub name { | ||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 502 | 0 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 503 | 0 | my $type = $node->{type}; | |||||||||||||||||||||||||||||||
| 504 | 0 | my $symbol = $instance->symbol($node); | |||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | return $symbol if $type ne 'node'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 506 | 0 | return $instance->lhsName($node); | |||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||
| 509 | # Determine how many spaces we need. | ||||||||||||||||||||||||||||||||
| 510 | # Arguments are an array of strings (intended | ||||||||||||||||||||||||||||||||
| 511 | # to be concatenated) and an integer, representing | ||||||||||||||||||||||||||||||||
| 512 | # the number of spaces needed by the app. | ||||||||||||||||||||||||||||||||
| 513 | # (For hoon this will always between 0 and 2.) | ||||||||||||||||||||||||||||||||
| 514 | # Hoon's notation of spacing, in which a newline is equivalent | ||||||||||||||||||||||||||||||||
| 515 | # a gap and therefore two spaces, is used. | ||||||||||||||||||||||||||||||||
| 516 | # | ||||||||||||||||||||||||||||||||
| 517 | # Return value is the number of spaces needed after | ||||||||||||||||||||||||||||||||
| 518 | # the trailing part of the argument string array is | ||||||||||||||||||||||||||||||||
| 519 | # taken into account. It is always less than or | ||||||||||||||||||||||||||||||||
| 520 | # equal to the `spacesNeeded` argument. | ||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | sub spacesNeeded { | ||||||||||||||||||||||||||||||
|
Subroutine
spacesNeeded: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 522 | 0 | my ( $strings, $spacesNeeded ) = @_; | |||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | for ( my $arrayIX = $#$strings ; $arrayIX >= 0 ; $arrayIX-- ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||
| 525 | 0 | my $string = $strings->[$arrayIX]; | |||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | for ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 528 | my $stringIX = ( length $string ) - 1 ; | ||||||||||||||||||||||||||||||||
| 529 | $stringIX >= 0 ; | ||||||||||||||||||||||||||||||||
| 530 | $stringIX-- | ||||||||||||||||||||||||||||||||
| 531 | ) | ||||||||||||||||||||||||||||||||
| 532 | { | ||||||||||||||||||||||||||||||||
| 533 | 0 | my $char = substr $string, $stringIX, 1; | |||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | return 0 if $char eq "\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | return $spacesNeeded if $char ne q{ }; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 536 | 0 | $spacesNeeded--; | |||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | return 0 if $spacesNeeded <= 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||
| 541 | # No spaces needed at beginning of string; | ||||||||||||||||||||||||||||||||
| 542 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||
| 545 | 7 | ▶ | sub testStyleCensus { | ||||||||||||||||||||||||||||||
|
Subroutine
testStyleCensus: called CC=10 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 546 | 7 | my ($instance) = @_; | |||||||||||||||||||||||||||||||
| 547 | 7 | my $ruleDB = $instance->{ruleDB}; | |||||||||||||||||||||||||||||||
| 548 | 7 | my $symbolDB = $instance->{symbolDB}; | |||||||||||||||||||||||||||||||
| 549 | 7 | my $symbolReverseDB = $instance->{symbolReverseDB}; | |||||||||||||||||||||||||||||||
| 550 | 7 | my $grammar = $instance->{grammar}; | |||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | SYMBOL: | ||||||||||||||||||||||||||||||||
| 553 | 7 | for my $symbolID ( $grammar->symbol_ids() ) { | |||||||||||||||||||||||||||||||
| 554 | 5607 | my $name = $grammar->symbol_name($symbolID); | |||||||||||||||||||||||||||||||
| 555 | 5607 | my $data = {}; | |||||||||||||||||||||||||||||||
| 556 | 5607 | $data->{name} = $name; | |||||||||||||||||||||||||||||||
| 557 | 5607 | $data->{id} = $symbolID; | |||||||||||||||||||||||||||||||
| 558 | 5607 | $data->{lexeme} = 1; # default to lexeme | |||||||||||||||||||||||||||||||
| 559 | 5607 | ▶ | $data->{gap} = 1 if $name eq 'GAP'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 560 | 5607 | ▶ | if ( $name =~ m/^[B-Z][AEOIU][B-Z][B-Z][AEIOU][B-Z]GAP$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 561 | 504 | $data->{gap} = 1; | |||||||||||||||||||||||||||||||
| 562 | 504 | $data->{runeGap} = 1; | |||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||
| 564 | 5607 | $symbolDB->[$symbolID] = $data; | |||||||||||||||||||||||||||||||
| 565 | 5607 | $symbolReverseDB->{$name} = $data; | |||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||
| 567 | 7 | my $gapID = $symbolReverseDB->{'GAP'}->{id}; | |||||||||||||||||||||||||||||||
| 568 | RULE: | ||||||||||||||||||||||||||||||||
| 569 | 7 | for my $ruleID ( $grammar->rule_ids() ) { | |||||||||||||||||||||||||||||||
| 570 | 7714 | my $data = { id => $ruleID }; | |||||||||||||||||||||||||||||||
| 571 | 7714 | my ( $lhs, @rhs ) = $grammar->rule_expand($ruleID); | |||||||||||||||||||||||||||||||
| 572 | 7714 | $data->{symbols} = [ $lhs, @rhs ]; | |||||||||||||||||||||||||||||||
| 573 | 7714 | my $lhsName = $grammar->symbol_name($lhs); | |||||||||||||||||||||||||||||||
| 574 | 7714 | my $separatorName = $separator{$lhsName}; | |||||||||||||||||||||||||||||||
| 575 | 7714 | ▶ | if ($separatorName) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 576 | 238 | my $separatorID = $symbolReverseDB->{$separatorName}->{id}; | |||||||||||||||||||||||||||||||
| 577 | 238 | $data->{separator} = $separatorID; | |||||||||||||||||||||||||||||||
| 578 | 238 | ▶ | if ( $separatorID == $gapID ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 579 | 77 | $data->{gapiness} = -1; | |||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||
| 582 | 7714 | ▶ | if ( not defined $data->{gapiness} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 583 | 7637 | for my $rhsID (@rhs) { | |||||||||||||||||||||||||||||||
| 584 | 18648 | ▶ | $data->{gapiness}++ if $symbolDB->[$rhsID]->{gap}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||
| 587 | 7714 | $ruleDB->[$ruleID] = $data; | |||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||
| 589 | # say STDERR join " ", __FILE__, __LINE__, "setting rule $ruleID gapiness to", $data->{gapiness} // 'undef'; | ||||||||||||||||||||||||||||||||
| 590 | 7714 | $symbolReverseDB->{$lhs}->{lexeme} = 0; | |||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | sub gapNode { | ||||||||||||||||||||||||||||||
|
Subroutine
gapNode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 596 | 0 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 597 | 0 | my $symbolReverseDB = $instance->{symbolReverseDB}; | |||||||||||||||||||||||||||||||
| 598 | 0 | my $symbol = $node->{symbol}; | |||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | return if not defined $symbol; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 600 | 0 | return $symbolReverseDB->{$symbol}->{gap}; | |||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | 669 | ▶ | sub runeGapNode { | ||||||||||||||||||||||||||||||
|
Subroutine
runeGapNode: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 604 | 669 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 605 | 669 | my $symbolReverseDB = $instance->{symbolReverseDB}; | |||||||||||||||||||||||||||||||
| 606 | 669 | my $symbol = $node->{symbol}; | |||||||||||||||||||||||||||||||
| 607 | 669 | ▶ | return if not defined $symbol; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 608 | 669 | return $symbolReverseDB->{$symbol}->{runeGap}; | |||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||
| 611 | # Assumes the node *is* a gap | ||||||||||||||||||||||||||||||||
| 612 | 285 | ▶ | sub gapLength { | ||||||||||||||||||||||||||||||
|
Subroutine
gapLength: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 613 | 285 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 614 | 285 | ▶ | if ( $instance->runeGapNode($node) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 615 | 192 | my $gapLiteral = $instance->literalNode($node); | |||||||||||||||||||||||||||||||
| 616 | 192 | return (length $gapLiteral) - 2; | |||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||
| 618 | 93 | return $node->{length}; | |||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||
| 621 | 16851 | ▶ | sub line_column { | ||||||||||||||||||||||||||||||
|
Subroutine
line_column: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 622 | 16851 | my ( $instance, $pos ) = @_; | |||||||||||||||||||||||||||||||
| 623 | 16851 | $Data::Dumper::Maxdepth = 3; | |||||||||||||||||||||||||||||||
| 624 | 16851 | ▶ | die Data::Dumper::Dumper($instance) if not defined $instance->{recce}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 625 | 16851 | my ( $line, $column ) = $instance->{recce}->line_column($pos); | |||||||||||||||||||||||||||||||
| 626 | 16851 | $column--; | |||||||||||||||||||||||||||||||
| 627 | 16851 | return $line, $column; | |||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | sub ancestorByBrickName { | ||||||||||||||||||||||||||||||
|
Subroutine
ancestorByBrickName: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 631 | 0 | my ( $instance, $node, $name ) = @_; | |||||||||||||||||||||||||||||||
| 632 | 0 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | PARENT: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 634 | 0 | my $thisName = $instance->brickName($thisNode); | |||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | return $thisNode if defined $thisName and $thisName eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $thisName and $thisName eq $name
MC/DC0%0/2
defined $thisName and $thisName eq $name
defined $thisName
$thisName eq $name
Truth table0%0/3
A and B
A= defined $thisNameB= $thisName eq $name
| |||||||||||||||||||||||||||||||||
| 636 | 0 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||
| 638 | 0 | return; | |||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||
| 641 | 90 | ▶ | sub ancestorByLHS { | ||||||||||||||||||||||||||||||
|
Subroutine
ancestorByLHS: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 642 | 90 | my ( $instance, $node, $names ) = @_; | |||||||||||||||||||||||||||||||
| 643 | 90 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 644 | 90 | ▶ | PARENT: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 645 | 249 | my $thisName = $instance->lhsName($thisNode); | |||||||||||||||||||||||||||||||
| 646 | 249 | ▶ | return $thisNode if defined $thisName and $names->{$thisName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $thisName and $names->{$thisName}
MC/DC50%1/2
defined $thisName and $names->{$thisName}
defined $thisName
$names->{$thisName}
Truth table66%2/3
A and B
A= defined $thisNameB= $names->{$thisName}
| |||||||||||||||||||||||||||||||||
| 647 | 159 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||
| 649 | 0 | return; | |||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||
| 652 | 54 | ▶ | sub ancestor { | ||||||||||||||||||||||||||||||
|
Subroutine
ancestor: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 653 | 54 | my ( $instance, $node, $generations ) = @_; | |||||||||||||||||||||||||||||||
| 654 | 54 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 655 | 54 | ▶ | PARENT: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 656 | 108 | ▶ | return $thisNode if $generations <= 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 657 | 54 | $generations--; | |||||||||||||||||||||||||||||||
| 658 | 54 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||
| 660 | 0 | return; | |||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||
| 663 | 4572 | ▶ | sub nodeLC { | ||||||||||||||||||||||||||||||
|
Subroutine
nodeLC: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 664 | 4572 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 665 | 4572 | return $instance->line_column( $node->{start} ); | |||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||
| 668 | 468 | ▶ | sub brickNode { | ||||||||||||||||||||||||||||||
|
Subroutine
brickNode: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 669 | 468 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 670 | 468 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 671 | 468 | ▶ | while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 672 | 669 | ▶ | return $thisNode if $instance->brickName($thisNode); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 673 | 201 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||
| 675 | 0 | return; | |||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||
| 678 | # Return a brick descendent, if there is one. | ||||||||||||||||||||||||||||||||
| 679 | # Only singletons are followed. | ||||||||||||||||||||||||||||||||
| 680 | 30 | ▶ | sub brickDescendant { | ||||||||||||||||||||||||||||||
|
Subroutine
brickDescendant: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 681 | 30 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 682 | # local $Data::Dumper::Maxdepth = 1; | ||||||||||||||||||||||||||||||||
| 683 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($node); | ||||||||||||||||||||||||||||||||
| 684 | 30 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 685 | 30 | ▶ | while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 686 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($thisNode); | ||||||||||||||||||||||||||||||||
| 687 | 36 | ▶ | return $thisNode if $instance->brickName($thisNode); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 688 | 6 | my $children = $thisNode->{children}; | |||||||||||||||||||||||||||||||
| 689 | 6 | ▶ | return if not $children; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 690 | 6 | $thisNode = $children->[0]; | |||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||
| 692 | 0 | return; | |||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||
| 695 | 0 | ▶ | sub brickLC { | ||||||||||||||||||||||||||||||
|
Subroutine
brickLC: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 696 | 0 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 697 | 0 | return $instance->nodeLC( $instance->brickNode($node) ); | |||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||
| 700 | # first brick node in $node's line -- | ||||||||||||||||||||||||||||||||
| 701 | # $node if there is no prior brick node | ||||||||||||||||||||||||||||||||
| 702 | 21 | ▶ | sub firstBrickOfLine { | ||||||||||||||||||||||||||||||
|
Subroutine
firstBrickOfLine: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 703 | 21 | my ( $instance, $node ) = @_; | |||||||||||||||||||||||||||||||
| 704 | 21 | my ($currentLine) = $instance->nodeLC($node); | |||||||||||||||||||||||||||||||
| 705 | 21 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 706 | 21 | my $firstBrickNode; | |||||||||||||||||||||||||||||||
| 707 | 21 | ▶ | NODE: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 708 | 63 | my ($thisLine) = $instance->nodeLC($thisNode); | |||||||||||||||||||||||||||||||
| 709 | 63 | ▶ | last NODE if $thisLine != $currentLine; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 710 | 42 | ▶ | $firstBrickNode = $thisNode if $instance->brickName($thisNode); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 711 | 42 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||
| 713 | 21 | ▶ | return $firstBrickNode // $node; | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$firstBrickNode // $node
MC/DC0%0/2
$firstBrickNode // $node
$firstBrickNode
$node
Truth table33%1/3
A // B
A= $firstBrickNodeB= $node
| |||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||
| 716 | # first brick node in $node's line, | ||||||||||||||||||||||||||||||||
| 717 | # by inclusion list. | ||||||||||||||||||||||||||||||||
| 718 | # $node if there is no prior included brick node | ||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | sub firstBrickOfLineInc { | ||||||||||||||||||||||||||||||
|
Subroutine
firstBrickOfLineInc: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 720 | 0 | my ( $instance, $node, $inclusions ) = @_; | |||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||
| 722 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($inclusions); | ||||||||||||||||||||||||||||||||
| 723 | 0 | my ($currentLine) = $instance->nodeLC($node); | |||||||||||||||||||||||||||||||
| 724 | 0 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 725 | 0 | my $firstBrickNode = $node; | |||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | NODE: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 727 | 0 | my ($thisLine) = $instance->nodeLC($thisNode); | |||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||
| 729 | # say STDERR join " ", __FILE__, __LINE__, 'LC', $instance->nodeLC($thisNode); | ||||||||||||||||||||||||||||||||
| 730 | # say STDERR join " ", __FILE__, __LINE__, $thisLine, $currentLine; | ||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | last NODE if $thisLine != $currentLine; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 732 | PICK_NODE: { | ||||||||||||||||||||||||||||||||
| 733 | 0 | my $brickName = $instance->brickName($thisNode); | |||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||
| 735 | # say STDERR join " ", __FILE__, __LINE__, ($brickName // '[undef]'); | ||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | last PICK_NODE if not defined $brickName; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | $firstBrickNode = $thisNode if $inclusions->{$brickName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||
| 739 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||
| 741 | 0 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||
| 743 | 0 | return $firstBrickNode; | |||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||
| 746 | # first brick node in $node's line, | ||||||||||||||||||||||||||||||||
| 747 | # with exclusions. | ||||||||||||||||||||||||||||||||
| 748 | # $node if there is no prior unexcluded brick node | ||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | sub firstBrickOfLineExc { | ||||||||||||||||||||||||||||||
|
Subroutine
firstBrickOfLineExc: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 750 | 0 | my ( $instance, $node, $exclusions ) = @_; | |||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||
| 752 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($exclusions); | ||||||||||||||||||||||||||||||||
| 753 | 0 | my ($currentLine) = $instance->nodeLC($node); | |||||||||||||||||||||||||||||||
| 754 | 0 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 755 | 0 | my $firstBrickNode = $node; | |||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | NODE: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 757 | 0 | my ($thisLine) = $instance->nodeLC($thisNode); | |||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||
| 759 | # say STDERR join " ", __FILE__, __LINE__, 'LC', $instance->nodeLC($thisNode); | ||||||||||||||||||||||||||||||||
| 760 | # say STDERR join " ", __FILE__, __LINE__, $thisLine, $currentLine; | ||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | last NODE if $thisLine != $currentLine; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 762 | PICK_NODE: { | ||||||||||||||||||||||||||||||||
| 763 | 0 | my $brickName = $instance->brickName($thisNode); | |||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||
| 765 | # say STDERR join " ", __FILE__, __LINE__, ($brickName // '[undef]'); | ||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | last PICK_NODE if not defined $brickName; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | last PICK_NODE if $exclusions->{$brickName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||
| 771 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 772 | 0 | $firstBrickNode = $thisNode; | |||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||
| 774 | 0 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||
| 777 | # say STDERR join " ", __FILE__, __LINE__, "returning from firstBrickOfLine"; | ||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||
| 779 | 0 | return $firstBrickNode; | |||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||
| 782 | # nearest (in syntax tree) brick node in $node's line, | ||||||||||||||||||||||||||||||||
| 783 | # from inclusion list | ||||||||||||||||||||||||||||||||
| 784 | # $node if there is no nearest included brick node on same line | ||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | sub nearestBrickOfLineInc { | ||||||||||||||||||||||||||||||
|
Subroutine
nearestBrickOfLineInc: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 786 | 0 | my ( $instance, $node, $inclusions ) = @_; | |||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||
| 788 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($inclusions); | ||||||||||||||||||||||||||||||||
| 789 | 0 | my ($currentLine) = $instance->nodeLC($node); | |||||||||||||||||||||||||||||||
| 790 | 0 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | NODE: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 792 | 0 | my ($thisLine) = $instance->nodeLC($thisNode); | |||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||
| 794 | # say STDERR join " ", __FILE__, __LINE__, 'LC', $instance->nodeLC($thisNode); | ||||||||||||||||||||||||||||||||
| 795 | # say STDERR join " ", __FILE__, __LINE__, $thisLine, $currentLine; | ||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | last NODE if $thisLine != $currentLine; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 797 | PICK_NODE: { | ||||||||||||||||||||||||||||||||
| 798 | 0 | my $brickName = $instance->brickName($thisNode); | |||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||
| 800 | # say STDERR join " ", __FILE__, __LINE__, ($brickName // '[undef]'); | ||||||||||||||||||||||||||||||||
| 801 | 0 | ▶ | last PICK_NODE if not defined $brickName; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||
| 803 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 804 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | return $thisNode if $inclusions->{$brickName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||
| 807 | 0 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||
| 810 | # say STDERR join " ", __FILE__, __LINE__, "returning from nearestBrickOfLineInc"; | ||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||
| 812 | 0 | return $node; | |||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||
| 815 | # nearest (in syntax tree) brick node in $node's line -- | ||||||||||||||||||||||||||||||||
| 816 | # with exclusions. | ||||||||||||||||||||||||||||||||
| 817 | # $node if there is no nearest unexcluded brick node on same line | ||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | sub nearestBrickOfLineExc { | ||||||||||||||||||||||||||||||
|
Subroutine
nearestBrickOfLineExc: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 819 | 0 | my ( $instance, $node, $exclusions ) = @_; | |||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||
| 821 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper($exclusions); | ||||||||||||||||||||||||||||||||
| 822 | 0 | my ($currentLine) = $instance->nodeLC($node); | |||||||||||||||||||||||||||||||
| 823 | 0 | my $thisNode = $node; | |||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | NODE: while ($thisNode) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 825 | 0 | my ($thisLine) = $instance->nodeLC($thisNode); | |||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||
| 827 | # say STDERR join " ", __FILE__, __LINE__, 'LC', $instance->nodeLC($thisNode); | ||||||||||||||||||||||||||||||||
| 828 | # say STDERR join " ", __FILE__, __LINE__, $thisLine, $currentLine; | ||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | last NODE if $thisLine != $currentLine; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 830 | PICK_NODE: { | ||||||||||||||||||||||||||||||||
| 831 | 0 | my $brickName = $instance->brickName($thisNode); | |||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||
| 833 | # say STDERR join " ", __FILE__, __LINE__, ($brickName // '[undef]'); | ||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | last PICK_NODE if not defined $brickName; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||
| 836 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | last PICK_NODE if $exclusions->{$brickName}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||
| 839 | # say STDERR join " ", __FILE__, __LINE__, $brickName; | ||||||||||||||||||||||||||||||||
| 840 | 0 | return $thisNode; | |||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||
| 842 | 0 | $thisNode = $thisNode->{PARENT}; | |||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||
| 845 | # say STDERR join " ", __FILE__, __LINE__, "returning from nearestBrickOfLine"; | ||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||
| 847 | 0 | return $node; | |||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||
| 850 | 7 | my $semantics = <<'EOS'; | |||||||||||||||||||||||||||||||
| 851 | :default ::= action=>MarpaX::Hoonlint::doNode | ||||||||||||||||||||||||||||||||
| 852 | lexeme default = latm => 1 action=>[start,length,name] | ||||||||||||||||||||||||||||||||
| 853 | EOS | ||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||
| 855 | 7 | my $parser = | |||||||||||||||||||||||||||||||
| 856 | MarpaX::Hoonlint::YAHC->new( { semantics => $semantics, all_symbols => 1 } ); | ||||||||||||||||||||||||||||||||
| 857 | 7 | my $dsl = $parser->dsl(); | |||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||
| 859 | 7 | $MarpaX::Hoonlint::grammar = $parser->rawGrammar(); | |||||||||||||||||||||||||||||||
| 860 | 7 | my %baseLintInstance = (); | |||||||||||||||||||||||||||||||
| 861 | 7 | $baseLintInstance{parser} = $parser; | |||||||||||||||||||||||||||||||
| 862 | 7 | $baseLintInstance{grammar} = $MarpaX::Hoonlint::grammar; | |||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||
| 864 | 7 | my %NYI_Rule = (); | |||||||||||||||||||||||||||||||
| 865 | 7 | $NYI_Rule{$_} = 1 for qw(); | |||||||||||||||||||||||||||||||
| 866 | 7 | $baseLintInstance{NYI_Rule} = \%NYI_Rule; | |||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||
| 868 | 763 | my %tallRuneRule = map { +( $_, 1 ) } grep { | |||||||||||||||||||||||||||||||
| 869 | 5607 | ▶ | /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]$/ | ||||||||||||||||||||||||||||||
|
Condition100%3/3
/^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]$/ || /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]Mold$/
MC/DC100%2/2
/^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]$/ || /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]Mold$/
/^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]$/
/^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]Mold$/
Truth table100%3/3
A || B
A= /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]$/B= /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]Mold$/
| |||||||||||||||||||||||||||||||||
| 870 | or /^tall[B-Z][aeoiu][b-z][b-z][aeiou][b-z]Mold$/ | ||||||||||||||||||||||||||||||||
| 871 | 7 | } map { $MarpaX::Hoonlint::grammar->symbol_name($_); } | |||||||||||||||||||||||||||||||
| 872 | $MarpaX::Hoonlint::grammar->symbol_ids(); | ||||||||||||||||||||||||||||||||
| 873 | 7 | $baseLintInstance{tallRuneRule} = \%tallRuneRule; | |||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||
| 875 | # TODO: Check that these are all backdented, | ||||||||||||||||||||||||||||||||
| 876 | 7 | my %tallNoteRule = map { +( $_, 1 ) } qw( | |||||||||||||||||||||||||||||||
| 877 | tallBarhep tallBardot | ||||||||||||||||||||||||||||||||
| 878 | tallBuccab | ||||||||||||||||||||||||||||||||
| 879 | tallCendot tallColcab | ||||||||||||||||||||||||||||||||
| 880 | tallKetbar tallKethep tallKetlus tallKetsig tallKetwut | ||||||||||||||||||||||||||||||||
| 881 | tallSigbar tallSigcab tallSigfas tallSiglus | ||||||||||||||||||||||||||||||||
| 882 | tallTisbar tallTiscom tallTisgal | ||||||||||||||||||||||||||||||||
| 883 | tallWutgal tallWutgar tallWuttis | ||||||||||||||||||||||||||||||||
| 884 | tallZapgar | ||||||||||||||||||||||||||||||||
| 885 | ); | ||||||||||||||||||||||||||||||||
| 886 | 7 | $baseLintInstance{tallNoteRule} = \%tallNoteRule; | |||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||
| 888 | 7 | my %mortarLHS = map { +( $_, 1 ) } | |||||||||||||||||||||||||||||||
| 889 | qw(rick5dJog ruck5dJog rick5d ruck5d till5dSeq tall5dSeq | ||||||||||||||||||||||||||||||||
| 890 | fordFile fordHoop fordHoopSeq norm5d tall5d | ||||||||||||||||||||||||||||||||
| 891 | boog5d wisp5d whap5d); | ||||||||||||||||||||||||||||||||
| 892 | 7 | $baseLintInstance{mortarLHS} = \%mortarLHS; | |||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||
| 894 | my %tallBodyRule = | ||||||||||||||||||||||||||||||||
| 895 | 7 | map { +( $_, 1 ) } grep { not $tallNoteRule{$_} } keys %tallRuneRule; | |||||||||||||||||||||||||||||||
| 896 | 7 | $baseLintInstance{tallBodyRule} = \%tallBodyRule; | |||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||
| 898 | # Will include: | ||||||||||||||||||||||||||||||||
| 899 | # BuccenMold BuccolMold BucwutMold | ||||||||||||||||||||||||||||||||
| 900 | # Buccen Buccol Bucwut Colsig Coltar Wutbar Wutpam | ||||||||||||||||||||||||||||||||
| 901 | 7 | my %tall_0RunningRule = map { +( $_, 1 ) } qw( | |||||||||||||||||||||||||||||||
| 902 | tallBuccen tallBuccenMold | ||||||||||||||||||||||||||||||||
| 903 | tallBuccol tallBuccolMold | ||||||||||||||||||||||||||||||||
| 904 | tallBucwut tallBucwutMold | ||||||||||||||||||||||||||||||||
| 905 | tallColsig tallColtar tallTissig | ||||||||||||||||||||||||||||||||
| 906 | tallWutbar tallWutpam); | ||||||||||||||||||||||||||||||||
| 907 | 7 | $baseLintInstance{tall_0RunningRule} = \%tall_0RunningRule; | |||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||
| 909 | my %tall_1RunningRule = | ||||||||||||||||||||||||||||||||
| 910 | 7 | map { +( $_, 1 ) } qw( tallDotket tallSemcol tallSemsig tallCencolMold ); | |||||||||||||||||||||||||||||||
| 911 | 7 | $baseLintInstance{tall_1RunningRule} = \%tall_1RunningRule; | |||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||
| 913 | my %tall_1JoggingRule = | ||||||||||||||||||||||||||||||||
| 914 | 7 | map { +( $_, 1 ) } qw(tallCentis tallCencab tallWuthep); | |||||||||||||||||||||||||||||||
| 915 | 7 | $baseLintInstance{tall_1JoggingRule} = \%tall_1JoggingRule; | |||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||
| 917 | 7 | my %tall_2JoggingRule = map { +( $_, 1 ) } qw(tallCentar tallWutlus); | |||||||||||||||||||||||||||||||
| 918 | 7 | $baseLintInstance{tall_2JoggingRule} = \%tall_2JoggingRule; | |||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||
| 920 | 7 | my %tallJogging1_Rule = map { +( $_, 1 ) } qw(tallTiscol); | |||||||||||||||||||||||||||||||
| 921 | 7 | $baseLintInstance{tallJogging1_Rule} = \%tallJogging1_Rule; | |||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||
| 923 | 7 | my %joggingRule = map { +( $_, 1 ) } ( | |||||||||||||||||||||||||||||||
| 924 | keys %tall_1JoggingRule, | ||||||||||||||||||||||||||||||||
| 925 | keys %tall_2JoggingRule, | ||||||||||||||||||||||||||||||||
| 926 | keys %tallJogging1_Rule | ||||||||||||||||||||||||||||||||
| 927 | ); | ||||||||||||||||||||||||||||||||
| 928 | 7 | $baseLintInstance{joggingRule} = \%joggingRule; | |||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||
| 930 | my %tallLuslusRule = | ||||||||||||||||||||||||||||||||
| 931 | 7 | map { +( $_, 1 ) } qw(LuslusCell LushepCell LustisCell); | |||||||||||||||||||||||||||||||
| 932 | 7 | $baseLintInstance{tallLuslusRule} = \%tallLuslusRule; | |||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||
| 934 | 7 | my %barcenAnchorExceptions = (); | |||||||||||||||||||||||||||||||
| 935 | $barcenAnchorExceptions{$_} = 1 | ||||||||||||||||||||||||||||||||
| 936 | 7 | for qw(tallTisgar tallTisgal LuslusCell LushepCell LustisCell); | |||||||||||||||||||||||||||||||
| 937 | 7 | $baseLintInstance{barcenAnchorExceptions} = \%barcenAnchorExceptions; | |||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||
| 939 | 7 | my %tallJogRule = map { +( $_, 1 ) } qw(rick5dJog ruck5dJog); | |||||||||||||||||||||||||||||||
| 940 | 7 | $baseLintInstance{tallJogRule} = \%tallJogRule; | |||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||
| 942 | 7 | my %tallBackdentRule = map { +( $_, 1 ) } qw( | |||||||||||||||||||||||||||||||
| 943 | bonz5d | ||||||||||||||||||||||||||||||||
| 944 | fordFascol | ||||||||||||||||||||||||||||||||
| 945 | fordFasket | ||||||||||||||||||||||||||||||||
| 946 | fordFaspam | ||||||||||||||||||||||||||||||||
| 947 | fordFassem | ||||||||||||||||||||||||||||||||
| 948 | tallBarcol | ||||||||||||||||||||||||||||||||
| 949 | tallBarsig | ||||||||||||||||||||||||||||||||
| 950 | tallBartar | ||||||||||||||||||||||||||||||||
| 951 | tallBartis | ||||||||||||||||||||||||||||||||
| 952 | tallBuchep | ||||||||||||||||||||||||||||||||
| 953 | tallBuchepMold | ||||||||||||||||||||||||||||||||
| 954 | tallBucket | ||||||||||||||||||||||||||||||||
| 955 | tallBucketMold | ||||||||||||||||||||||||||||||||
| 956 | tallBucpat | ||||||||||||||||||||||||||||||||
| 957 | tallBuctisMold | ||||||||||||||||||||||||||||||||
| 958 | tallCenhep | ||||||||||||||||||||||||||||||||
| 959 | tallCenhepMold | ||||||||||||||||||||||||||||||||
| 960 | tallCenket | ||||||||||||||||||||||||||||||||
| 961 | tallCenlus | ||||||||||||||||||||||||||||||||
| 962 | tallCenlusMold | ||||||||||||||||||||||||||||||||
| 963 | tallCensig | ||||||||||||||||||||||||||||||||
| 964 | tallCentar | ||||||||||||||||||||||||||||||||
| 965 | tallColhep | ||||||||||||||||||||||||||||||||
| 966 | tallColket | ||||||||||||||||||||||||||||||||
| 967 | tallCollus | ||||||||||||||||||||||||||||||||
| 968 | tallDottar | ||||||||||||||||||||||||||||||||
| 969 | tallDottis | ||||||||||||||||||||||||||||||||
| 970 | tallKetcen | ||||||||||||||||||||||||||||||||
| 971 | tallKettis | ||||||||||||||||||||||||||||||||
| 972 | tallSigbuc | ||||||||||||||||||||||||||||||||
| 973 | tallSigcen | ||||||||||||||||||||||||||||||||
| 974 | tallSiggar | ||||||||||||||||||||||||||||||||
| 975 | tallSigpam | ||||||||||||||||||||||||||||||||
| 976 | tallSigwut | ||||||||||||||||||||||||||||||||
| 977 | tallSigzap | ||||||||||||||||||||||||||||||||
| 978 | tallTisdot | ||||||||||||||||||||||||||||||||
| 979 | tallTisfas | ||||||||||||||||||||||||||||||||
| 980 | tallTisgar | ||||||||||||||||||||||||||||||||
| 981 | tallTishep | ||||||||||||||||||||||||||||||||
| 982 | tallTisket | ||||||||||||||||||||||||||||||||
| 983 | tallTislus | ||||||||||||||||||||||||||||||||
| 984 | tallTissem | ||||||||||||||||||||||||||||||||
| 985 | tallTistar | ||||||||||||||||||||||||||||||||
| 986 | tallTiswut | ||||||||||||||||||||||||||||||||
| 987 | tallWutcol | ||||||||||||||||||||||||||||||||
| 988 | tallWutdot | ||||||||||||||||||||||||||||||||
| 989 | tallWutket | ||||||||||||||||||||||||||||||||
| 990 | tallWutpat | ||||||||||||||||||||||||||||||||
| 991 | tallWutsig | ||||||||||||||||||||||||||||||||
| 992 | tallZapcol | ||||||||||||||||||||||||||||||||
| 993 | tallZapdot | ||||||||||||||||||||||||||||||||
| 994 | tallZaptis | ||||||||||||||||||||||||||||||||
| 995 | tallZapwut | ||||||||||||||||||||||||||||||||
| 996 | ); | ||||||||||||||||||||||||||||||||
| 997 | 7 | $baseLintInstance{backdentedRule} = \%tallBackdentRule; | |||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||
| 999 | 7 | $baseLintInstance{ruleDB} = []; | |||||||||||||||||||||||||||||||
| 1000 | 7 | $baseLintInstance{symbolDB} = []; | |||||||||||||||||||||||||||||||
| 1001 | 7 | $baseLintInstance{symbolReverseDB} = {}; | |||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||
| 1003 | 7 | testStyleCensus(\%baseLintInstance); | |||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||
| 1005 | 12 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 1006 | 12 | my ( $class, $config ) = (@_); | |||||||||||||||||||||||||||||||
| 1007 | 12 | my $fileName = $config->{fileName}; | |||||||||||||||||||||||||||||||
| 1008 | 12 | my %lint = (%{$config}, %baseLintInstance); | |||||||||||||||||||||||||||||||
| 1009 | 12 | my $lintInstance = \%lint; | |||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||
| 1011 | 12 | bless $lintInstance, "MarpaX::Hoonlint"; | |||||||||||||||||||||||||||||||
| 1012 | 12 | my $policies = $lintInstance->{policies}; | |||||||||||||||||||||||||||||||
| 1013 | 12 | my $pSource = $lintInstance->{pHoonSource}; | |||||||||||||||||||||||||||||||
| 1014 | 12 | my $parser = $lintInstance->{parser}; | |||||||||||||||||||||||||||||||
| 1015 | 12 | $lintInstance->{topicLines} = {}; | |||||||||||||||||||||||||||||||
| 1016 | 12 | $lintInstance->{mistakeLines} = {}; | |||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||
| 1018 | 12 | my @data = (); | |||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||
| 1020 | 12 | $parser->read($pSource); | |||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||
| 1022 | 12 | $MarpaX::Hoonlint::recce = $parser->rawRecce(); | |||||||||||||||||||||||||||||||
| 1023 | 12 | $lintInstance->{recce} = $MarpaX::Hoonlint::recce; | |||||||||||||||||||||||||||||||
| 1024 | 12 | $lintInstance->{nodeCount} = 0; | |||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||
| 1026 | 12 | $parser = undef; # free up memory | |||||||||||||||||||||||||||||||
| 1027 | 12 | my $astRef = $MarpaX::Hoonlint::recce->value($lintInstance); | |||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||
| 1029 | 12 | my @lineToPos = ( -1, 0 ); | |||||||||||||||||||||||||||||||
| 1030 | { | ||||||||||||||||||||||||||||||||
| 1031 | 12 | my $lastPos = 0; | |||||||||||||||||||||||||||||||
| 1032 | 12 | LINE: while (1) { | |||||||||||||||||||||||||||||||
| 1033 | 384 | my $newPos = index ${$pSource}, "\n", $lastPos; | |||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||
| 1035 | # say $newPos; | ||||||||||||||||||||||||||||||||
| 1036 | 384 | ▶ | last LINE if $newPos < 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1037 | 372 | $lastPos = $newPos + 1; | |||||||||||||||||||||||||||||||
| 1038 | 372 | push @lineToPos, $lastPos; | |||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||
| 1041 | 12 | $lintInstance->{lineToPos} = \@lineToPos; | |||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||
| 1043 | # say STDERR join " ", __FILE__, __LINE__, Data::Dumper::Dumper(\@lineToPos); | ||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||
| 1045 | 12 | ▶ | die "Parse failed" if not $astRef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||
| 1047 | # local $Data::Dumper::Deepcopy = 1; | ||||||||||||||||||||||||||||||||
| 1048 | # local $Data::Dumper::Terse = 1; | ||||||||||||||||||||||||||||||||
| 1049 | # local $Data::Dumper::Maxdepth = 3; | ||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||
| 1051 | 12 | my $astValue = ${$astRef}; | |||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||
| 1053 | 12 | for my $policyShortName ( keys %{$policies} ) { | |||||||||||||||||||||||||||||||
| 1054 | 12 | my $policyFullName = $policies->{$policyShortName}; | |||||||||||||||||||||||||||||||
| 1055 | 12 | my $constructor = UNIVERSAL::can( $policyFullName, 'new' ); | |||||||||||||||||||||||||||||||
| 1056 | 12 | my $policy = $constructor->( $policyFullName, $lintInstance ); | |||||||||||||||||||||||||||||||
| 1057 | 12 | $policy->{shortName} = $policyShortName; | |||||||||||||||||||||||||||||||
| 1058 | 12 | $policy->{fullName} = $policyFullName; | |||||||||||||||||||||||||||||||
| 1059 | 12 | $policy->{perNode} = {}; | |||||||||||||||||||||||||||||||
| 1060 | 12 | $policy->validate($astValue); | |||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||
| 1063 | 12 | print $lintInstance->contextDisplay(); | |||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||
| 1065 | 12 | my $unusedSuppressions = $lintInstance->{unusedSuppressions}; | |||||||||||||||||||||||||||||||
| 1066 | 12 | for my $lc ( keys %{$unusedSuppressions} ) { | |||||||||||||||||||||||||||||||
| 1067 | 6 | my $perLCSuppressions = $unusedSuppressions->{$lc}; | |||||||||||||||||||||||||||||||
| 1068 | 6 | for my $policy ( | |||||||||||||||||||||||||||||||
| 1069 | 6 | grep { $perLCSuppressions->{$_} } | |||||||||||||||||||||||||||||||
| 1070 | 6 | keys %{$perLCSuppressions} | |||||||||||||||||||||||||||||||
| 1071 | ) | ||||||||||||||||||||||||||||||||
| 1072 | { | ||||||||||||||||||||||||||||||||
| 1073 | 6 | my $perPolicySuppressions = $perLCSuppressions->{$policy}; | |||||||||||||||||||||||||||||||
| 1074 | 6 | for my $subpolicy ( | |||||||||||||||||||||||||||||||
| 1075 | 6 | grep { $perPolicySuppressions->{$_} } | |||||||||||||||||||||||||||||||
| 1076 | 6 | keys %{$perPolicySuppressions} | |||||||||||||||||||||||||||||||
| 1077 | ) | ||||||||||||||||||||||||||||||||
| 1078 | { | ||||||||||||||||||||||||||||||||
| 1079 | 0 | say "Unused suppression: $fileName $lc $policy $subpolicy"; | |||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||
| 1084 | 12 | return $lintInstance; | |||||||||||||||||||||||||||||||
| 1085 | } | ||||||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||||||
| 1087 | 7 | 1; | |||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||
| 1089 | # vim: expandtab shiftwidth=4: | ||||||||||||||||||||||||||||||||