blib/lib/JavaScript/Swell.pm

filter: Statementstmt 69.2% 162 / 234 Branchbran 67.1% 94 / 140 Conditioncond 71.0% 49 / 69 MC/DCmcdc 37.8% 14 / 37 Subroutinesub 84.8% 28 / 33 Podpod 6.2% 2 / 32 totaltotal 64.0% 349 / 545 CC 94 SCAR 38.2
CC
94
Cov
69%
parser_default
121.5
term_spacer
31.3
parser_comment
20.0
CRAP 45.8
↑ Summary
1 package JavaScript::Swell;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 our $VERSION = '0.01';
6  
7 2 my @RE = qw(! != !== % %= & && &&= &= \( *= + += - -= -> . .. ... / /= : :: ; < << <<= <= = == === > >= >> >>= >>> >>>= ? @ \[ ^ ^= ^^ ^^= \{ | |= || ||= ~ abstract break case catch const continue debugger default delete do else enum export extends final finally for function goto if implements import in instanceof interface is namespace native new package return static switch synchronized throw throws transient try typeof use var volatile while with);
8 2 my @TS = qw(* ! != !== % %= & && &&= &= *= + += - -= -> .. ... / /= : :: < << <<= <= = == === > >= >> >>= >>> >>>= ? @ ^ ^= ^^ ^^= | |= || ||= ~);
9 2 my %RegularExpression;
10 my %RegularExpression_shortcut;
11 2 foreach (@RE) {
12 188 s/^\\//o;
13 188 my $word;
14 188 $RegularExpression{$_}++;
15 188 foreach (split(//)) {
16 690 $word .= $_;
17 690 $RegularExpression_shortcut{$word}++;
18 }
19 188 $RegularExpression_shortcut{'#'}++;
20 188 $RegularExpression_shortcut{','}++;
21 188 $RegularExpression{'#'}++;
22 188 $RegularExpression{','}++;
23 }
24 2 my %TERMSPACE;
25 2 foreach (@TS) {
26 92 s/^\\//o;
27 92 $TERMSPACE{$_}++;
28 }
29 2 $TERMSPACE{'#'}++;
30  
31 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
32 2 my $class = shift;
33 2 bless {
34 source => '',
35 split_source => undef,
36 return_source => '',
37 parser_state => {
38 line => 0,
39 method => '',
40 re_word => '',
41 quote => '',
42 indent => 0,
43 cursor => 0,
44 parentheses_nest => 0,
45 is_linehead => 0,
46 squishmode => 0,
47 charlast => '',
48 },
49 }, $class;
50 }
51  
52  
53 #setter or getter
54 4 ▶sub source {
Subroutine source: called CC=2 SCAR=6.9
Pod undocumented
55 4 my $self = shift;
56 4 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 2 4
57 2 $self->{source} = shift;
58 2 $self->{source} =~ s/\r\n/\n/go;
59 2 my @ss = split(//, $self->{source});
60 2 $self->{split_source} = \@ss;
61 2 $self->{return_source} = '';
62 }
63 4 $self->{return_source};
64 }
65 247 ▶sub split_source {@{shift->{split_source}}}
Subroutine split_source: called CC=1 SCAR=0.0
Pod undocumented
66 309 ▶sub get_char {
Subroutine get_char: called CC=5 SCAR=16.2
Pod undocumented
67 309 my $self = shift;
68  
69 309 ▶ return $self->{split_source}[$self->cursor] unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 124 185 309
70 185 ▶ if ($_[0] =~ m/^\-{0,1}\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ /^\-{0,1}\d+$/) { } 185 0 185
71 185 ▶ if ((0 <= ($self->cursor + $_[0]) && ($self->split_source + 0) > ($self->cursor + $_[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (0 <= $self->cursor + $_[0] and $self->split_source + 0 > $self->cursor + $_[0]) { } 180 5 185
Condition100%3/3
0 <= $self->cursor + $_[0] and $self->split_source + 0 > $self->cursor + $_[0]
!ll&&!rl&&r
23180
MC/DC100%2/2
0 <= $self->cursor + $_[0] and $self->split_source + 0 > $self->cursor + $_[0]
0 <= $self->cursor + $_[0] $self->split_source + 0 > $self->cursor + $_[0]
Truth table100%3/3
A and B
A= 0 <= $self->cursor + $_[0]B= $self->split_source + 0 > $self->cursor + $_[0]
ABresult
0X0
100
111
72 180 return $self->{split_source}[$self->cursor + $_[0]];
73 } else {
74 5 return '';
75 }
76 } else {
77 0 return $self->{split_source}[$self->cursor];
78 }
79 }
80 62 ▶sub get_charlast {shift->{parser_state}->{charlast}}
Subroutine get_charlast: called CC=1 SCAR=0.0
Pod undocumented
81 60 ▶sub set_char {
Subroutine set_char: called CC=3 SCAR=11.0
Pod undocumented
82 60 my $self = shift;
83 60 my $c = shift;
84  
85 60 ▶ $self->{parser_state}->{charlast} = $1
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /(.)$/ 57 3 60
86 if $c =~ /(.)$/;
87  
88 60 ▶ $self->set_re_word($c) unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 58 2 60
89 60 $self->{return_source} .= $c;
90 }
91 9 ▶sub set_lf {
Subroutine set_lf: called CC=2 SCAR=6.9
Pod undocumented
92 9 my $self = shift;
93 9 ▶ return if $self->squishmode;
Branch: 1 branch
BranchTrueFalseTotal
if $self->squishmode 5 4 9
94 4 $self->set_char("\n" . (' ' x $self->indent));
95 4 $self->is_linehead(1);
96 }
97 58 ▶sub set_re_word {
Subroutine set_re_word: called CC=3 SCAR=11.0
Pod undocumented
98 58 my $self = shift;
99 58 my $c = shift;
100  
101 58 ▶ return if $c =~ /\s/o;
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\s/o 12 46 58
102  
103 46 ▶ unless ($RegularExpression_shortcut{$self->re_word . $c}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($RegularExpression_shortcut{$self->re_word . $c}) { } 10 36 46
104 36 $self->re_word($c);
105 } else {
106 10 $self->re_word($self->re_word . $c);
107 }
108 }
109 0 ▶sub is_re_before {$RegularExpression{shift->re_word}}
Subroutine is_re_before: not called CC=1 SCAR=6.9
Pod undocumented
110 130 ▶sub is_linehead {my $self = shift;@_ ? $self->{parser_state}->{is_linehead} = shift:$self->{parser_state}->{is_linehead}}
Subroutine is_linehead: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 68 62 130
111 130 ▶sub squishmode {my $self = shift;@_ ? $self->{parser_state}->{squishmode} = shift:$self->{parser_state}->{squishmode}}
Subroutine squishmode: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 128 130
112  
113 6 ▶sub indent {my $self = shift;@_ ? $self->{parser_state}->{indent} = shift:$self->{parser_state}->{indent}}
Subroutine indent: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 4 6
114 738 ▶sub cursor {my $self = shift;@_ ? $self->{parser_state}->{cursor} = shift:$self->{parser_state}->{cursor}}
Subroutine cursor: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 736 738
115 64 ▶sub method {my $self = shift;@_ ? $self->{parser_state}->{method} = shift:$self->{parser_state}->{method}}
Subroutine method: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 62 64
116 2 ▶sub quote {my $self = shift;@_ ? $self->{parser_state}->{quote} = shift:$self->{parser_state}->{quote}}
Subroutine quote: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 0 2
117 8 ▶sub parentheses_nest {my $self = shift;@_ ? $self->{parser_state}->{parentheses_nest} = shift:$self->{parser_state}->{parentheses_nest}}
Subroutine parentheses_nest: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 2 6 8
118 230 ▶sub re_word {my $self = shift;@_ ? $self->{parser_state}->{re_word} = shift:$self->{parser_state}->{re_word}}
Subroutine re_word: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 48 182 230
119  
120 64 ▶sub add_cursor {shift->{parser_state}->{cursor}++}
Subroutine add_cursor: called CC=1 SCAR=0.0
Pod undocumented
121 2 ▶sub add_indent {shift->{parser_state}->{indent} += 2}
Subroutine add_indent: called CC=1 SCAR=0.0
Pod undocumented
122 2 ▶sub dec_indent {shift->{parser_state}->{indent} -= 2}
Subroutine dec_indent: called CC=1 SCAR=0.0
Pod undocumented
123 2 ▶sub add_parentheses_nest {shift->{parser_state}->{parentheses_nest}++}
Subroutine add_parentheses_nest: called CC=1 SCAR=0.0
Pod undocumented
124 2 ▶sub dec_parentheses_nest {shift->{parser_state}->{parentheses_nest}--}
Subroutine dec_parentheses_nest: called CC=1 SCAR=0.0
Pod undocumented
125  
126  
127 #parser
128 2 ▶sub init_parser {
Subroutine init_parser: called CC=1 SCAR=0.0
Pod undocumented
129 2 my $self = shift;
130  
131 2 $self->quote('');
132 2 $self->indent(0);
133 2 $self->cursor(0);
134 2 $self->parentheses_nest(0);
135 2 $self->method('default');
136 2 $self->re_word('{');
137 2 $self->is_linehead(0);
138 }
139  
140 41 ▶sub term_spacer {
Subroutine term_spacer: called CC=23 SCAR=34.4
Pod undocumented
141 41 my $self = shift;
142 41 ▶ my $c = @_ ? shift : $self->get_char;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 41 0 41
143 41 ▶ my $c2 = @_ ? shift : $self->get_char(1);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 41 0 41
144 41 ▶ my $c3 = @_ ? shift : $self->get_char(2);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 41 41
145 41 ▶ my $c4 = @_ ? shift : $self->get_char(3);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 41 41
146 41 my $cb = $self->get_char(-1);
147 41 my $cl = $self->get_charlast;
148  
149 41 my ($s1, $s2) = (1, 1);
150 41 ▶ ($s1, $s2) = (0, 0) if $self->squishmode;
Branch: 1 branch
BranchTrueFalseTotal
if $self->squishmode 22 19 41
151 41 my $m = '';
152 # $s1 = 0 if $cb =~ /[\s\(\[]/;
153 41 ▶ $s1 = 0 if $cl =~ /[\s\(\[]/;
Branch: 1 branch
BranchTrueFalseTotal
if $cl =~ /[\s\(\[]/ 8 33 41
154  
155 41 my $cc4 = "$c$c2$c3$c4";
156 41 my $cc3 = "$c$c2$c3";
157 41 my $cc2 = "$c$c2";
158  
159 41 ▶ if ($TERMSPACE{$cc4}) {
Branch: 7 branches
BranchTrueFalseTotal
if ($TERMSPACE{$cc4}) { } 0 41 41
elsif ($TERMSPACE{$cc3}) { } 0 41 41
elsif ($TERMSPACE{$cc2}) { } 0 41 41
elsif ($cc2 eq '++' or $cc2 eq '--') { } 2 39 41
elsif ($self->re_word eq '=' || $self->re_word eq '(' and $c eq '+' || $c eq '-' and $c2 =~ /^\d$/ or $TERMSPACE{$c} and $TERMSPACE{$c2}) { } 3 36 39
elsif ($TERMSPACE{$c}) { } 3 33 36
elsif ($c eq ',') { } 0 33 33
160 0 $m = $cc4;
161 0 $self->add_cursor;
162 0 $self->add_cursor;
163 0 $self->add_cursor;
164 # $s2 = 0 if $self->get_char(4) =~ /[\s\)\]]/ && $self->squishmode;
165 } elsif ($TERMSPACE{$cc3}) {
166 0 $m = $cc3;
167 0 $self->add_cursor;
168 0 $self->add_cursor;
169 ## $s2 = 0 if $c4 =~ /[\s\)\]]/;
170 } elsif ($TERMSPACE{$cc2}) {
171 0 $m = $cc2;
172 0 $self->add_cursor;
173 # $s2 = 0 if $c3 =~ /[\s\)\]]/ && $self->squishmode;
174 ▶ } elsif ($cc2 eq '++' || $cc2 eq '--') {
Condition66%2/3
$cc2 eq "++" or $cc2 eq "--"
l!l&&r!l&&!r
2039
MC/DC50%1/2
$cc2 eq "++" or $cc2 eq "--"
$cc2 eq "++" $cc2 eq "--"
Truth table66%2/3
A or B
A= $cc2 eq "++"B= $cc2 eq "--"
ABresult
1X1
011
000
175 2 $m = $cc2;
176 2 ($s1, $s2) = (0, 0);
177 2 $self->add_cursor;
178 ## $s2 = 0 if $c3 =~ /[\s\)\]]/;
179 ▶ } elsif (((($self->re_word eq '=' || $self->re_word eq '(') && ($c eq '+' || $c eq '-') && $c2 =~ /^\d$/) || ($TERMSPACE{$c} && $TERMSPACE{$c2}))) {
Condition88%16/18
$self->re_word eq "=" || $self->re_word eq "(" and $c eq "+" || $c eq "-" and $c2 =~ /^\d$/ or $TERMSPACE{$c} and $TERMSPACE{$c2}
l!l&&r!l&&!r
2136
$self->re_word eq "=" || $self->re_word eq "(" and $c eq "+" || $c eq "-" and $c2 =~ /^\d$/
!ll&&!rl&&r
3702
$self->re_word eq "=" || $self->re_word eq "(" and $c eq "+" || $c eq "-"
!ll&&!rl&&r
3252
$self->re_word eq "=" or $self->re_word eq "("
l!l&&r!l&&!r
5232
$c eq "+" or $c eq "-"
l!l&&r!l&&!r
025
$TERMSPACE{$c} and $TERMSPACE{$c2}
!ll&&!rl&&r
3331
MC/DC57%4/7
$self->re_word eq "=" || $self->re_word eq "(" and $c eq "+" || $c eq "-" and $c2 =~ /^\d$/ or $TERMSPACE{$c} and $TERMSPACE{$c2}
$self->re_word eq "=" $self->re_word eq "(" $c eq "+" $c eq "-" $c2 =~ /^\d$/ $TERMSPACE{$c} $TERMSPACE{$c2}
Truth table24%6/25
A or B and C or D and E or F and G
A= $self->re_word eq "="B= $self->re_word eq "("C= $c eq "+"D= $c eq "-"E= $c2 =~ /^\d$/F= $TERMSPACE{$c}G= $TERMSPACE{$c2}
ABCDEFGresult
1X1X1XX1
1X011XX1
011X1XX1
01011XX1
00XXX111
1X00X111
0100X111
1X1X0111
1X010111
011X0111
01010111
00XXX0X0
00XXX100
1X00X0X0
1X00X100
0100X0X0
0100X100
1X1X00X0
1X1X0100
1X0100X0
1X010100
011X00X0
011X0100
010100X0
01010100
180 3 $m = $c;
181 3 $s2 = 0;
182 # $s2 = 0 if $c2 =~ /[\s\)\]]/ && $self->squishmode;
183 } elsif ($TERMSPACE{$c}) {
184 3 $m = $c;
185 # $s2 = 0 if $c2 =~ /[\s\)\]]/ && $self->squishmode;
186 } elsif ($c eq ',') {
187 0 $m = $c;
188 0 $s1 = 0;
189 } else {
190 33 return 0;
191 }
192 8 ▶ $self->set_char(' ') if $s1;
Branch: 1 branch
BranchTrueFalseTotal
if $s1 3 5 8
193 8 $self->set_char($m);
194 8 ▶ $self->set_char(' ') if $s2;
Branch: 1 branch
BranchTrueFalseTotal
if $s2 1 7 8
195
196 8 return 1;
197 }
198  
199 62 ▶sub parser_default {
Subroutine parser_default: called CC=39 SCAR=48.0
Pod undocumented
200 62 my $self = shift;
201 62 my $c = $self->get_char;
202 62 my $c2 = $self->get_char(1);
203  
204 62 ▶ return if $c =~ /\s/o && ($self->get_charlast =~ /\s/ || $c2 !~ /[_a-zA-Z0-9]/);
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ /\s/o and $self->get_charlast =~ /\s/ || !($c2 =~ /[_a-zA-Z0-9]/) 9 53 62
Condition83%5/6
$c =~ /\s/o and $self->get_charlast =~ /\s/ || !($c2 =~ /[_a-zA-Z0-9]/)
!ll&&!rl&&r
4679
$self->get_charlast =~ /\s/ or not $c2 =~ /[_a-zA-Z0-9]/
l!l&&r!l&&!r
097
MC/DC66%2/3
$c =~ /\s/o and $self->get_charlast =~ /\s/ || !($c2 =~ /[_a-zA-Z0-9]/)
$c =~ /\s/o $self->get_charlast =~ /\s/ not $c2 =~ /[_a-zA-Z0-9]/
Truth table75%3/4
A and B or not(C)
A= $c =~ /\s/oB= $self->get_charlast =~ /\s/C= not $c2 =~ /[_a-zA-Z0-9]/
ABCresult
0XX0
1000
11X1
1011
205  
206 53 ▶ if ($c eq '/') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "/") 0 53 53
207 0 ▶ if ($c2 eq '*') {
Branch: 3 branches
BranchTrueFalseTotal
if ($c2 eq '*') { } 0 0 0
elsif ($c2 eq '/') { } 0 0 0
elsif ($self->is_re_before) { } 0 0 0
208 0 $self->method('comment');
209 0 $self->add_cursor;
210 0 $self->add_indent;
211 0 $self->set_char('/*', 1);
212 0 $self->set_lf;
213 0 return;
214 } elsif ($c2 eq '/') {
215 0 $self->method('comment_line');
216 0 $self->add_cursor;
217 0 ▶ $self->set_char('//', 1) unless $self->squishmode;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->squishmode 0 0 0
218 0 return;
219 } elsif ($self->is_re_before) {
220 0 $self->method('regularexpression');
221 0 $self->set_char('/');
222 0 return;
223 }
224 }
225  
226 53 my $bword = $self->re_word;
227 53 ▶ if ($c =~ /\s/o && $c2 =~ /\s/o) {
Branch: 11 branches
BranchTrueFalseTotal
if ($c =~ /\s/o and $c2 =~ /\s/o) { } 0 53 53
elsif ($c eq '"' or $c eq q[']) { } 0 53 53
elsif ($c eq '(') { } 2 51 53
elsif ($c eq ')') { } 2 49 51
elsif ($c eq '{') { } 2 47 49
elsif ($c eq '}') { } 2 45 47
elsif ($c eq ';') { } 4 41 45
elsif ($self->squishmode and $c eq 'i' and $bword eq 'else') { } 0 41 41
elsif ($self->term_spacer($c, $c2)) { } 8 33 41
elsif ($self->squishmode and $c =~ /\s/o and not $self->get_charlast =~ /[_a-zA-Z0-9]/ && $c2 =~ /[_a-zA-Z0-9]/) { } 3 30 33
elsif ($c ne "\n") { } 30 0 30
Condition66%2/3
$c =~ /\s/o and $c2 =~ /\s/o
!ll&&!rl&&r
4670
MC/DC0%0/2
$c =~ /\s/o and $c2 =~ /\s/o
$c =~ /\s/o $c2 =~ /\s/o
Truth table66%2/3
A and B
A= $c =~ /\s/oB= $c2 =~ /\s/o
ABresult
0X0
100
111
228 0 $self->add_cursor;
229 ▶ } elsif ($c eq '"' || $c eq '\'') {
Condition33%1/3
$c eq "\"" or $c eq "'"
l!l&&r!l&&!r
0053
MC/DC0%0/2
$c eq "\"" or $c eq "'"
$c eq "\"" $c eq "'"
Truth table33%1/3
A or B
A= $c eq "\""B= $c eq "'"
ABresult
1X1
011
000
230 0 $self->method('quote');
231 0 $self->set_char($c, 1);
232 0 $self->quote($c);
233  
234  
235 } elsif ($c eq '(') {
236 2 ▶ $self->set_char(' ', 1)
Branch: 1 branch
BranchTrueFalseTotal
if $bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/o and not $self->squishmode 1 1 2
Condition66%2/3
$bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/o and not $self->squishmode
!ll&&!rl&&r
011
MC/DC50%1/2
$bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/o and not $self->squishmode
$bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/o not $self->squishmode
Truth table66%2/3
A and not(B)
A= $bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/oB= not $self->squishmode
ABresult
0X0
100
111
237 if $bword =~ /^(case|catch|do|for|function|if|import|switch|throw|try|while|with)$/o && !$self->squishmode;
238 2 $self->set_char('(');
239 2 $self->add_parentheses_nest;
240 } elsif ($c eq ')') {
241 2 ▶ if ($self->parentheses_nest) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->parentheses_nest) { } 2 0 2
242 2 $self->set_char(')');
243 2 $self->dec_parentheses_nest;
244 } else {
245 0 $self->set_char(')');
246 }
247 2 ▶ $self->set_char(' ') if $c2 =~ /[\_a-z-A-Z0-9]/;
Branch: 1 branch
BranchTrueFalseTotal
if $c2 =~ /[\_a-z-A-Z0-9]/ 0 2 2
248 } elsif ($c eq '{') {
249 2 ▶ $self->set_char(' ', 1)
Branch: 1 branch
BranchTrueFalseTotal
if $bword =~ /^(case|catch|do|try|else|\))$/o and not $self->squishmode 1 1 2
Condition66%2/3
$bword =~ /^(case|catch|do|try|else|\))$/o and not $self->squishmode
!ll&&!rl&&r
011
MC/DC50%1/2
$bword =~ /^(case|catch|do|try|else|\))$/o and not $self->squishmode
$bword =~ /^(case|catch|do|try|else|\))$/o not $self->squishmode
Truth table66%2/3
A and not(B)
A= $bword =~ /^(case|catch|do|try|else|\))$/oB= not $self->squishmode
ABresult
0X0
100
111
250 if $bword =~ /^(case|catch|do|try|else|\))$/o && !$self->squishmode;
251 2 $self->add_indent;
252 2 $self->set_char('{');
253 2 ▶ $self->set_lf unless $c2 eq '}';
Branch: 1 branch
BranchTrueFalseTotal
unless $c2 eq "}" 2 0 2
254 } elsif ($c eq '}') {
255 2 $self->dec_indent;
256 2 $self->set_lf;
257 2 $self->set_char('}');
258 2 ▶ if ($c2 eq ';') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c2 eq ";") 0 2 2
259 0 $self->add_cursor;
260 0 $self->set_char(';');
261 }
262 2 ▶ if ($c2 ne '}') {
Branch: 1 branch
BranchTrueFalseTotal
if ($c2 ne "}") 2 0 2
263 2 $self->set_lf;
264 }
265 } elsif ($c eq ';') {
266 4 $self->set_char(';');
267 4 ▶ if ($self->parentheses_nest && !$self->squishmode) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->parentheses_nest and not $self->squishmode) { } 0 4 4
elsif ($c2 ne '}') { } 3 1 4
Condition33%1/3
$self->parentheses_nest and not $self->squishmode
!ll&&!rl&&r
400
MC/DC0%0/2
$self->parentheses_nest and not $self->squishmode
$self->parentheses_nest not $self->squishmode
Truth table33%1/3
A and not(B)
A= $self->parentheses_nestB= not $self->squishmode
ABresult
0X0
100
111
268 0 $self->set_char(' ');
269 } elsif ($c2 ne '}') {
270 3 $self->set_lf;
271 }
272 ▶ } elsif ($self->squishmode && $c eq 'i' && $bword eq 'else') {
Condition83%5/6
$self->squishmode and $c eq "i" and $bword eq "else"
!ll&&!rl&&r
3830
$self->squishmode and $c eq "i"
!ll&&!rl&&r
19193
MC/DC0%0/3
$self->squishmode and $c eq "i" and $bword eq "else"
$self->squishmode $c eq "i" $bword eq "else"
Truth table75%3/4
A and B and C
A= $self->squishmodeB= $c eq "i"C= $bword eq "else"
ABCresult
0XX0
10X0
1100
1111
273 0 $self->set_char(' ');
274 0 $self->set_char('i');
275 } elsif ($self->term_spacer($c, $c2)) {
276 ▶ } elsif ($self->squishmode && $c =~ /\s/o && ($self->get_charlast !~ /[_a-zA-Z0-9]/ || $c2 !~ /[_a-zA-Z0-9]/)) {
Condition88%8/9
$self->squishmode and $c =~ /\s/o and not $self->get_charlast =~ /[_a-zA-Z0-9]/ && $c2 =~ /[_a-zA-Z0-9]/
!ll&&!rl&&r
2823
$self->squishmode and $c =~ /\s/o
!ll&&!rl&&r
15135
$self->get_charlast =~ /[_a-zA-Z0-9]/ && $c2 =~ /[_a-zA-Z0-9]/
!ll&&!rl&&r
302
MC/DC75%3/4
$self->squishmode and $c =~ /\s/o and not $self->get_charlast =~ /[_a-zA-Z0-9]/ && $c2 =~ /[_a-zA-Z0-9]/
$self->squishmode $c =~ /\s/o $self->get_charlast =~ /[_a-zA-Z0-9]/ $c2 =~ /[_a-zA-Z0-9]/
Truth table80%4/5
A and B and not(C && D)
A= $self->squishmodeB= $c =~ /\s/oC= $self->get_charlast =~ /[_a-zA-Z0-9]/D= $c2 =~ /[_a-zA-Z0-9]/
ABCDresult
0XXX0
10XX0
11110
110X1
11101
277 } elsif ($c ne "\n") {
278 30 $self->set_char($c);
279 }
280 }
281 0 ▶sub parser_comment {
Subroutine parser_comment: not called CC=4 SCAR=30.0
Pod undocumented
282 0 my $self = shift;
283 0 my $c = $self->get_char;
284 0 my $c2 = $self->get_char(1);
285  
286 0 ▶ if ($c eq '*' && $c2 eq '/') {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq '*' and $c2 eq '/') { } 0 0 0
elsif ($c eq "\n") { } 0 0 0
Condition0%0/3
$c eq "*" and $c2 eq "/"
!ll&&!rl&&r
000
MC/DC0%0/2
$c eq "*" and $c2 eq "/"
$c eq "*" $c2 eq "/"
Truth table0%0/3
A and B
A= $c eq "*"B= $c2 eq "/"
ABresult
0X0
100
111
287 0 $self->method('default');
288 0 $self->add_cursor;
289 0 $self->dec_indent;
290 0 $self->set_lf;
291 0 $self->set_char('*/', 1);
292 0 $self->set_lf;
293 } elsif ($c eq "\n") {
294 0 $self->set_lf;
295 } else {
296 0 $self->set_char($c, 1);
297 }
298 }
299 0 ▶sub parser_comment_line {
Subroutine parser_comment_line: not called CC=3 SCAR=24.8
Pod undocumented
300 0 my $self = shift;
301 0 my $c = $self->get_char;
302  
303 0 ▶ if ($c eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\n") { } 0 0 0
304 0 $self->set_lf;
305 0 $self->method('default');
306 } else {
307 0 ▶ $self->set_char($c, 1) unless $self->squishmode;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->squishmode 0 0 0
308 }
309 }
310 0 ▶sub parser_quote {
Subroutine parser_quote: not called CC=2 SCAR=17.9
Pod undocumented
311 0 my $self = shift;
312 0 my $c = $self->get_char;
313  
314 0 $self->set_char($c, 1);
315 0 ▶ if ($c eq $self->quote) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq $self->quote) 0 0 0
316 0 $self->quote('');
317 0 $self->method('default');
318 }
319 }
320 0 ▶sub parser_regularexpression {
Subroutine parser_regularexpression: not called CC=3 SCAR=24.8
Pod undocumented
321 0 my $self = shift;
322 0 my $c = $self->get_char;
323  
324 0 ▶ if ($c eq '/' || $c eq "\n") {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq '/' or $c eq "\n") { } 0 0 0
Condition0%0/3
$c eq "/" or $c eq "\n"
l!l&&r!l&&!r
000
MC/DC0%0/2
$c eq "/" or $c eq "\n"
$c eq "/" $c eq "\n"
Truth table0%0/3
A or B
A= $c eq "/"B= $c eq "\n"
ABresult
1X1
011
000
325 0 $self->set_char($c);
326 0 $self->method('default');
327 } else {
328 0 $self->set_char($c, 1);
329 }
330 }
331  
332 2 ▶sub parser {
Subroutine parser: called CC=6 SCAR=19.2
Pod undocumented
333 2 my $self = shift;;
334 2 ▶ $self->source(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 0 2
335  
336 2 $self->init_parser;
337  
338 2 ▶ while ($self->cursor < $self->split_source) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cursor < $self->split_source) 62 2 64
339 62 my $c = $self->get_char;
340 62 ▶ if ($c eq '\\') {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq '\\') { } 0 62 62
elsif ($self->is_linehead and $c =~ /\s/) { } 0 62 62
341 0 $self->set_char($c, 1);
342 0 $self->set_char($self->get_char(1), 1);
343 0 $self->add_cursor;
344 ▶ } elsif ($self->is_linehead && ($c =~ /\s/)) {
Condition66%2/3
$self->is_linehead and $c =~ /\s/
!ll&&!rl&&r
6020
MC/DC0%0/2
$self->is_linehead and $c =~ /\s/
$self->is_linehead $c =~ /\s/
Truth table66%2/3
A and B
A= $self->is_lineheadB= $c =~ /\s/
ABresult
0X0
100
111
345 } else {
346 62 $self->is_linehead(0);
347 62 my $method = 'parser_' . $self->method;
348 62 $self->$method();
349 }
350 62 $self->add_cursor;
351 }
352  
353 2 $self->source;
354 }
355  
356 1 ▶sub swell {
Subroutine swell: called CC=2 SCAR=7.2
Pod documented
357 1 my $self;
358 1 ▶ if (ref($_[0]) eq __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq __PACKAGE__) { } 0 1 1
359 0 $self = shift;
360 } else {
361 1 $self = shift->new;
362 }
363 1 $self->squishmode(0);
364 1 $self->parser(@_);
365 }
366  
367 1 ▶sub squish {
Subroutine squish: called CC=2 SCAR=7.2
Pod documented
368 1 my $self;
369 1 ▶ if (ref($_[0]) eq __PACKAGE__) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq __PACKAGE__) { } 0 1 1
370 0 $self = shift;
371 } else {
372 1 $self = shift->new;
373 }
374 1 $self->squishmode(1);
375 1 $self->parser(@_);
376 }
377  
378 2 1;
379 __END__
↑ Summary