| 1 | # Copyright (c) 2006 Hans Jeuken. All rights reserved. | ||||||||||||||||||||||||||||
| 2 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 3 | # modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Syntax::Highlight::Engine::Kate::Template; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | our $VERSION = '0.14'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Carp qw(cluck); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | #my $regchars = '\\^.$|()[]*+?'; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub new { | ||||||||||||||||||||||||||||
| 16 | 232 | ▶ | my $proto = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 232 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 18 | 232 | my %args = (@_); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 232 | my $debug = delete $args{'debug'}; | |||||||||||||||||||||||||||
| 21 | 232 | ▶ | unless (defined($debug)) { $debug = 0 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 232 | my $substitutions = delete $args{'substitutions'}; | |||||||||||||||||||||||||||
| 23 | 232 | ▶ | unless (defined($substitutions)) { $substitutions = {} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 232 | my $formattable = delete $args{'format_table'}; | |||||||||||||||||||||||||||
| 25 | 232 | ▶ | unless (defined($formattable)) { $formattable = {} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 232 | my $engine = delete $args{'engine'}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 232 | my $self = {}; | |||||||||||||||||||||||||||
| 29 | $self->{'attributes'} = {}, | ||||||||||||||||||||||||||||
| 30 | 232 | $self->{'captured'} = []; | |||||||||||||||||||||||||||
| 31 | 232 | $self->{'contextdata'} = {}; | |||||||||||||||||||||||||||
| 32 | 232 | $self->{'basecontext'} = ''; | |||||||||||||||||||||||||||
| 33 | 232 | $self->{'debug'} = $debug; | |||||||||||||||||||||||||||
| 34 | 232 | $self->{'deliminators'} = ''; | |||||||||||||||||||||||||||
| 35 | 232 | $self->{'engine'} = ''; | |||||||||||||||||||||||||||
| 36 | 232 | $self->{'format_table'} = $formattable; | |||||||||||||||||||||||||||
| 37 | 232 | $self->{'keywordscase'} = 1; | |||||||||||||||||||||||||||
| 38 | 232 | $self->{'lastchar'} = ''; | |||||||||||||||||||||||||||
| 39 | 232 | $self->{'linesegment'} = ''; | |||||||||||||||||||||||||||
| 40 | 232 | $self->{'lists'} = {}; | |||||||||||||||||||||||||||
| 41 | 232 | $self->{'linestart'} = 1; | |||||||||||||||||||||||||||
| 42 | 232 | $self->{'out'} = []; | |||||||||||||||||||||||||||
| 43 | 232 | $self->{'plugins'} = {}; | |||||||||||||||||||||||||||
| 44 | 232 | $self->{'snippet'} = ''; | |||||||||||||||||||||||||||
| 45 | 232 | $self->{'snippetattribute'} = ''; | |||||||||||||||||||||||||||
| 46 | 232 | $self->{'stack'} = []; | |||||||||||||||||||||||||||
| 47 | 232 | $self->{'substitutions'} = $substitutions; | |||||||||||||||||||||||||||
| 48 | 232 | bless ($self, $class); | |||||||||||||||||||||||||||
| 49 | 232 | ▶ | unless (defined $engine) { $engine = $self }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 232 | $self->engine($engine); | |||||||||||||||||||||||||||
| 51 | 232 | $self->initialize; | |||||||||||||||||||||||||||
| 52 | 232 | return $self; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub attributes { | ||||||||||||||||||||||||||||
| 56 | 219 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 219 | ▶ | if (@_) { $self->{'attributes'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 219 | return $self->{'attributes'}; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | sub basecontext { | ||||||||||||||||||||||||||||
| 62 | 333 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
basecontext: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 63 | 333 | ▶ | if (@_) { $self->{'basecontext'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 333 | return $self->{'basecontext'}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub captured { | ||||||||||||||||||||||||||||
| 68 | 13174 | ▶ | my ($self, $c) = @_; | ||||||||||||||||||||||||||
|
Subroutine
captured: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 69 | 13174 | ▶ | if (defined($c)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 13174 | my $t = $self->engine->stackTop; | |||||||||||||||||||||||||||
| 71 | 13174 | my $n = 0; | |||||||||||||||||||||||||||
| 72 | 13174 | my @o = (); | |||||||||||||||||||||||||||
| 73 | 13174 | ▶ | while (defined($c->[$n])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 1324 | push @o, $c->[$n]; | |||||||||||||||||||||||||||
| 75 | 1324 | $n ++; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 13174 | ▶ | if (@o) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 1200 | $t->[2] = \@o; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub capturedGet { | ||||||||||||||||||||||||||||
| 84 | 5334 | ▶ | my ($self, $num) = @_; | ||||||||||||||||||||||||||
|
Subroutine
capturedGet: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 5334 | my $s = $self->engine->{stack}; | |||||||||||||||||||||||||||
| 86 | 5334 | ▶ | if (defined($s->[1])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 5334 | my $c = $s->[1]->[2]; | |||||||||||||||||||||||||||
| 88 | 5334 | $num --; | |||||||||||||||||||||||||||
| 89 | 5334 | ▶ | if (defined($c)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 5334 | ▶ | if (defined($c->[$num])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 5334 | my $r = $c->[$num]; | |||||||||||||||||||||||||||
| 92 | 5334 | return $r; | |||||||||||||||||||||||||||
| 93 | } else { | ||||||||||||||||||||||||||||
| 94 | 1 | warn "capture number $num not defined"; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | } else { | ||||||||||||||||||||||||||||
| 97 | 1 | warn "dynamic substitution is called for but nothing to substitute\n"; | |||||||||||||||||||||||||||
| 98 | 1 | return undef; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | } else { | ||||||||||||||||||||||||||||
| 101 | 1 | warn "no parent context to take captures from"; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | #sub captured { | ||||||||||||||||||||||||||||
| 106 | # my $self = shift; | ||||||||||||||||||||||||||||
| 107 | # if (@_) { | ||||||||||||||||||||||||||||
| 108 | # $self->{'captured'} = shift; | ||||||||||||||||||||||||||||
| 109 | ## print Dumper($self->{'captured'}); | ||||||||||||||||||||||||||||
| 110 | # }; | ||||||||||||||||||||||||||||
| 111 | # return $self->{'captured'} | ||||||||||||||||||||||||||||
| 112 | ## my ($self, $c) = @_; | ||||||||||||||||||||||||||||
| 113 | ## if (defined($c)) { | ||||||||||||||||||||||||||||
| 114 | ## my $t = $self->engine->stackTop; | ||||||||||||||||||||||||||||
| 115 | ## my $n = 0; | ||||||||||||||||||||||||||||
| 116 | ## my @o = (); | ||||||||||||||||||||||||||||
| 117 | ## while (defined($c->[$n])) { | ||||||||||||||||||||||||||||
| 118 | ## push @o, $c->[$n]; | ||||||||||||||||||||||||||||
| 119 | ## $n ++; | ||||||||||||||||||||||||||||
| 120 | ## } | ||||||||||||||||||||||||||||
| 121 | ## if (@o) { | ||||||||||||||||||||||||||||
| 122 | ## $t->[2] = \@o; | ||||||||||||||||||||||||||||
| 123 | ## } | ||||||||||||||||||||||||||||
| 124 | ## }; | ||||||||||||||||||||||||||||
| 125 | #} | ||||||||||||||||||||||||||||
| 126 | # | ||||||||||||||||||||||||||||
| 127 | #sub capturedGet { | ||||||||||||||||||||||||||||
| 128 | # my ($self, $num) = @_; | ||||||||||||||||||||||||||||
| 129 | # my $s = $self->captured; | ||||||||||||||||||||||||||||
| 130 | # if (defined $s) { | ||||||||||||||||||||||||||||
| 131 | # $num --; | ||||||||||||||||||||||||||||
| 132 | # if (defined($s->[$num])) { | ||||||||||||||||||||||||||||
| 133 | # return $s->[$num]; | ||||||||||||||||||||||||||||
| 134 | # } else { | ||||||||||||||||||||||||||||
| 135 | # $self->logwarning("capture number $num not defined"); | ||||||||||||||||||||||||||||
| 136 | # } | ||||||||||||||||||||||||||||
| 137 | # } else { | ||||||||||||||||||||||||||||
| 138 | # $self->logwarning("dynamic substitution is called for but nothing to substitute"); | ||||||||||||||||||||||||||||
| 139 | # return undef; | ||||||||||||||||||||||||||||
| 140 | # } | ||||||||||||||||||||||||||||
| 141 | #} | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | sub capturedParse { | ||||||||||||||||||||||||||||
| 144 | 5334 | ▶ | my ($self, $string, $mode) = @_; | ||||||||||||||||||||||||||
|
Subroutine
capturedParse: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 145 | 5334 | my $s = ''; | |||||||||||||||||||||||||||
| 146 | 5334 | ▶ | if (defined($mode)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 35 | ▶ | if ($string =~ s/^(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 35 | $s = $self->capturedGet($1); | |||||||||||||||||||||||||||
| 149 | 35 | ▶ | if ($string ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 1 | $self->logwarning("character class is longer then 1 character, ignoring the rest"); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | } else { | ||||||||||||||||||||||||||||
| 154 | 5300 | ▶ | while ($string ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 15739 | ▶ | if ($string =~ s/^([^\%]*)\%(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 5300 | my $r = $self->capturedGet($2); | |||||||||||||||||||||||||||
| 157 | 5300 | ▶ | if ($r ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 5300 | $s = $s . $1 . $r | |||||||||||||||||||||||||||
| 159 | } else { | ||||||||||||||||||||||||||||
| 160 | 1 | $s = $s . $1 . '%' . $2; | |||||||||||||||||||||||||||
| 161 | 1 | $self->logwarning("target is an empty string"); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||
| 164 | 10440 | $string =~ s/^(.)//; | |||||||||||||||||||||||||||
| 165 | 10440 | $s = "$s$1"; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 5334 | return $s; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | sub column { | ||||||||||||||||||||||||||||
| 173 | 285 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 174 | 285 | return length($self->{linesegment}); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | sub contextdata { | ||||||||||||||||||||||||||||
| 178 | 219 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
contextdata: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 179 | 219 | ▶ | if (@_) { $self->{'contextdata'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 219 | return $self->{'contextdata'}; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | sub contextInfo { | ||||||||||||||||||||||||||||
| 184 | 696216 | ▶ | my ($self, $context, $item) = @_; | ||||||||||||||||||||||||||
|
Subroutine
contextInfo: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 696216 | ▶ | if (exists $self->{contextdata}->{$context}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 696216 | my $c = $self->{contextdata}->{$context}; | |||||||||||||||||||||||||||
| 187 | 696216 | ▶ | if (exists $c->{$item}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 506856 | return $c->{$item} | |||||||||||||||||||||||||||
| 189 | } else { | ||||||||||||||||||||||||||||
| 190 | 189361 | return undef; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||
| 193 | 1 | $self->logwarning("undefined context '$context'"); | |||||||||||||||||||||||||||
| 194 | 1 | return undef; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | sub contextParse { | ||||||||||||||||||||||||||||
| 199 | 45696 | ▶ | my ($self, $plug, $context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
contextParse: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 45696 | ▶ | if ($context =~ /^#pop/i) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 201 | 7682 | ▶ | while ($context =~ s/#pop//i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 9608 | $self->stackPull; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | } elsif ($context =~ /^#stay/i) { | ||||||||||||||||||||||||||||
| 205 | #don't do anything | ||||||||||||||||||||||||||||
| 206 | } elsif ($context =~ /^##(.+)/) { | ||||||||||||||||||||||||||||
| 207 | 7 | my $new = $self->pluginGet($1); | |||||||||||||||||||||||||||
| 208 | 7 | $self->stackPush([$new, $new->{basecontext}]); | |||||||||||||||||||||||||||
| 209 | } else { | ||||||||||||||||||||||||||||
| 210 | 9851 | $self->stackPush([$plug, $context]); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | sub debug { | ||||||||||||||||||||||||||||
| 215 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
debug: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 1 | ▶ | if (@_) { $self->{'debug'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 1 | return $self->{'debug'}; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | sub debugTest { | ||||||||||||||||||||||||||||
| 221 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
debugTest: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 222 | 1 | ▶ | if (@_) { $self->{'debugtest'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 1 | return $self->{'debugtest'}; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | sub deliminators { | ||||||||||||||||||||||||||||
| 227 | 219 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
deliminators: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 228 | 219 | ▶ | if (@_) { $self->{'deliminators'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 219 | return $self->{'deliminators'}; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | sub engine { | ||||||||||||||||||||||||||||
| 233 | 255435 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
engine: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 234 | 255435 | ▶ | if (@_) { $self->{'engine'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 255435 | return $self->{'engine'}; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | sub firstnonspace { | ||||||||||||||||||||||||||||
| 240 | 235 | ▶ | my ($self, $string) = @_; | ||||||||||||||||||||||||||
|
Subroutine
firstnonspace: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 241 | 235 | my $line = $self->{linesegment}; | |||||||||||||||||||||||||||
| 242 | 235 | ▶ | if (($line =~ /^\s*$/) and ($string =~ /^[^\s]/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /^\s*$/ and $string =~ /^[^\s]/
MC/DC50%1/2
$line =~ /^\s*$/ and $string =~ /^[^\s]/
$line =~ /^\s*$/
$string =~ /^[^\s]/
Truth table66%2/3
A and B
A= $line =~ /^\s*$/B= $string =~ /^[^\s]/
| |||||||||||||||||||||||||||||
| 243 | 197 | return 1 | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | 39 | return '' | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | sub formatTable { | ||||||||||||||||||||||||||||
| 249 | 55852 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
formatTable: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 55852 | ▶ | if (@_) { $self->{'format_table'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 55852 | return $self->{'format_table'}; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | sub highlight { | ||||||||||||||||||||||||||||
| 255 | 109 | ▶ | my ($self, $text) = @_; | ||||||||||||||||||||||||||
|
Subroutine
highlight: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 256 | 109 | $self->snippet(''); | |||||||||||||||||||||||||||
| 257 | 109 | my $out = $self->{out}; | |||||||||||||||||||||||||||
| 258 | 109 | @$out = (); | |||||||||||||||||||||||||||
| 259 | 109 | ▶ | while ($text ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 222996 | my $top = $self->stackTop; | |||||||||||||||||||||||||||
| 261 | 222996 | ▶ | if (defined($top)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 222990 | my ($plug, $context) = @$top; | |||||||||||||||||||||||||||
| 263 | 222990 | ▶ | if ($text =~ s/^(\n)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 11829 | $self->snippetForce; | |||||||||||||||||||||||||||
| 265 | 11829 | my $e = $plug->contextInfo($context, 'lineending'); | |||||||||||||||||||||||||||
| 266 | 11829 | ▶ | if (defined($e)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 1646 | $self->contextParse($plug, $e) | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | 11829 | my $attr = $plug->{attributes}->{$plug->contextInfo($context, 'attribute')}; | |||||||||||||||||||||||||||
| 270 | 11829 | $self->snippetParse($1, $attr); | |||||||||||||||||||||||||||
| 271 | 11829 | $self->snippetForce; | |||||||||||||||||||||||||||
| 272 | 11829 | $self->{linesegment} = ''; | |||||||||||||||||||||||||||
| 273 | 11829 | my $b = $plug->contextInfo($context, 'linebeginning'); | |||||||||||||||||||||||||||
| 274 | 11829 | ▶ | if (defined($b)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 1 | $self->contextParse($plug, $b) | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||
| 278 | 211162 | my $sub = $plug->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 279 | 211162 | my $result = &$sub($plug, \$text); | |||||||||||||||||||||||||||
| 280 | 211162 | ▶ | unless($result) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 168787 | my $f = $plug->contextInfo($context, 'fallthrough'); | |||||||||||||||||||||||||||
| 282 | 168787 | ▶ | if (defined($f)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 1438 | $self->contextParse($plug, $f); | |||||||||||||||||||||||||||
| 284 | } else { | ||||||||||||||||||||||||||||
| 285 | 167350 | $text =~ s/^(.)//; | |||||||||||||||||||||||||||
| 286 | 167350 | my $attr = $plug->{attributes}->{$plug->contextInfo($context, 'attribute')}; | |||||||||||||||||||||||||||
| 287 | 167350 | $self->snippetParse($1, $attr); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||
| 292 | 7 | push @$out, length($text), 'Normal'; | |||||||||||||||||||||||||||
| 293 | 7 | $text = ''; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 109 | $self->snippetForce; | |||||||||||||||||||||||||||
| 297 | 109 | return @$out; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | sub highlightText { | ||||||||||||||||||||||||||||
| 301 | 109 | ▶ | my ($self, $text) = @_; | ||||||||||||||||||||||||||
|
Subroutine
highlightText: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 302 | 109 | my $res = ''; | |||||||||||||||||||||||||||
| 303 | 109 | my @hl = $self->highlight($text); | |||||||||||||||||||||||||||
| 304 | 109 | ▶ | while (@hl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 55852 | my $f = shift @hl; | |||||||||||||||||||||||||||
| 306 | 55852 | my $t = shift @hl; | |||||||||||||||||||||||||||
| 307 | 55852 | ▶ | unless (defined($t)) { $t = 'Normal' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 55852 | my $s = $self->{substitutions}; | |||||||||||||||||||||||||||
| 309 | 55852 | my $rr = ''; | |||||||||||||||||||||||||||
| 310 | 55852 | ▶ | while ($f ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 324031 | my $k = substr($f , 0, 1); | |||||||||||||||||||||||||||
| 312 | 324031 | $f = substr($f, 1, length($f) -1); | |||||||||||||||||||||||||||
| 313 | 324031 | ▶ | if (exists $s->{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 9735 | $rr = $rr . $s->{$k} | |||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||
| 316 | 314296 | $rr = $rr . $k; | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 55851 | my $rt = $self->formatTable; | |||||||||||||||||||||||||||
| 320 | 55851 | ▶ | if (exists $rt->{$t}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 55851 | my $o = $rt->{$t}; | |||||||||||||||||||||||||||
| 322 | 55851 | $res = $res . $o->[0] . $rr . $o->[1]; | |||||||||||||||||||||||||||
| 323 | } else { | ||||||||||||||||||||||||||||
| 324 | 0 | $res = $res . $rr; | |||||||||||||||||||||||||||
| 325 | 0 | $self->logwarning("undefined format tag '$t'"); | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | 108 | return $res; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | sub includePlugin { | ||||||||||||||||||||||||||||
| 332 | 22906 | ▶ | my ($self, $language, $text) = @_; | ||||||||||||||||||||||||||
|
Subroutine
includePlugin: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||
| 333 | 22906 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 334 | 22906 | my $plug = $eng->pluginGet($language); | |||||||||||||||||||||||||||
| 335 | 22906 | ▶ | if (defined($plug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 22906 | my $context = $plug->{basecontext}; | |||||||||||||||||||||||||||
| 337 | 22906 | my $call = $plug->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 338 | 22906 | ▶ | if (defined($call)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 22906 | return &$call($plug, $text); | |||||||||||||||||||||||||||
| 340 | } else { | ||||||||||||||||||||||||||||
| 341 | 0 | $self->logwarning("cannot find callback for context '$context'"); | |||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | 0 | return 0; | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | sub includeRules { | ||||||||||||||||||||||||||||
| 348 | 81937 | ▶ | my ($self, $context, $text) = @_; | ||||||||||||||||||||||||||
|
Subroutine
includeRules: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||
| 349 | 81937 | my $call = $self->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 350 | 81937 | ▶ | if (defined($call)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 81937 | return &$call($self, $text); | |||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||
| 353 | 0 | $self->logwarning("cannot find callback for context '$context'"); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | 0 | return 0; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | sub initialize { | ||||||||||||||||||||||||||||
| 359 | 436 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 360 | 436 | ▶ | if ($self->engine eq $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 260 | $self->stack([[$self, $self->{basecontext}]]); | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | sub keywordscase { | ||||||||||||||||||||||||||||
| 366 | 218 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
keywordscase: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 367 | 218 | ▶ | if (@_) { $self->{'keywordscase'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 218 | return $self->{'keywordscase'} | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | sub languagePlug { | ||||||||||||||||||||||||||||
| 372 | 21 | ▶ | my ($cw, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
languagePlug: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 373 | 21 | my %numb = ( | |||||||||||||||||||||||||||
| 374 | '1' => 'One', | ||||||||||||||||||||||||||||
| 375 | '2' => 'Two', | ||||||||||||||||||||||||||||
| 376 | '3' => 'Three', | ||||||||||||||||||||||||||||
| 377 | '4' => 'Four', | ||||||||||||||||||||||||||||
| 378 | '5' => 'Five', | ||||||||||||||||||||||||||||
| 379 | '6' => 'Six', | ||||||||||||||||||||||||||||
| 380 | '7' => 'Seven', | ||||||||||||||||||||||||||||
| 381 | '8' => 'Eight', | ||||||||||||||||||||||||||||
| 382 | '9' => 'Nine', | ||||||||||||||||||||||||||||
| 383 | '0' => 'Zero', | ||||||||||||||||||||||||||||
| 384 | ); | ||||||||||||||||||||||||||||
| 385 | 21 | ▶ | if ($name =~ s/^(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 0 | $name = $numb{$1} . $name; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | 21 | $name =~ s/\.//; | |||||||||||||||||||||||||||
| 389 | 21 | $name =~ s/\+/plus/g; | |||||||||||||||||||||||||||
| 390 | 21 | $name =~ s/\-/minus/g; | |||||||||||||||||||||||||||
| 391 | 21 | $name =~ s/#/dash/g; | |||||||||||||||||||||||||||
| 392 | 21 | $name =~ s/[^0-9a-zA-Z]/_/g; | |||||||||||||||||||||||||||
| 393 | 21 | $name =~ s/__/_/g; | |||||||||||||||||||||||||||
| 394 | 21 | $name =~ s/_$//; | |||||||||||||||||||||||||||
| 395 | 21 | $name = ucfirst($name); | |||||||||||||||||||||||||||
| 396 | 21 | return $name; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | sub lastchar { | ||||||||||||||||||||||||||||
| 400 | 838627 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
lastchar: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 401 | 838627 | my $l = $self->{linesegment}; | |||||||||||||||||||||||||||
| 402 | 838627 | ▶ | if ($l eq '') { return "\n" } #last character was a newline | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | 814504 | return substr($l, length($l) - 1, 1); | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | sub lastcharDeliminator { | ||||||||||||||||||||||||||||
| 407 | 566144 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
lastcharDeliminator: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 408 | 566144 | my $deliminators = '\s|\~|\!|\%|\^|\&|\*|\+|\(|\)|-|=|\{|\}|\[|\]|:|;|<|>|,|\\|\||\.|\?|\/'; | |||||||||||||||||||||||||||
| 409 | 566144 | ▶ | if ($self->linestart or ($self->lastchar =~ /$deliminators/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->linestart or $self->lastchar =~ /$deliminators/
MC/DC100%2/2
$self->linestart or $self->lastchar =~ /$deliminators/
$self->linestart
$self->lastchar =~ /$deliminators/
Truth table100%3/3
A or B
A= $self->linestartB= $self->lastchar =~ /$deliminators/
| |||||||||||||||||||||||||||||
| 410 | 310033 | return 1; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | 256111 | return ''; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | sub linesegment { | ||||||||||||||||||||||||||||
| 416 | 860067 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
linesegment: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 417 | 860067 | ▶ | if (@_) { $self->{'linesegment'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 860067 | return $self->{'linesegment'}; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | sub linestart { | ||||||||||||||||||||||||||||
| 422 | 860067 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
linestart: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 423 | 860067 | ▶ | if ($self->linesegment eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 48445 | return 1 | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 811622 | return ''; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | sub lists { | ||||||||||||||||||||||||||||
| 430 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
lists: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (@_) { $self->{'lists'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 0 | return $self->{'lists'} | |||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | sub out { | ||||||||||||||||||||||||||||
| 436 | 116 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
out: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 437 | 116 | ▶ | if (@_) { $self->{'out'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 116 | return $self->{'out'}; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | sub listAdd { | ||||||||||||||||||||||||||||
| 442 | 670 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
listAdd: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 443 | 670 | my $listname = shift; | |||||||||||||||||||||||||||
| 444 | 670 | my $lst = $self->{lists}; | |||||||||||||||||||||||||||
| 445 | 670 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | 669 | my @l = reverse sort @_; | |||||||||||||||||||||||||||
| 447 | 669 | $lst->{$listname} = \@l; | |||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||
| 449 | 1 | $lst->{$listname} = []; | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | sub logwarning { | ||||||||||||||||||||||||||||
| 454 | 2 | ▶ | my ($self, $warning) = @_; | ||||||||||||||||||||||||||
|
Subroutine
logwarning: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 455 | 2 | my $top = $self->engine->stackTop; | |||||||||||||||||||||||||||
| 456 | 2 | ▶ | if (defined $top) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | 0 | my $lang = $top->[0]->language; | |||||||||||||||||||||||||||
| 458 | 0 | my $context = $top->[1]; | |||||||||||||||||||||||||||
| 459 | 0 | $warning = "$warning\n Language => $lang, Context => $context\n"; | |||||||||||||||||||||||||||
| 460 | } else { | ||||||||||||||||||||||||||||
| 461 | 2 | $warning = "$warning\n STACK IS EMPTY: PANIC\n" | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | 2 | cluck($warning); | |||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | sub parseResult { | ||||||||||||||||||||||||||||
| 467 | 42702 | ▶ | my ($self, $text, $string, $lahead, $column, $fnspace, $context, $attr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parseResult: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 468 | 42702 | my $eng = $self->engine; | |||||||||||||||||||||||||||
| 469 | 42702 | ▶ | if ($fnspace) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 234 | ▶ | unless ($eng->firstnonspace($$text)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | 38 | return '' | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | 42664 | ▶ | if (defined($column)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 284 | ▶ | if ($column ne $eng->column) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 476 | 51 | return ''; | |||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | 42613 | ▶ | unless ($lahead) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 480 | 41376 | $$text = substr($$text, length($string)); | |||||||||||||||||||||||||||
| 481 | 41376 | my $r; | |||||||||||||||||||||||||||
| 482 | 41376 | ▶ | unless (defined($attr)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 8592 | my $t = $eng->stackTop; | |||||||||||||||||||||||||||
| 484 | 8592 | my ($plug, $ctext) = @$t; | |||||||||||||||||||||||||||
| 485 | 8592 | $r = $plug->{attributes}->{$plug->contextInfo($ctext, 'attribute')}; | |||||||||||||||||||||||||||
| 486 | } else { | ||||||||||||||||||||||||||||
| 487 | 32784 | $r = $self->{attributes}->{$attr}; | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | 41376 | $eng->snippetParse($string, $r); | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | 42613 | $eng->contextParse($self, $context); | |||||||||||||||||||||||||||
| 492 | 42613 | return 1 | |||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | sub pluginGet { | ||||||||||||||||||||||||||||
| 496 | 23028 | ▶ | my ($self, $language) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pluginGet: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 497 | 23028 | my $plugs = $self->{'plugins'}; | |||||||||||||||||||||||||||
| 498 | 23028 | ▶ | unless (exists($plugs->{$language})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | 90 | my $lang_plug = $self->languagePlug($language); | |||||||||||||||||||||||||||
| 500 | 90 | my $modname = 'Syntax::Highlight::Engine::Kate::'; | |||||||||||||||||||||||||||
| 501 | 90 | ▶ | if (defined $lang_plug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 88 | $modname .= $lang_plug; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | 90 | ▶ | unless (defined($modname)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 505 | 0 | $self->logwarning("no valid module found for language '$language'"); | |||||||||||||||||||||||||||
| 506 | 0 | return undef; | |||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | 90 | my $plug; | |||||||||||||||||||||||||||
| 509 | 5 | ▶ | eval "use $modname; \$plug = new $modname(engine => \$self);"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 510 | 90 | ▶ | if (defined($plug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 511 | 88 | $plugs->{$language} = $plug; | |||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||
| 513 | 2 | $self->logwarning("cannot create plugin for language '$language'\n--------------\n$@"); | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | 23028 | ▶ | if (exists($plugs->{$language})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 517 | 23026 | return $plugs->{$language}; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | 2 | return undef; | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | sub reset { | ||||||||||||||||||||||||||||
| 523 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 524 | 0 | $self->stack([[$self, $self->{basecontext}]]); | |||||||||||||||||||||||||||
| 525 | 0 | $self->out([]); | |||||||||||||||||||||||||||
| 526 | 0 | $self->snippet(''); | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | sub snippet { | ||||||||||||||||||||||||||||
| 530 | 119878 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
snippet: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 531 | 119878 | ▶ | if (@_) { $self->{'snippet'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 119878 | return $self->{'snippet'}; | |||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | sub snippetAppend { | ||||||||||||||||||||||||||||
| 536 | 220553 | ▶ | my ($self, $ch) = @_; | ||||||||||||||||||||||||||
|
Subroutine
snippetAppend: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 220553 | ▶ | return if not defined $ch; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 539 | 220539 | $self->{'snippet'} = $self->{'snippet'} . $ch; | |||||||||||||||||||||||||||
| 540 | 220539 | ▶ | if ($ch ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 541 | 220539 | $self->{linesegment} = $self->{linesegment} . $ch; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | 220539 | return; | |||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | sub snippetAttribute { | ||||||||||||||||||||||||||||
| 547 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
snippetAttribute: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if (@_) { $self->{'snippetattribute'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | 0 | return $self->{'snippetattribute'}; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | sub snippetForce { | ||||||||||||||||||||||||||||
| 553 | 63809 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
snippetForce: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 554 | 63809 | my $parse = $self->snippet; | |||||||||||||||||||||||||||
| 555 | 63809 | ▶ | if ($parse ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 556 | 55845 | my $out = $self->{'out'}; | |||||||||||||||||||||||||||
| 557 | 55845 | push(@$out, $parse, $self->{snippetattribute}); | |||||||||||||||||||||||||||
| 558 | 55845 | $self->snippet(''); | |||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | sub snippetParse { | ||||||||||||||||||||||||||||
| 563 | 220553 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
snippetParse: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 564 | 220553 | my $snip = shift; | |||||||||||||||||||||||||||
| 565 | 220553 | my $attr = shift; | |||||||||||||||||||||||||||
| 566 | 220553 | ▶ | if ((defined $attr) and ($attr ne $self->{snippetattribute})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $attr and $attr ne $self->{"snippetattribute"}
MC/DC100%2/2
defined $attr and $attr ne $self->{"snippetattribute"}
defined $attr
$attr ne $self->{"snippetattribute"}
Truth table100%3/3
A and B
A= defined $attrB= $attr ne $self->{"snippetattribute"}
| |||||||||||||||||||||||||||||
| 567 | 40045 | $self->snippetForce; | |||||||||||||||||||||||||||
| 568 | 40045 | $self->{snippetattribute} = $attr; | |||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||
| 570 | 220553 | $self->snippetAppend($snip); | |||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | sub stack { | ||||||||||||||||||||||||||||
| 574 | 376 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
stack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 575 | 376 | ▶ | if (@_) { $self->{'stack'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 376 | return $self->{'stack'}; | |||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | sub stackPush { | ||||||||||||||||||||||||||||
| 580 | 9856 | ▶ | my ($self, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
stackPush: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 581 | 9856 | my $stack = $self->{stack}; | |||||||||||||||||||||||||||
| 582 | 9856 | unshift(@$stack, $val); | |||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | sub stackPull { | ||||||||||||||||||||||||||||
| 586 | 9607 | ▶ | my ($self, $val) = @_; | ||||||||||||||||||||||||||
|
Subroutine
stackPull: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 587 | 9607 | my $stack = $self->{stack}; | |||||||||||||||||||||||||||
| 588 | 9607 | return shift(@$stack); | |||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | sub stackTop { | ||||||||||||||||||||||||||||
| 592 | 244762 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
stackTop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 593 | 244762 | return $self->{stack}->[0]; | |||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | sub stateCompare { | ||||||||||||||||||||||||||||
| 597 | 0 | ▶ | my ($self, $state) = @_; | ||||||||||||||||||||||||||
|
Subroutine
stateCompare: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 598 | 0 | my $h = [ $self->stateGet ]; | |||||||||||||||||||||||||||
| 599 | 0 | my $equal = 0; | |||||||||||||||||||||||||||
| 600 | 0 | ▶ | if (Dumper($h) eq Dumper($state)) { $equal = 1 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 601 | 0 | return $equal; | |||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | sub stateGet { | ||||||||||||||||||||||||||||
| 605 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
stateGet: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 606 | 0 | my $s = $self->{stack}; | |||||||||||||||||||||||||||
| 607 | 0 | return @$s; | |||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | sub stateSet { | ||||||||||||||||||||||||||||
| 611 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
stateSet: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 612 | 0 | my $s = $self->{stack}; | |||||||||||||||||||||||||||
| 613 | 0 | @$s = (@_); | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | sub substitutions { | ||||||||||||||||||||||||||||
| 617 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
substitutions: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 618 | 0 | ▶ | if (@_) { $self->{'substitutions'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 619 | 0 | return $self->{'substitutions'}; | |||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | sub testAnyChar { | ||||||||||||||||||||||||||||
| 623 | 40969 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testAnyChar: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 624 | 40969 | my $text = shift; | |||||||||||||||||||||||||||
| 625 | 40969 | my $string = shift; | |||||||||||||||||||||||||||
| 626 | 40969 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 627 | 40969 | my $test = substr($$text, 0, 1); | |||||||||||||||||||||||||||
| 628 | 40969 | my $bck = $test; | |||||||||||||||||||||||||||
| 629 | 40969 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 630 | 0 | $string = lc($string); | |||||||||||||||||||||||||||
| 631 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | 40969 | ▶ | if (index($string, $test) > -1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 634 | 5110 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||
| 636 | 35859 | return '' | |||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | sub testDetectChar { | ||||||||||||||||||||||||||||
| 640 | 385776 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testDetectChar: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 641 | 385776 | my $text = shift; | |||||||||||||||||||||||||||
| 642 | 385776 | my $char = shift; | |||||||||||||||||||||||||||
| 643 | 385776 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 644 | 385776 | my $dyn = shift; | |||||||||||||||||||||||||||
| 645 | 385776 | ▶ | if ($dyn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 646 | 34 | $char = $self->capturedParse($char, 1); | |||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||
| 648 | 385776 | my $test = substr($$text, 0, 1); | |||||||||||||||||||||||||||
| 649 | 385776 | my $bck = $test; | |||||||||||||||||||||||||||
| 650 | 385776 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 651 | 0 | $char = lc($char); | |||||||||||||||||||||||||||
| 652 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||
| 654 | 385776 | ▶ | if ($char eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 655 | 9537 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | 376239 | return '' | |||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | sub testDetect2Chars { | ||||||||||||||||||||||||||||
| 661 | 236118 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testDetect2Chars: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 662 | 236118 | my $text = shift; | |||||||||||||||||||||||||||
| 663 | 236118 | my $char = shift; | |||||||||||||||||||||||||||
| 664 | 236118 | my $char1 = shift; | |||||||||||||||||||||||||||
| 665 | 236118 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 666 | 236118 | my $dyn = shift; | |||||||||||||||||||||||||||
| 667 | 236118 | ▶ | if ($dyn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 668 | 0 | $char = $self->capturedParse($char, 1); | |||||||||||||||||||||||||||
| 669 | 0 | $char1 = $self->capturedParse($char1, 1); | |||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | 236118 | my $string = $char . $char1; | |||||||||||||||||||||||||||
| 672 | 236118 | my $test = substr($$text, 0, 2); | |||||||||||||||||||||||||||
| 673 | 236118 | my $bck = $test; | |||||||||||||||||||||||||||
| 674 | 236118 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 675 | 0 | $string = lc($string); | |||||||||||||||||||||||||||
| 676 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | 236118 | ▶ | if ($string eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 679 | 1263 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||
| 681 | 234855 | return '' | |||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | sub testDetectIdentifier { | ||||||||||||||||||||||||||||
| 685 | 29422 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testDetectIdentifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 686 | 29422 | my $text = shift; | |||||||||||||||||||||||||||
| 687 | 29422 | ▶ | if ($$text =~ /^([a-zA-Z_][a-zA-Z0-9_]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 688 | 7405 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||
| 690 | 22017 | return '' | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | sub testDetectSpaces { | ||||||||||||||||||||||||||||
| 694 | 41375 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testDetectSpaces: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 695 | 41375 | my $text = shift; | |||||||||||||||||||||||||||
| 696 | 41375 | ▶ | if ($$text =~ /^([\\040|\\t]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 697 | 955 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||
| 699 | 40420 | return '' | |||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | sub testFloat { | ||||||||||||||||||||||||||||
| 703 | 57829 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testFloat: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 704 | 57829 | my $text = shift; | |||||||||||||||||||||||||||
| 705 | 57829 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 706 | 31956 | ▶ | if ($$text =~ /^((?=\.?\d)\d*(?:\.\d*)?(?:[Ee][+-]?\d+)?)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 707 | 1845 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||
| 710 | 55984 | return '' | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | sub testHlCChar { | ||||||||||||||||||||||||||||
| 714 | 24992 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testHlCChar: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 715 | 24992 | my $text = shift; | |||||||||||||||||||||||||||
| 716 | 24992 | ▶ | if ($$text =~ /^('.')/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 717 | 26 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||
| 719 | 24966 | return '' | |||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | sub testHlCHex { | ||||||||||||||||||||||||||||
| 723 | 39211 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testHlCHex: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 724 | 39211 | my $text = shift; | |||||||||||||||||||||||||||
| 725 | 39211 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 726 | 22158 | ▶ | if ($$text =~ /^(0x[0-9a-fA-F]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 727 | 8 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||
| 730 | 39203 | return '' | |||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | sub testHlCOct { | ||||||||||||||||||||||||||||
| 734 | 33373 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testHlCOct: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 735 | 33373 | my $text = shift; | |||||||||||||||||||||||||||
| 736 | 33373 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 737 | 19928 | ▶ | if ($$text =~ /^(0[0-7]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 738 | 0 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||
| 741 | 33373 | return '' | |||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | sub testHlCStringChar { | ||||||||||||||||||||||||||||
| 745 | 5020 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testHlCStringChar: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 746 | 5020 | my $text = shift; | |||||||||||||||||||||||||||
| 747 | 5020 | ▶ | if ($$text =~ /^(\\[a|b|e|f|n|r|t|v|'|"|\?])/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 748 | 34 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||
| 750 | 4986 | ▶ | if ($$text =~ /^(\\x[0-9a-fA-F][0-9a-fA-F]?)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 751 | 0 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||
| 753 | 4986 | ▶ | if ($$text =~ /^(\\[0-7][0-7]?[0-7]?)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 754 | 0 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||
| 756 | 4986 | return '' | |||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | sub testInt { | ||||||||||||||||||||||||||||
| 760 | 63144 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testInt: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 761 | 63144 | my $text = shift; | |||||||||||||||||||||||||||
| 762 | 63144 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 763 | 33241 | ▶ | if ($$text =~ /^([+-]?\d+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 764 | 314 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||
| 767 | 62830 | return '' | |||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | sub testKeyword { | ||||||||||||||||||||||||||||
| 771 | 372587 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testKeyword: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 772 | 372587 | my $text = shift; | |||||||||||||||||||||||||||
| 773 | 372587 | my $list = shift; | |||||||||||||||||||||||||||
| 774 | 372587 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 775 | 372587 | my $deliminators = $self->{deliminators}; | |||||||||||||||||||||||||||
| 776 | 372587 | ▶ | if (($eng->lastcharDeliminator) and ($$text =~ /^([^$deliminators]+)/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$eng->lastcharDeliminator and $$text =~ /^([^$deliminators]+)/
MC/DC100%2/2
$eng->lastcharDeliminator and $$text =~ /^([^$deliminators]+)/
$eng->lastcharDeliminator
$$text =~ /^([^$deliminators]+)/
Truth table100%3/3
A and B
A= $eng->lastcharDeliminatorB= $$text =~ /^([^$deliminators]+)/
| |||||||||||||||||||||||||||||
| 777 | 72284 | my $match = $1; | |||||||||||||||||||||||||||
| 778 | 72284 | my $l = $self->{lists}->{$list}; | |||||||||||||||||||||||||||
| 779 | 72284 | ▶ | if (defined($l)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 780 | 72284 | my @list = @$l; | |||||||||||||||||||||||||||
| 781 | 72284 | my @rl = (); | |||||||||||||||||||||||||||
| 782 | 72284 | ▶ | unless ($self->{keywordscase}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 783 | 66046 | @rl = grep { (lc($match) eq lc($_)) } @list; | |||||||||||||||||||||||||||
| 784 | } else { | ||||||||||||||||||||||||||||
| 785 | 6238 | @rl = grep { ($match eq $_) } @list; | |||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||
| 787 | 72284 | ▶ | if (@rl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 788 | 5778 | return $self->parseResult($text, $match, @_); | |||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||
| 790 | } else { | ||||||||||||||||||||||||||||
| 791 | 0 | $self->logwarning("list '$list' is not defined, failing test"); | |||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||
| 794 | 366809 | return '' | |||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | sub testLineContinue { | ||||||||||||||||||||||||||||
| 798 | 6210 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testLineContinue: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||
| 799 | 6210 | my $text = shift; | |||||||||||||||||||||||||||
| 800 | 6210 | my $lahead = shift; | |||||||||||||||||||||||||||
| 801 | 6210 | ▶ | if ($lahead) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 802 | 0 | ▶ | if ($$text =~ /^\\\n/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 803 | 0 | $self->parseResult($text, "\\", $lahead, @_); | |||||||||||||||||||||||||||
| 804 | 0 | return 1; | |||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||
| 806 | } else { | ||||||||||||||||||||||||||||
| 807 | 6210 | ▶ | if ($$text =~ s/^(\\)(\n)/$2/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 808 | 14 | return $self->parseResult($text, "\\", $lahead, @_); | |||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||
| 811 | 6196 | return '' | |||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | sub testRangeDetect { | ||||||||||||||||||||||||||||
| 815 | 15374 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testRangeDetect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 816 | 15374 | my $text = shift; | |||||||||||||||||||||||||||
| 817 | 15374 | my $char = shift; | |||||||||||||||||||||||||||
| 818 | 15374 | my $char1 = shift; | |||||||||||||||||||||||||||
| 819 | 15374 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 820 | 15374 | my $string = "$char\[^$char1\]+$char1"; | |||||||||||||||||||||||||||
| 821 | 15374 | return $self->testRegExpr($text, $string, $insensitive, 0, @_); | |||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | sub testRegExpr { | ||||||||||||||||||||||||||||
| 825 | 1370097 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testRegExpr: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||
| 826 | 1370097 | my $text = shift; | |||||||||||||||||||||||||||
| 827 | 1370097 | my $reg = shift; | |||||||||||||||||||||||||||
| 828 | 1370097 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 829 | 1370097 | my $dynamic = shift; | |||||||||||||||||||||||||||
| 830 | 1370097 | ▶ | if ($dynamic) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 831 | 5299 | $reg = $self->capturedParse($reg); | |||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||
| 833 | 1370097 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 834 | 1370097 | ▶ | if ($reg =~ s/^\^//) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 835 | 293923 | ▶ | unless ($eng->linestart) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 836 | 283496 | return ''; | |||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||
| 838 | } elsif ($reg =~ s/^\\(b)//i) { | ||||||||||||||||||||||||||||
| 839 | 310501 | my $lastchar = $eng->lastchar; | |||||||||||||||||||||||||||
| 840 | 310501 | ▶ | if ($1 eq 'b') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 841 | 309819 | ▶ | if ($lastchar =~ /\w/) { return '' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 842 | } else { | ||||||||||||||||||||||||||||
| 843 | 682 | ▶ | if ($lastchar =~ /\W/) { return '' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||
| 846 | 956282 | $reg = "^($reg)"; | |||||||||||||||||||||||||||
| 847 | 956282 | my $sample = $$text; | |||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | # emergency measurements to avoid exception (szabgab) | ||||||||||||||||||||||||||||
| 850 | 956282 | $reg = eval { qr/$reg/ }; | |||||||||||||||||||||||||||
| 851 | 956282 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 852 | 0 | warn $@; | |||||||||||||||||||||||||||
| 853 | 0 | return ''; | |||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||
| 855 | 956282 | my $match; | |||||||||||||||||||||||||||
| 856 | 956282 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 857 | 127708 | ▶ | if ($sample =~ /$reg/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 858 | 158 | $match = $1; | |||||||||||||||||||||||||||
| 859 | 158 | ▶ | if ($#-) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 860 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 861 | 158 | my @cap = map {$$_} 2 .. $#-; | |||||||||||||||||||||||||||
| 862 | 158 | $self->captured(\@cap) | |||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||
| 865 | } else { | ||||||||||||||||||||||||||||
| 866 | 828574 | ▶ | if ($sample =~ /$reg/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 867 | 13015 | $match = $1; | |||||||||||||||||||||||||||
| 868 | 13015 | ▶ | if ($#-) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 869 | 6 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 870 | 13015 | my @cap = map {$$_} 2 .. $#-; | |||||||||||||||||||||||||||
| 871 | 13015 | $self->captured(\@cap); | |||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||
| 875 | 956282 | ▶ | if ((defined($match)) and ($match ne '')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $match and $match ne ""
MC/DC100%2/2
defined $match and $match ne ""
defined $match
$match ne ""
Truth table100%3/3
A and B
A= defined $matchB= $match ne ""
| |||||||||||||||||||||||||||||
| 876 | 9843 | return $self->parseResult($text, $match, @_); | |||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||
| 878 | 946439 | return '' | |||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | sub testStringDetect { | ||||||||||||||||||||||||||||
| 882 | 1692834 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
testStringDetect: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 883 | 1692834 | my $text = shift; | |||||||||||||||||||||||||||
| 884 | 1692834 | my $string = shift; | |||||||||||||||||||||||||||
| 885 | 1692834 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 886 | 1692834 | my $dynamic = shift; | |||||||||||||||||||||||||||
| 887 | 1692834 | ▶ | if ($dynamic) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 888 | 0 | $string = $self->capturedParse($string); | |||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||
| 890 | 1692834 | my $test = substr($$text, 0, length($string)); | |||||||||||||||||||||||||||
| 891 | 1692834 | my $bck = $test; | |||||||||||||||||||||||||||
| 892 | 1692834 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 893 | 3672 | $string = lc($string); | |||||||||||||||||||||||||||
| 894 | 3672 | $test = lc($test); | |||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||
| 896 | 1692834 | ▶ | if ($string eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 897 | 570 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||
| 899 | 1692264 | return '' | |||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | 5 | 1; | |||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | __END__ | ||||||||||||||||||||||||||||