| 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 | 7 | our $VERSION = '0.16'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Carp qw(cluck); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | #my $regchars = '\\^.$|()[]*+?'; | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 239 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 239 | my $proto = shift; | |||||||||||||||||||||||||||
| 17 | 239 | ▶ | 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 | 239 | my %args = (@_); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 239 | my $debug = delete $args{'debug'}; | |||||||||||||||||||||||||||
| 21 | 239 | ▶ | unless (defined($debug)) { $debug = 0 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 239 | my $substitutions = delete $args{'substitutions'}; | |||||||||||||||||||||||||||
| 23 | 239 | ▶ | unless (defined($substitutions)) { $substitutions = {} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 239 | my $formattable = delete $args{'format_table'}; | |||||||||||||||||||||||||||
| 25 | 239 | ▶ | unless (defined($formattable)) { $formattable = {} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 239 | my $engine = delete $args{'engine'}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 239 | my $self = {}; | |||||||||||||||||||||||||||
| 29 | $self->{'attributes'} = {}, | ||||||||||||||||||||||||||||
| 30 | 239 | $self->{'captured'} = []; | |||||||||||||||||||||||||||
| 31 | 239 | $self->{'contextdata'} = {}; | |||||||||||||||||||||||||||
| 32 | 239 | $self->{'basecontext'} = ''; | |||||||||||||||||||||||||||
| 33 | 239 | $self->{'debug'} = $debug; | |||||||||||||||||||||||||||
| 34 | 239 | $self->{'deliminators'} = ''; | |||||||||||||||||||||||||||
| 35 | 239 | $self->{'engine'} = ''; | |||||||||||||||||||||||||||
| 36 | 239 | $self->{'format_table'} = $formattable; | |||||||||||||||||||||||||||
| 37 | 239 | $self->{'keywordscase'} = 1; | |||||||||||||||||||||||||||
| 38 | 239 | $self->{'lastchar'} = ''; | |||||||||||||||||||||||||||
| 39 | 239 | $self->{'linesegment'} = ''; | |||||||||||||||||||||||||||
| 40 | 239 | $self->{'lists'} = {}; | |||||||||||||||||||||||||||
| 41 | 239 | $self->{'linestart'} = 1; | |||||||||||||||||||||||||||
| 42 | 239 | $self->{'out'} = []; | |||||||||||||||||||||||||||
| 43 | 239 | $self->{'plugins'} = {}; | |||||||||||||||||||||||||||
| 44 | 239 | $self->{'snippet'} = ''; | |||||||||||||||||||||||||||
| 45 | 239 | $self->{'snippetattribute'} = ''; | |||||||||||||||||||||||||||
| 46 | 239 | $self->{'stack'} = []; | |||||||||||||||||||||||||||
| 47 | 239 | $self->{'substitutions'} = $substitutions; | |||||||||||||||||||||||||||
| 48 | 239 | bless ($self, $class); | |||||||||||||||||||||||||||
| 49 | 239 | ▶ | unless (defined $engine) { $engine = $self }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 239 | $self->engine($engine); | |||||||||||||||||||||||||||
| 51 | 239 | $self->initialize; | |||||||||||||||||||||||||||
| 52 | 239 | return $self; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 226 | ▶ | sub attributes { | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 226 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 226 | ▶ | if (@_) { $self->{'attributes'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 226 | return $self->{'attributes'}; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 340 | ▶ | sub basecontext { | ||||||||||||||||||||||||||
|
Subroutine
basecontext: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 62 | 340 | my $self = shift; | |||||||||||||||||||||||||||
| 63 | 340 | ▶ | if (@_) { $self->{'basecontext'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 340 | return $self->{'basecontext'}; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 13285 | ▶ | sub captured { | ||||||||||||||||||||||||||
|
Subroutine
captured: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 13285 | my ($self, $c) = @_; | |||||||||||||||||||||||||||
| 69 | 13285 | ▶ | if (defined($c)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 13285 | my $t = $self->engine->stackTop; | |||||||||||||||||||||||||||
| 71 | 13285 | my $n = 0; | |||||||||||||||||||||||||||
| 72 | 13285 | my @o = (); | |||||||||||||||||||||||||||
| 73 | 13285 | ▶ | while (defined($c->[$n])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 1328 | push @o, $c->[$n]; | |||||||||||||||||||||||||||
| 75 | 1328 | $n ++; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 13285 | ▶ | if (@o) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 1204 | $t->[2] = \@o; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 5384 | ▶ | sub capturedGet { | ||||||||||||||||||||||||||
|
Subroutine
capturedGet: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | 5384 | my ($self, $num) = @_; | |||||||||||||||||||||||||||
| 85 | 5384 | my $s = $self->engine->{stack}; | |||||||||||||||||||||||||||
| 86 | 5384 | ▶ | if (defined($s->[1])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 5384 | my $c = $s->[1]->[2]; | |||||||||||||||||||||||||||
| 88 | 5384 | $num --; | |||||||||||||||||||||||||||
| 89 | 5384 | ▶ | if (defined($c)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 5384 | ▶ | if (defined($c->[$num])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 5384 | my $r = $c->[$num]; | |||||||||||||||||||||||||||
| 92 | 5384 | 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 | 5384 | ▶ | sub capturedParse { | ||||||||||||||||||||||||||
|
Subroutine
capturedParse: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 144 | 5384 | my ($self, $string, $mode) = @_; | |||||||||||||||||||||||||||
| 145 | 5384 | my $s = ''; | |||||||||||||||||||||||||||
| 146 | 5384 | ▶ | if (defined($mode)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 49 | ▶ | if ($string =~ s/^(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 49 | $s = $self->capturedGet($1); | |||||||||||||||||||||||||||
| 149 | 49 | ▶ | 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 | 5336 | ▶ | while ($string ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 15939 | ▶ | if ($string =~ s/^([^\%]*)\%(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 5336 | my $r = $self->capturedGet($2); | |||||||||||||||||||||||||||
| 157 | 5336 | ▶ | if ($r ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 5336 | $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 | 10604 | $string =~ s/^(.)//; | |||||||||||||||||||||||||||
| 165 | 10604 | $s = "$s$1"; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 5384 | return $s; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 287 | ▶ | sub column { | ||||||||||||||||||||||||||
|
Subroutine
column: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 173 | 287 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | 287 | return length($self->{linesegment}); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 226 | ▶ | sub contextdata { | ||||||||||||||||||||||||||
|
Subroutine
contextdata: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 226 | my $self = shift; | |||||||||||||||||||||||||||
| 179 | 226 | ▶ | if (@_) { $self->{'contextdata'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 226 | return $self->{'contextdata'}; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 654278 | ▶ | sub contextInfo { | ||||||||||||||||||||||||||
|
Subroutine
contextInfo: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 654278 | my ($self, $context, $item) = @_; | |||||||||||||||||||||||||||
| 185 | 654278 | ▶ | if (exists $self->{contextdata}->{$context}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 654278 | my $c = $self->{contextdata}->{$context}; | |||||||||||||||||||||||||||
| 187 | 654278 | ▶ | if (exists $c->{$item}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 483842 | return $c->{$item} | |||||||||||||||||||||||||||
| 189 | } else { | ||||||||||||||||||||||||||||
| 190 | 170437 | return undef; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||
| 193 | 1 | $self->logwarning("undefined context '$context'"); | |||||||||||||||||||||||||||
| 194 | 1 | return undef; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 57194 | ▶ | sub contextParse { | ||||||||||||||||||||||||||
|
Subroutine
contextParse: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 199 | 57194 | my ($self, $plug, $context) = @_; | |||||||||||||||||||||||||||
| 200 | 57194 | ▶ | if ($context =~ /^#pop/i) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 201 | 7770 | ▶ | while ($context =~ s/#pop//i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 9766 | $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 | 10020 | $self->stackPush([$plug, $context]); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 1 | ▶ | sub debug { | ||||||||||||||||||||||||||
|
Subroutine
debug: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 215 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 216 | 1 | ▶ | if (@_) { $self->{'debug'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | 1 | return $self->{'debug'}; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 1 | ▶ | sub debugTest { | ||||||||||||||||||||||||||
|
Subroutine
debugTest: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 221 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 222 | 1 | ▶ | if (@_) { $self->{'debugtest'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 1 | return $self->{'debugtest'}; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 226 | ▶ | sub deliminators { | ||||||||||||||||||||||||||
|
Subroutine
deliminators: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 227 | 226 | my $self = shift; | |||||||||||||||||||||||||||
| 228 | 226 | ▶ | if (@_) { $self->{'deliminators'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 226 | return $self->{'deliminators'}; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 234106 | ▶ | sub engine { | ||||||||||||||||||||||||||
|
Subroutine
engine: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 233 | 234106 | my $self = shift; | |||||||||||||||||||||||||||
| 234 | 234106 | ▶ | if (@_) { $self->{'engine'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 234106 | return $self->{'engine'}; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 238 | ▶ | sub firstnonspace { | ||||||||||||||||||||||||||
|
Subroutine
firstnonspace: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 240 | 238 | my ($self, $string) = @_; | |||||||||||||||||||||||||||
| 241 | 238 | my $line = $self->{linesegment}; | |||||||||||||||||||||||||||
| 242 | 238 | ▶ | if (($line =~ /^\s*$/) and ($string =~ /^[^\s]/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line =~ /^\s*$/ and $string =~ /^[^\s]/
MC/DC100%2/2
$line =~ /^\s*$/ and $string =~ /^[^\s]/
$line =~ /^\s*$/
$string =~ /^[^\s]/
Truth table100%3/3
A and B
A= $line =~ /^\s*$/B= $string =~ /^[^\s]/
| |||||||||||||||||||||||||||||
| 243 | 197 | return 1 | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | 42 | return '' | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 56233 | ▶ | sub formatTable { | ||||||||||||||||||||||||||
|
Subroutine
formatTable: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 249 | 56233 | my $self = shift; | |||||||||||||||||||||||||||
| 250 | 56233 | ▶ | if (@_) { $self->{'format_table'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 56233 | return $self->{'format_table'}; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 140 | ▶ | sub highlight { | ||||||||||||||||||||||||||
|
Subroutine
highlight: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 255 | 140 | my ($self, $text) = @_; | |||||||||||||||||||||||||||
| 256 | 140 | $self->snippet(''); | |||||||||||||||||||||||||||
| 257 | 140 | my $out = $self->{out}; | |||||||||||||||||||||||||||
| 258 | 140 | @$out = (); | |||||||||||||||||||||||||||
| 259 | 140 | ▶ | while ($text ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 215530 | my $top = $self->stackTop; | |||||||||||||||||||||||||||
| 261 | 215530 | ▶ | if (defined($top)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 215524 | my ($plug, $context) = @$top; | |||||||||||||||||||||||||||
| 263 | 215524 | ▶ | 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 | 203696 | my $sub = $plug->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 279 | 203696 | my $result = &$sub($plug, \$text); | |||||||||||||||||||||||||||
| 280 | 203696 | ▶ | unless($result) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 149929 | my $f = $plug->contextInfo($context, 'fallthrough'); | |||||||||||||||||||||||||||
| 282 | 149929 | ▶ | if (defined($f)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 1504 | $self->contextParse($plug, $f); | |||||||||||||||||||||||||||
| 284 | } else { | ||||||||||||||||||||||||||||
| 285 | 148426 | $text =~ s/^(.)//; | |||||||||||||||||||||||||||
| 286 | 148426 | my $attr = $plug->{attributes}->{$plug->contextInfo($context, 'attribute')}; | |||||||||||||||||||||||||||
| 287 | 148426 | $self->snippetParse($1, $attr); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | } else { | ||||||||||||||||||||||||||||
| 292 | 7 | push @$out, length($text), 'Normal'; | |||||||||||||||||||||||||||
| 293 | 7 | $text = ''; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 140 | $self->snippetForce; | |||||||||||||||||||||||||||
| 297 | 140 | return @$out; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 140 | ▶ | sub highlightText { | ||||||||||||||||||||||||||
|
Subroutine
highlightText: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 301 | 140 | my ($self, $text) = @_; | |||||||||||||||||||||||||||
| 302 | 140 | my $res = ''; | |||||||||||||||||||||||||||
| 303 | 140 | my @hl = $self->highlight($text); | |||||||||||||||||||||||||||
| 304 | 140 | ▶ | while (@hl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | 56233 | my $f = shift @hl; | |||||||||||||||||||||||||||
| 306 | 56233 | my $t = shift @hl; | |||||||||||||||||||||||||||
| 307 | 56233 | ▶ | unless (defined($t)) { $t = 'Normal' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | 56233 | my $s = $self->{substitutions}; | |||||||||||||||||||||||||||
| 309 | 56233 | my $rr = ''; | |||||||||||||||||||||||||||
| 310 | 56233 | ▶ | while ($f ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 324916 | my $k = substr($f , 0, 1); | |||||||||||||||||||||||||||
| 312 | 324916 | $f = substr($f, 1, length($f) -1); | |||||||||||||||||||||||||||
| 313 | 324916 | ▶ | if (exists $s->{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | 9735 | $rr = $rr . $s->{$k} | |||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||
| 316 | 315181 | $rr = $rr . $k; | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 56232 | my $rt = $self->formatTable; | |||||||||||||||||||||||||||
| 320 | 56232 | ▶ | if (exists $rt->{$t}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 56232 | my $o = $rt->{$t}; | |||||||||||||||||||||||||||
| 322 | 56232 | $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 | 139 | return $res; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 17034 | ▶ | sub includePlugin { | ||||||||||||||||||||||||||
|
Subroutine
includePlugin: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | 17033 | my ($self, $language, $text) = @_; | |||||||||||||||||||||||||||
| 333 | 17033 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 334 | 17033 | my $plug = $eng->pluginGet($language); | |||||||||||||||||||||||||||
| 335 | 17033 | ▶ | if (defined($plug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 336 | 17033 | my $context = $plug->{basecontext}; | |||||||||||||||||||||||||||
| 337 | 17033 | my $call = $plug->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 338 | 17033 | ▶ | if (defined($call)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 17033 | 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 | 80047 | ▶ | sub includeRules { | ||||||||||||||||||||||||||
|
Subroutine
includeRules: called CC=2 SCAR=7.9
Pod
documented
| |||||||||||||||||||||||||||||
| 348 | 80046 | my ($self, $context, $text) = @_; | |||||||||||||||||||||||||||
| 349 | 80046 | my $call = $self->contextInfo($context, 'callback'); | |||||||||||||||||||||||||||
| 350 | 80046 | ▶ | if (defined($call)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 80046 | return &$call($self, $text); | |||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||
| 353 | 0 | $self->logwarning("cannot find callback for context '$context'"); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | 0 | return 0; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | 452 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 359 | 451 | my $self = shift; | |||||||||||||||||||||||||||
| 360 | 451 | ▶ | if ($self->engine eq $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 273 | $self->stack([[$self, $self->{basecontext}]]); | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 226 | ▶ | sub keywordscase { | ||||||||||||||||||||||||||
|
Subroutine
keywordscase: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 366 | 225 | my $self = shift; | |||||||||||||||||||||||||||
| 367 | 225 | ▶ | if (@_) { $self->{'keywordscase'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 225 | return $self->{'keywordscase'} | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 23 | ▶ | sub languagePlug { | ||||||||||||||||||||||||||
|
Subroutine
languagePlug: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 372 | 22 | my ($cw, $name) = @_; | |||||||||||||||||||||||||||
| 373 | 22 | 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 | 22 | ▶ | if ($name =~ s/^(\d)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 0 | $name = $numb{$1} . $name; | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | 22 | $name =~ s/\.//; | |||||||||||||||||||||||||||
| 389 | 22 | $name =~ s/\+/plus/g; | |||||||||||||||||||||||||||
| 390 | 22 | $name =~ s/\-/minus/g; | |||||||||||||||||||||||||||
| 391 | 22 | $name =~ s/#/dash/g; | |||||||||||||||||||||||||||
| 392 | 22 | $name =~ s/[^0-9a-zA-Z]/_/g; | |||||||||||||||||||||||||||
| 393 | 22 | $name =~ s/__/_/g; | |||||||||||||||||||||||||||
| 394 | 22 | $name =~ s/_$//; | |||||||||||||||||||||||||||
| 395 | 22 | $name = ucfirst($name); | |||||||||||||||||||||||||||
| 396 | 22 | return $name; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 764841 | ▶ | sub lastchar { | ||||||||||||||||||||||||||
|
Subroutine
lastchar: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 400 | 764840 | my $self = shift; | |||||||||||||||||||||||||||
| 401 | 764840 | my $l = $self->{linesegment}; | |||||||||||||||||||||||||||
| 402 | 764840 | ▶ | if ($l eq '') { return "\n" } #last character was a newline | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | 746116 | return substr($l, length($l) - 1, 1); | |||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 508994 | ▶ | sub lastcharDeliminator { | ||||||||||||||||||||||||||
|
Subroutine
lastcharDeliminator: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 407 | 508993 | my $self = shift; | |||||||||||||||||||||||||||
| 408 | 508993 | my $deliminators = '\s|\~|\!|\%|\^|\&|\*|\+|\(|\)|-|=|\{|\}|\[|\]|:|;|<|>|,|\\|\||\.|\?|\/'; | |||||||||||||||||||||||||||
| 409 | 508993 | ▶ | 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 | 272041 | return 1; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | 236952 | return ''; | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 801723 | ▶ | sub linesegment { | ||||||||||||||||||||||||||
|
Subroutine
linesegment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 416 | 801722 | my $self = shift; | |||||||||||||||||||||||||||
| 417 | 801722 | ▶ | if (@_) { $self->{'linesegment'} = shift; }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 801722 | return $self->{'linesegment'}; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 801714 | ▶ | sub linestart { | ||||||||||||||||||||||||||
|
Subroutine
linestart: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 422 | 801713 | my $self = shift; | |||||||||||||||||||||||||||
| 423 | 801713 | ▶ | if ($self->linesegment eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 40419 | return 1 | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 761294 | return ''; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 1 | ▶ | sub lists { | ||||||||||||||||||||||||||
|
Subroutine
lists: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 430 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (@_) { $self->{'lists'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 0 | return $self->{'lists'} | |||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 117 | ▶ | sub out { | ||||||||||||||||||||||||||
|
Subroutine
out: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 436 | 116 | my $self = shift; | |||||||||||||||||||||||||||
| 437 | 116 | ▶ | if (@_) { $self->{'out'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 116 | return $self->{'out'}; | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 696 | ▶ | sub listAdd { | ||||||||||||||||||||||||||
|
Subroutine
listAdd: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 442 | 695 | my $self = shift; | |||||||||||||||||||||||||||
| 443 | 695 | my $listname = shift; | |||||||||||||||||||||||||||
| 444 | 695 | my $lst = $self->{lists}; | |||||||||||||||||||||||||||
| 445 | 695 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 446 | 694 | my @l = reverse sort @_; | |||||||||||||||||||||||||||
| 447 | 694 | $lst->{$listname} = \@l; | |||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||
| 449 | 1 | $lst->{$listname} = []; | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 3 | ▶ | sub logwarning { | ||||||||||||||||||||||||||
|
Subroutine
logwarning: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 454 | 2 | my ($self, $warning) = @_; | |||||||||||||||||||||||||||
| 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 | 54139 | ▶ | sub parseResult { | ||||||||||||||||||||||||||
|
Subroutine
parseResult: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 467 | 54138 | my ($self, $text, $string, $lahead, $column, $fnspace, $context, $attr) = @_; | |||||||||||||||||||||||||||
| 468 | 54138 | my $eng = $self->engine; | |||||||||||||||||||||||||||
| 469 | 54138 | ▶ | if ($fnspace) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 237 | ▶ | unless ($eng->firstnonspace($$text)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | 41 | return '' | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | 54097 | ▶ | if (defined($column)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 286 | ▶ | if ($column ne $eng->column) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 476 | 52 | return ''; | |||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | 54045 | ▶ | unless ($lahead) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 480 | 52775 | $$text = substr($$text, length($string)); | |||||||||||||||||||||||||||
| 481 | 52775 | my $r; | |||||||||||||||||||||||||||
| 482 | 52775 | ▶ | unless (defined($attr)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 19666 | my $t = $eng->stackTop; | |||||||||||||||||||||||||||
| 484 | 19666 | my ($plug, $ctext) = @$t; | |||||||||||||||||||||||||||
| 485 | 19666 | $r = $plug->{attributes}->{$plug->contextInfo($ctext, 'attribute')}; | |||||||||||||||||||||||||||
| 486 | } else { | ||||||||||||||||||||||||||||
| 487 | 33109 | $r = $self->{attributes}->{$attr}; | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | 52775 | $eng->snippetParse($string, $r); | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | 54045 | $eng->contextParse($self, $context); | |||||||||||||||||||||||||||
| 492 | 54045 | return 1 | |||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 17156 | ▶ | sub pluginGet { | ||||||||||||||||||||||||||
|
Subroutine
pluginGet: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 496 | 17155 | my ($self, $language) = @_; | |||||||||||||||||||||||||||
| 497 | 17155 | my $plugs = $self->{'plugins'}; | |||||||||||||||||||||||||||
| 498 | 17155 | ▶ | unless (exists($plugs->{$language})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 499 | 91 | my $lang_plug = $self->languagePlug($language); | |||||||||||||||||||||||||||
| 500 | 91 | my $modname = 'Syntax::Highlight::Engine::Kate::'; | |||||||||||||||||||||||||||
| 501 | 91 | ▶ | if (defined $lang_plug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 89 | $modname .= $lang_plug; | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | 91 | ▶ | unless (defined($modname)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 505 | 0 | $self->logwarning("no valid module found for language '$language'"); | |||||||||||||||||||||||||||
| 506 | 0 | return undef; | |||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | 91 | my $plug; | |||||||||||||||||||||||||||
| 509 | 6 | ▶ | 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 | 91 | ▶ | if (defined($plug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 511 | 89 | $plugs->{$language} = $plug; | |||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||
| 513 | 2 | $self->logwarning("cannot create plugin for language '$language'\n--------------\n$@"); | |||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | 17155 | ▶ | if (exists($plugs->{$language})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 517 | 17153 | return $plugs->{$language}; | |||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||
| 519 | 2 | return undef; | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 1 | ▶ | sub reset { | ||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 523 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 524 | 0 | $self->stack([[$self, $self->{basecontext}]]); | |||||||||||||||||||||||||||
| 525 | 0 | $self->out([]); | |||||||||||||||||||||||||||
| 526 | 0 | $self->snippet(''); | |||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 120701 | ▶ | sub snippet { | ||||||||||||||||||||||||||
|
Subroutine
snippet: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 530 | 120700 | my $self = shift; | |||||||||||||||||||||||||||
| 531 | 120700 | ▶ | if (@_) { $self->{'snippet'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 120700 | return $self->{'snippet'}; | |||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 213029 | ▶ | sub snippetAppend { | ||||||||||||||||||||||||||
|
Subroutine
snippetAppend: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 536 | 213028 | my ($self, $ch) = @_; | |||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | 213028 | ▶ | return if not defined $ch; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 539 | 213014 | $self->{'snippet'} = $self->{'snippet'} . $ch; | |||||||||||||||||||||||||||
| 540 | 213014 | ▶ | if ($ch ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 541 | 213014 | $self->{linesegment} = $self->{linesegment} . $ch; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | 213014 | return; | |||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 1 | ▶ | sub snippetAttribute { | ||||||||||||||||||||||||||
|
Subroutine
snippetAttribute: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 547 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 548 | 0 | ▶ | if (@_) { $self->{'snippetattribute'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | 0 | return $self->{'snippetattribute'}; | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | 64220 | ▶ | sub snippetForce { | ||||||||||||||||||||||||||
|
Subroutine
snippetForce: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 553 | 64219 | my $self = shift; | |||||||||||||||||||||||||||
| 554 | 64219 | my $parse = $self->snippet; | |||||||||||||||||||||||||||
| 555 | 64219 | ▶ | if ($parse ne '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 556 | 56226 | my $out = $self->{'out'}; | |||||||||||||||||||||||||||
| 557 | 56226 | push(@$out, $parse, $self->{snippetattribute}); | |||||||||||||||||||||||||||
| 558 | 56226 | $self->snippet(''); | |||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | 213029 | ▶ | sub snippetParse { | ||||||||||||||||||||||||||
|
Subroutine
snippetParse: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 563 | 213028 | my $self = shift; | |||||||||||||||||||||||||||
| 564 | 213028 | my $snip = shift; | |||||||||||||||||||||||||||
| 565 | 213028 | my $attr = shift; | |||||||||||||||||||||||||||
| 566 | 213028 | ▶ | 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 | 40424 | $self->snippetForce; | |||||||||||||||||||||||||||
| 568 | 40424 | $self->{snippetattribute} = $attr; | |||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||
| 570 | 213028 | $self->snippetAppend($snip); | |||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 390 | ▶ | sub stack { | ||||||||||||||||||||||||||
|
Subroutine
stack: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 574 | 389 | my $self = shift; | |||||||||||||||||||||||||||
| 575 | 389 | ▶ | if (@_) { $self->{'stack'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 389 | return $self->{'stack'}; | |||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | 10026 | ▶ | sub stackPush { | ||||||||||||||||||||||||||
|
Subroutine
stackPush: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 580 | 10025 | my ($self, $val) = @_; | |||||||||||||||||||||||||||
| 581 | 10025 | my $stack = $self->{stack}; | |||||||||||||||||||||||||||
| 582 | 10025 | unshift(@$stack, $val); | |||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | 9766 | ▶ | sub stackPull { | ||||||||||||||||||||||||||
|
Subroutine
stackPull: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 586 | 9765 | my ($self, $val) = @_; | |||||||||||||||||||||||||||
| 587 | 9765 | my $stack = $self->{stack}; | |||||||||||||||||||||||||||
| 588 | 9765 | return shift(@$stack); | |||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||
| 591 | 248482 | ▶ | sub stackTop { | ||||||||||||||||||||||||||
|
Subroutine
stackTop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 592 | 248481 | my $self = shift; | |||||||||||||||||||||||||||
| 593 | 248481 | return $self->{stack}->[0]; | |||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | 1 | ▶ | sub stateCompare { | ||||||||||||||||||||||||||
|
Subroutine
stateCompare: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 597 | 0 | my ($self, $state) = @_; | |||||||||||||||||||||||||||
| 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 | 1 | ▶ | sub stateGet { | ||||||||||||||||||||||||||
|
Subroutine
stateGet: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 605 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 606 | 0 | my $s = $self->{stack}; | |||||||||||||||||||||||||||
| 607 | 0 | return @$s; | |||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||
| 610 | 1 | ▶ | sub stateSet { | ||||||||||||||||||||||||||
|
Subroutine
stateSet: called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 611 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 612 | 0 | my $s = $self->{stack}; | |||||||||||||||||||||||||||
| 613 | 0 | @$s = (@_); | |||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | 1 | ▶ | sub substitutions { | ||||||||||||||||||||||||||
|
Subroutine
substitutions: called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 617 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 618 | 0 | ▶ | if (@_) { $self->{'substitutions'} = shift; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 619 | 0 | return $self->{'substitutions'}; | |||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 37572 | ▶ | sub testAnyChar { | ||||||||||||||||||||||||||
|
Subroutine
testAnyChar: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 623 | 37571 | my $self = shift; | |||||||||||||||||||||||||||
| 624 | 37571 | my $text = shift; | |||||||||||||||||||||||||||
| 625 | 37571 | my $string = shift; | |||||||||||||||||||||||||||
| 626 | 37571 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 627 | 37571 | my $test = substr($$text, 0, 1); | |||||||||||||||||||||||||||
| 628 | 37571 | my $bck = $test; | |||||||||||||||||||||||||||
| 629 | 37571 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 630 | 0 | $string = lc($string); | |||||||||||||||||||||||||||
| 631 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | 37571 | ▶ | if (index($string, $test) > -1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 634 | 5179 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||
| 636 | 32392 | return '' | |||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | 333363 | ▶ | sub testDetectChar { | ||||||||||||||||||||||||||
|
Subroutine
testDetectChar: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 640 | 333362 | my $self = shift; | |||||||||||||||||||||||||||
| 641 | 333362 | my $text = shift; | |||||||||||||||||||||||||||
| 642 | 333362 | my $char = shift; | |||||||||||||||||||||||||||
| 643 | 333362 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 644 | 333362 | my $dyn = shift; | |||||||||||||||||||||||||||
| 645 | 333362 | ▶ | if ($dyn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 646 | 48 | $char = $self->capturedParse($char, 1); | |||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||
| 648 | 333362 | my $test = substr($$text, 0, 1); | |||||||||||||||||||||||||||
| 649 | 333362 | my $bck = $test; | |||||||||||||||||||||||||||
| 650 | 333362 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 651 | 0 | $char = lc($char); | |||||||||||||||||||||||||||
| 652 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||
| 654 | 333362 | ▶ | if ($char eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 655 | 9591 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | 323771 | return '' | |||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | 221496 | ▶ | sub testDetect2Chars { | ||||||||||||||||||||||||||
|
Subroutine
testDetect2Chars: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 661 | 221495 | my $self = shift; | |||||||||||||||||||||||||||
| 662 | 221495 | my $text = shift; | |||||||||||||||||||||||||||
| 663 | 221495 | my $char = shift; | |||||||||||||||||||||||||||
| 664 | 221495 | my $char1 = shift; | |||||||||||||||||||||||||||
| 665 | 221495 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 666 | 221495 | my $dyn = shift; | |||||||||||||||||||||||||||
| 667 | 221495 | ▶ | if ($dyn) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 668 | 0 | $char = $self->capturedParse($char, 1); | |||||||||||||||||||||||||||
| 669 | 0 | $char1 = $self->capturedParse($char1, 1); | |||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | 221495 | my $string = $char . $char1; | |||||||||||||||||||||||||||
| 672 | 221495 | my $test = substr($$text, 0, 2); | |||||||||||||||||||||||||||
| 673 | 221495 | my $bck = $test; | |||||||||||||||||||||||||||
| 674 | 221495 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 675 | 0 | $string = lc($string); | |||||||||||||||||||||||||||
| 676 | 0 | $test = lc($test); | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | 221495 | ▶ | if ($string eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 679 | 1263 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||
| 681 | 220232 | return '' | |||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | 16810 | ▶ | sub testDetectIdentifier { | ||||||||||||||||||||||||||
|
Subroutine
testDetectIdentifier: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 685 | 16809 | my $self = shift; | |||||||||||||||||||||||||||
| 686 | 16809 | my $text = shift; | |||||||||||||||||||||||||||
| 687 | 16809 | ▶ | if ($$text =~ /^([a-zA-Z_][a-zA-Z0-9_]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 688 | 7537 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||
| 690 | 9272 | return '' | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | 33861 | ▶ | sub testDetectSpaces { | ||||||||||||||||||||||||||
|
Subroutine
testDetectSpaces: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 694 | 33860 | my $self = shift; | |||||||||||||||||||||||||||
| 695 | 33860 | my $text = shift; | |||||||||||||||||||||||||||
| 696 | 33860 | ▶ | if ($$text =~ /^([\040\t]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 697 | 11911 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||
| 699 | 21949 | return '' | |||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 49444 | ▶ | sub testFloat { | ||||||||||||||||||||||||||
|
Subroutine
testFloat: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 703 | 49443 | my $self = shift; | |||||||||||||||||||||||||||
| 704 | 49443 | my $text = shift; | |||||||||||||||||||||||||||
| 705 | 49443 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 706 | 25619 | ▶ | if ($$text =~ /^((?=\.?\d)\d*(?:\.\d*)?(?:[Ee][+-]?\d+)?)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 707 | 1912 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||
| 710 | 47531 | return '' | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | 22741 | ▶ | sub testHlCChar { | ||||||||||||||||||||||||||
|
Subroutine
testHlCChar: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 714 | 22740 | my $self = shift; | |||||||||||||||||||||||||||
| 715 | 22740 | my $text = shift; | |||||||||||||||||||||||||||
| 716 | 22740 | ▶ | if ($$text =~ /^('.')/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 717 | 26 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||
| 719 | 22714 | return '' | |||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | 31142 | ▶ | sub testHlCHex { | ||||||||||||||||||||||||||
|
Subroutine
testHlCHex: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 723 | 31141 | my $self = shift; | |||||||||||||||||||||||||||
| 724 | 31141 | my $text = shift; | |||||||||||||||||||||||||||
| 725 | 31141 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 726 | 15995 | ▶ | if ($$text =~ /^(0x[0-9a-fA-F]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 727 | 8 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||
| 730 | 31133 | return '' | |||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||
| 733 | 25304 | ▶ | sub testHlCOct { | ||||||||||||||||||||||||||
|
Subroutine
testHlCOct: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 734 | 25303 | my $self = shift; | |||||||||||||||||||||||||||
| 735 | 25303 | my $text = shift; | |||||||||||||||||||||||||||
| 736 | 25303 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 737 | 13765 | ▶ | if ($$text =~ /^(0[0-7]+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 738 | 0 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||
| 741 | 25303 | return '' | |||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | 5021 | ▶ | sub testHlCStringChar { | ||||||||||||||||||||||||||
|
Subroutine
testHlCStringChar: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 745 | 5020 | my $self = shift; | |||||||||||||||||||||||||||
| 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 | 54722 | ▶ | sub testInt { | ||||||||||||||||||||||||||
|
Subroutine
testInt: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 760 | 54721 | my $self = shift; | |||||||||||||||||||||||||||
| 761 | 54721 | my $text = shift; | |||||||||||||||||||||||||||
| 762 | 54721 | ▶ | if ($self->engine->lastcharDeliminator) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 763 | 26837 | ▶ | if ($$text =~ /^([+-]?\d+)/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 764 | 314 | return $self->parseResult($text, $1, @_); | |||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||
| 767 | 54407 | return '' | |||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | 348386 | ▶ | sub testKeyword { | ||||||||||||||||||||||||||
|
Subroutine
testKeyword: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 771 | 348385 | my $self = shift; | |||||||||||||||||||||||||||
| 772 | 348385 | my $text = shift; | |||||||||||||||||||||||||||
| 773 | 348385 | my $list = shift; | |||||||||||||||||||||||||||
| 774 | 348385 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 775 | 348385 | my $deliminators = $self->{deliminators}; | |||||||||||||||||||||||||||
| 776 | 348385 | ▶ | 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 | 73262 | my $match = $1; | |||||||||||||||||||||||||||
| 778 | 73262 | my $l = $self->{lists}->{$list}; | |||||||||||||||||||||||||||
| 779 | 73262 | ▶ | if (defined($l)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 780 | 73262 | my @list = @$l; | |||||||||||||||||||||||||||
| 781 | 73262 | my @rl = (); | |||||||||||||||||||||||||||
| 782 | 73262 | ▶ | unless ($self->{keywordscase}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 783 | 67024 | @rl = grep { (lc($match) eq lc($_)) } @list; | |||||||||||||||||||||||||||
| 784 | } else { | ||||||||||||||||||||||||||||
| 785 | 6238 | @rl = grep { ($match eq $_) } @list; | |||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||
| 787 | 73262 | ▶ | if (@rl) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 788 | 5832 | return $self->parseResult($text, $match, @_); | |||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||
| 790 | } else { | ||||||||||||||||||||||||||||
| 791 | 0 | $self->logwarning("list '$list' is not defined, failing test"); | |||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||
| 794 | 342553 | return '' | |||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||
| 797 | 6211 | ▶ | sub testLineContinue { | ||||||||||||||||||||||||||
|
Subroutine
testLineContinue: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||
| 798 | 6210 | my $self = shift; | |||||||||||||||||||||||||||
| 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 | 15468 | ▶ | sub testRangeDetect { | ||||||||||||||||||||||||||
|
Subroutine
testRangeDetect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 815 | 15468 | my $self = shift; | |||||||||||||||||||||||||||
| 816 | 15468 | my $text = shift; | |||||||||||||||||||||||||||
| 817 | 15468 | my $char = shift; | |||||||||||||||||||||||||||
| 818 | 15468 | my $char1 = shift; | |||||||||||||||||||||||||||
| 819 | 15468 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 820 | 15468 | my $string = "$char\[^$char1\]+$char1"; | |||||||||||||||||||||||||||
| 821 | 15468 | return $self->testRegExpr($text, $string, $insensitive, 0, @_); | |||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | 1245760 | ▶ | sub testRegExpr { | ||||||||||||||||||||||||||
|
Subroutine
testRegExpr: called CC=16 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||
| 825 | 1245760 | my $self = shift; | |||||||||||||||||||||||||||
| 826 | 1245760 | my $text = shift; | |||||||||||||||||||||||||||
| 827 | 1245760 | my $reg = shift; | |||||||||||||||||||||||||||
| 828 | 1245760 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 829 | 1245760 | my $dynamic = shift; | |||||||||||||||||||||||||||
| 830 | 1245760 | ▶ | if ($dynamic) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 831 | 5335 | $reg = $self->capturedParse($reg); | |||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||
| 833 | 1245760 | my $eng = $self->{engine}; | |||||||||||||||||||||||||||
| 834 | 1245760 | ▶ | if ($reg =~ s/^\^//) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 835 | 292720 | ▶ | unless ($eng->linestart) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 836 | 282288 | return ''; | |||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||
| 838 | } elsif ($reg =~ s/^\\(b)//i) { | ||||||||||||||||||||||||||||
| 839 | 285834 | my $lastchar = $eng->lastchar; | |||||||||||||||||||||||||||
| 840 | 285834 | ▶ | if ($1 eq 'b') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 841 | 285152 | ▶ | if ($lastchar =~ /\w/) { return '' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 842 | } else { | ||||||||||||||||||||||||||||
| 843 | 682 | ▶ | if ($lastchar =~ /\W/) { return '' } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||
| 846 | 837437 | $reg = "^($reg)"; | |||||||||||||||||||||||||||
| 847 | 837437 | my $sample = $$text; | |||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | # emergency measurements to avoid exception (szabgab) | ||||||||||||||||||||||||||||
| 850 | 837437 | $reg = eval { qr/$reg/ }; | |||||||||||||||||||||||||||
| 851 | 837437 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 852 | 0 | warn $@; | |||||||||||||||||||||||||||
| 853 | 0 | return ''; | |||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||
| 855 | 837437 | my $match; | |||||||||||||||||||||||||||
| 856 | 837437 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 857 | 122076 | ▶ | if ($sample =~ /$reg/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 858 | 158 | $match = $1; | |||||||||||||||||||||||||||
| 859 | 158 | ▶ | if ($#-) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 860 | 8 | ▶ | 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 | 715361 | ▶ | if ($sample =~ /$reg/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 867 | 13126 | $match = $1; | |||||||||||||||||||||||||||
| 868 | 13126 | ▶ | if ($#-) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 869 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 870 | 13126 | my @cap = map {$$_} 2 .. $#-; | |||||||||||||||||||||||||||
| 871 | 13126 | $self->captured(\@cap); | |||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||
| 875 | 837437 | ▶ | 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 | 9947 | return $self->parseResult($text, $match, @_); | |||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||
| 878 | 827490 | return '' | |||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | 1677490 | ▶ | sub testStringDetect { | ||||||||||||||||||||||||||
|
Subroutine
testStringDetect: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 882 | 1677490 | my $self = shift; | |||||||||||||||||||||||||||
| 883 | 1677490 | my $text = shift; | |||||||||||||||||||||||||||
| 884 | 1677490 | my $string = shift; | |||||||||||||||||||||||||||
| 885 | 1677490 | my $insensitive = shift; | |||||||||||||||||||||||||||
| 886 | 1677490 | my $dynamic = shift; | |||||||||||||||||||||||||||
| 887 | 1677490 | ▶ | if ($dynamic) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 888 | 0 | $string = $self->capturedParse($string); | |||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||
| 890 | 1677490 | my $test = substr($$text, 0, length($string)); | |||||||||||||||||||||||||||
| 891 | 1677490 | my $bck = $test; | |||||||||||||||||||||||||||
| 892 | 1677490 | ▶ | if ($insensitive) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 893 | 3672 | $string = lc($string); | |||||||||||||||||||||||||||
| 894 | 3672 | $test = lc($test); | |||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||
| 896 | 1677490 | ▶ | if ($string eq $test) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 897 | 570 | return $self->parseResult($text, $bck, @_); | |||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||
| 899 | 1676920 | return '' | |||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | 7 | 1; | |||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | __END__ | ||||||||||||||||||||||||||||