CljPerl/Reader.pm

filter: Statementstmt 88.9% 233 / 262 Branchbran 79.2% 111 / 140 Conditioncond 74.2% 49 / 66 MC/DCmcdc 31.0% 9 / 29 Subroutinesub 86.2% 25 / 29 Podpod 0.0% 0 / 23 totaltotal 77.7% 427 / 549 CC 93 SCAR 23.7
CC
93
Cov
84%
lex
19.9
string
19.1
symbol
13.3
CRAP 10.7
« CljPerl/Printer.pm ↑ Summary CljPerl/SocketServer.pm »
1 package CljPerl::Reader;
2
3 2 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶ use CljPerl::Seq;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶ use CljPerl::Atom;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶ use CljPerl::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 2 our $VERSION = '0.10';
10
11 9 ▶ sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 9 my $class = shift;
13 9 my $self = {class => $class,
14 ast => {},
15 nest => 0,
16 filehandler => undef,
17 filename => "unknown",
18 line => 1,
19 col => 1};
20 9 bless $self;
21 9 return $self;
22 }
23
24 0 ▶ sub class {
Subroutine class: not called CC=1 SCAR=6.9
Pod undocumented
25 0 my $self = shift;
26 0 return $self->{class};
27 }
28
29 39744 ▶ sub filehandler {
Subroutine filehandler: called CC=2 SCAR=6.9
Pod undocumented
30 39744 my $self = shift;
31 39744 my $fh = shift;
32 39744 ▶ if(defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) { } 9 39735 39744
33 9 $self->{filehandler} = $fh;
34 } else {
35 39735 return $self->{filehandler};
36 }
37 }
38
39 2629 ▶ sub filename {
Subroutine filename: called CC=2 SCAR=6.9
Pod undocumented
40 2629 my $self = shift;
41 2629 my $fn = shift;
42 2629 ▶ if(defined $fn) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fn) { } 9 2620 2629
43 9 $self->{filename} = $fn;
44 } else {
45 2620 return $self->{filename};
46 }
47 }
48
49 3691 ▶ sub line {
Subroutine line: called CC=2 SCAR=6.9
Pod undocumented
50 3691 my $self = shift;
51 3691 my $line = shift;
52 3691 ▶ if(defined $line) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $line) { } 540 3151 3691
53 540 $self->{line} = $line;
54 } else {
55 3151 return $self->{line};
56 };
57 }
58
59 20788 ▶ sub col {
Subroutine col: called CC=2 SCAR=6.9
Pod undocumented
60 20788 my $self = shift;
61 20788 my $col = shift;
62 20788 ▶ if(defined $col) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $col) { } 9354 11434 20788
63 9354 $self->{col} = $col;
64 } else {
65 11434 return $self->{col};
66 };
67 }
68
69 9 ▶ sub ast {
Subroutine ast: called CC=1 SCAR=0.0
Pod undocumented
70 9 my $self = shift;
71 9 return $self->{ast};
72 }
73
74 30390 ▶ sub peekc {
Subroutine peekc: called CC=3 SCAR=11.0
Pod undocumented
75 30390 my $self = shift;
76 30390 my $fh = $self->filehandler();
77 30390 ▶ die "file handler is un-defined" if(!defined $fh);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 30390 30390
78 30390 my $c = undef;
79 30390 ▶ if(!eof($fh)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eof $fh) 30381 9 30390
80 30381 $c = getc($fh);
81 30381 seek($fh, -1, 1);
82 }
83 30390 return $c;
84 }
85
86 9345 ▶ sub readc {
Subroutine readc: called CC=3 SCAR=11.0
Pod undocumented
87 9345 my $self = shift;
88 9345 my $fh = $self->filehandler();
89 9345 my $c = $self->peekc();
90 9345 ▶ if(defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 9345 0 9345
91 9345 ▶ if($c eq "\n"){
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "\n") { } 531 8814 9345
92 531 $self->line(1 + $self->line());
93 531 $self->col(1);
94 } else {
95 8814 $self->col(1 + $self->col());
96 };
97 9345 seek($fh, 1, 1);
98 };
99 9345 return $c;
100 }
101
102 8884 ▶ sub consume {
Subroutine consume: called CC=2 SCAR=6.9
Pod undocumented
103 8884 my $self = shift;
104 8884 my $offset = shift;
105 8884 ▶ for(my $i=0; $i<$offset; $i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $offset) 8884 8884 17768
106 8884 $self->readc();
107 }
108 }
109
110 7763 ▶ sub skip_blanks {
Subroutine skip_blanks: called CC=5 SCAR=16.1
Pod undocumented
111 7763 my $self = shift;
112 7763 my $c = undef;
113 7763 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $c or do { do { $c = $self->peekc; if (defined $c) { if ($c eq ";") { $self->consume(1); $self->comment; } elsif ($c =~ /\s/) { $self->consume(1); } else { $c = undef; } ; } else { $c = undef; } } } 7763 2367 10130
114 10130 $c = $self->peekc();
115 10130 ▶ if(defined $c){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) { } 10121 9 10130
116 10121 ▶ if($c eq ";"){
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq ';') { } 25 10096 10121
elsif ($c =~ /\s/) { } 2342 7754 10096
117 25 $self->consume(1);
118 25 $self->comment();
119 } elsif($c =~ /\s/) {
120 2342 $self->consume(1);
121 } else {
122 7754 $c = undef;
123 }
124 } else {
125 9 $c = undef;
126 }
127 } until ! defined $c;
128 }
129
130 9 ▶ sub parse {
Subroutine parse: called CC=8 SCAR=20.9
Pod undocumented
131 9 my $self = shift;
132 9 my $file_or_str = shift;
133 9 my $mode = shift;
134 9 ▶ $mode = "string" if !defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 2 7 9
135 9 my $fh = undef;
136 9 ▶ if($mode eq "string"){
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq 'string') { } 2 7 9
137 2 ▶ open $fh, "<", \$file_or_str or die "cannot read string $file_or_str";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", \$file_or_str or die "cannot read string $file_or_str" 2 0 2
138 } else {
139 7 ▶ open $fh, "<", $file_or_str or die "cannot open file $file_or_str";
Branch: 1 branch
BranchTrueFalseTotal
open $fh, "<", $file_or_str or die "cannot open file $file_or_str" 7 0 7
140 };
141 9 $self->filehandler($fh);
142 9 $self->filename($file_or_str);
143 9 $self->line(1);
144 9 $self->col(1);
145 9 my $ast = CljPerl::Seq->new();
146 9 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
eof $fh or do { do { $self->skip_blanks; my $r = $self->lex; $ast->append($r) if defined $r } } 9 156 165
147 165 $self->skip_blanks();
148 165 my $r = $self->lex();
149 165 ▶ $ast->append($r) if defined $r;
Branch: 1 branch
BranchTrueFalseTotal
if defined $r 165 0 165
150 } until eof($fh);
151 9 $self->{ast} = $ast;
152 9 ▶ close $fh if $mode ne "string";
Branch: 1 branch
BranchTrueFalseTotal
if $mode ne "string" 7 2 9
153 }
154
155 7 ▶ sub read_file {
Subroutine read_file: called CC=1 SCAR=0.0
Pod undocumented
156 7 my $self = shift;
157 7 my $file = shift;
158 7 $self->parse($file, "file");
159 }
160
161 2 ▶ sub read_string {
Subroutine read_string: called CC=1 SCAR=0.0
Pod undocumented
162 2 my $self = shift;
163 2 my $str = shift;
164 2 $self->parse($str);
165 }
166
167 0 ▶ sub show {
Subroutine show: not called CC=2 SCAR=17.9
Pod undocumented
168 0 my $self = shift;
169 0 my $indent = shift;
170 0 ▶ $indent = "" if !defined $indent;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $indent 0 0 0
171 0 $self->{ast}->show($indent);
172 }
173
174 2732 ▶ sub lex {
Subroutine lex: called CC=19 SCAR=29.9
Pod undocumented
175 2732 my $self = shift;
176 2732 my $c = $self->peekc();
177 2732 ▶ if(defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 2732 0 2732
178 2732 ▶ if($c eq '(') {
Branch: 13 branches
BranchTrueFalseTotal
if ($c eq '(') { } 551 2181 2732
elsif ($c eq '"') { } 74 2107 2181
elsif ($c =~ /\d/) { } 48 2059 2107
elsif ($c eq '[') { } 107 1952 2059
elsif ($c eq '{') { } 16 1936 1952
elsif ($c eq '#') { } 39 1897 1936
elsif ($c eq '^') { } 8 1889 1897
elsif ($c eq ':') { } 38 1851 1889
elsif ($c eq q[']) { } 42 1809 1851
elsif ($c eq '`') { } 33 1776 1809
elsif ($c eq '~') { } 54 1722 1776
elsif ($c eq ';') { } 0 1722 1722
elsif ($c eq ')' || $c eq ']' || $c eq '}' and $self->{'nest'} == 0) { } 0 1722 1722
179 551 return $self->seq("list", "(", ")");
180 } elsif($c eq '"') {
181 74 return $self->string();
182 } elsif($c =~ /\d/) {
183 48 return $self->number();
184 } elsif($c eq '[') {
185 107 return $self->seq("vector", "[", "]");
186 } elsif($c eq '{') {
187 16 return $self->seq("map", "{", "}");
188 } elsif($c eq '#') {
189 39 $self->consume(1);
190 39 return $self->dispatch();
191 } elsif($c eq '^') {
192 8 $self->consume(1);
193 8 ▶ $self->error("meta should be a map") if $self->peekc() ne "{";
Branch: 1 branch
BranchTrueFalseTotal
if $self->peekc ne "{" 0 8 8
194 8 my $md = $self->lex();
195 8 $md->type("meta");
196 8 return $md;
197 } elsif($c eq ':') {
198 38 $self->consume(1);
199 38 my $k = $self->symbol();
200 38 $k->type("keyword");
201 38 return $k;
202 } elsif($c eq "'") {
203 42 $self->consume(1);
204 42 my $q = $self->lex();
205 42 return CljPerl::Atom->new("quotation", $q);
206 } elsif($c eq "`") {
207 33 $self->consume(1);
208 33 my $sq = $self->lex();
209 33 return CljPerl::Atom->new("syntaxquotation", $sq);
210 } elsif($c eq "~") {
211 54 $self->consume(1);
212 54 my $dq = $self->symbol();
213 54 $dq->type("dequotation");
214 54 return $dq;
215 #} elsif($c eq "@") {
216 # $self->consume(1);
217 # my $dr = $self->symbol();
218 #$dr->type("deref");
219 #return $dr;
220 } elsif($c eq ";") {
221 0 $self->consume(1);
222 0 $self->comment();
223 0 return undef;
224 ▶ } elsif(($c eq ')' or $c eq ']' or $c eq '}')
Condition88%8/9
$c eq ")" || $c eq "]" || $c eq "}" and $self->{"nest"} == 0
!ll&&!rl&&r
10386840
$c eq ")" or $c eq "]" or $c eq "}"
l!l&&r!l&&!r
668161038
$c eq ")" or $c eq "]"
l!l&&r!l&&!r
5511171054
MC/DC0%0/4
$c eq ")" || $c eq "]" || $c eq "}" and $self->{"nest"} == 0
$c eq ")" $c eq "]" $c eq "}" $self->{"nest"} == 0
Truth table57%4/7
A or B or C and D
A= $c eq ")"B= $c eq "]"C= $c eq "}"D= $self->{"nest"} == 0
ABCDresult
000X0
1XX00
01X00
00100
1XX11
01X11
00111
225 and $self->{nest} == 0) {
226 0 $self->error("unexpected " . $c);
227 } else {
228 1722 return $self->symbol();
229 };
230 };
231 0 return undef;
232 }
233
234 39 ▶ sub dispatch {
Subroutine dispatch: called CC=5 SCAR=16.6
Pod undocumented
235 39 my $self = shift;
236 39 my $c = $self->peekc();
237 39 ▶ if(defined $c) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 39 0 39
238 39 ▶ if($c eq ":") {
Branch: 3 branches
BranchTrueFalseTotal
if ($c eq ':') { } 28 11 39
elsif ($c eq '!') { } 1 10 11
elsif ($c eq '[') { } 10 0 10
239 28 $self->consume(1);
240 28 return CljPerl::Atom->new("accessor", $self->lex());
241 } elsif($c eq "!") {
242 1 $self->consume(1);
243 1 return CljPerl::Atom->new("sender", $self->lex());
244 } elsif($c eq '[') {
245 10 return $self->seq("xml", "[", "]");
246 } else {
247 0 $self->error("unsupport syntax for disptacher");
248 };
249 };
250 0 return undef;
251 };
252
253 25 ▶ sub comment {
Subroutine comment: called CC=4 SCAR=13.9
Pod undocumented
254 25 my $self = shift;
255 25 my $c = undef;
256 25 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $c or do { do { $c = $self->readc; if (defined $c and $c eq "\n") { $c = undef; } } } 25 436 461
257 461 $c = $self->readc();
258 461 ▶ if(defined $c and $c eq "\n"){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c eq "\n") 25 436 461
Condition66%2/3
defined $c and $c eq "\n"
!ll&&!rl&&r
043625
MC/DC50%1/2
defined $c and $c eq "\n"
defined $c $c eq "\n"
Truth table66%2/3
A and B
A= defined $cB= $c eq "\n"
ABresult
0X0
100
111
259 25 $c = undef;
260 }
261 } until ! defined $c;
262 25 $self->skip_blanks();
263
264 25 return undef;
265 }
266
267 74 ▶ sub string {
Subroutine string: called CC=15 SCAR=29.5
Pod undocumented
268 74 my $self = shift;
269 74 my $c = undef;
270 74 my $s = CljPerl::Atom->new("string");
271 74 $s->{pos} = {filename=>$self->filename(),
272 line=>$self->line(),
273 col=>$self->col()};
274 74 $self->consume(1);
275 74 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $c or do { do { $c = $self->peekc; if (defined $c) { if ($c eq "\\") { $self->consume(1); my $nc = $self->peekc; $self->error("unexpected eof") unless defined $nc; $self->consume(1); my $rc = $nc; if ($nc eq "a") { $rc = "\a"; } elsif ($nc eq "b") { $rc = "\b"; } elsif ($nc eq "e") { $rc = "\e"; } elsif ($nc eq "f") { $rc = "\f"; } elsif ($nc eq "n") { $rc = "\n"; } elsif ($nc eq "r") { $rc = "\r"; } elsif ($nc eq "t") { $rc = "\t"; } ; $s->{"value"} .= $rc; } elsif ($c ne "\"") { $s->{"value"} .= $c; $self->consume(1); } else { $c = undef; } ; } } } 74 273 347
276 347 $c = $self->peekc();
277 347 ▶ if(defined $c){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 347 0 347
278 347 ▶ if($c eq "\\") {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq '\\') { } 10 337 347
elsif ($c ne '"') { } 263 74 337
279 10 $self->consume(1);
280 10 my $nc = $self->peekc();
281 10 ▶ $self->error("unexpected eof") if !defined $nc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $nc 0 10 10
282 10 $self->consume(1);
283 10 my $rc = $nc;
284 10 ▶ if($nc eq "a") {
Branch: 7 branches
BranchTrueFalseTotal
if ($nc eq 'a') { } 0 10 10
elsif ($nc eq 'b') { } 0 10 10
elsif ($nc eq 'e') { } 0 10 10
elsif ($nc eq 'f') { } 0 10 10
elsif ($nc eq 'n') { } 4 6 10
elsif ($nc eq 'r') { } 0 6 6
elsif ($nc eq 't') { } 1 5 6
285 0 $rc = "\a";
286 } elsif($nc eq "b") {
287 0 $rc = "\b";
288 } elsif($nc eq "e") {
289 0 $rc = "\e";
290 } elsif($nc eq "f") {
291 0 $rc = "\f";
292 } elsif($nc eq "n") {
293 4 $rc = "\n";
294 } elsif($nc eq "r") {
295 0 $rc = "\r";
296 } elsif($nc eq "t") {
297 1 $rc = "\t";
298 };
299 10 $s->{value} .= $rc;
300 } elsif($c ne '"') {
301 263 $s->{value} .= $c;
302 263 $self->consume(1);
303 } else {
304 74 $c = undef;
305 };
306 };
307 } until ! defined $c;
308 74 $c = $self->peekc();
309 74 ▶ if(defined $c and $c eq '"'){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c eq '"') { } 74 0 74
Condition33%1/3
defined $c and $c eq "\""
!ll&&!rl&&r
0074
MC/DC0%0/2
defined $c and $c eq "\""
defined $c $c eq "\""
Truth table33%1/3
A and B
A= defined $cB= $c eq "\""
ABresult
0X0
100
111
310 74 $self->consume(1);
311 } else {
312 0 $self->error("expect \"");
313 }
314 74 $self->skip_blanks();
315 74 return $s;
316 }
317
318 48 ▶ sub number {
Subroutine number: called CC=12 SCAR=25.4
Pod undocumented
319 48 my $self = shift;
320 48 my $c = undef;
321 48 my $n = CljPerl::Atom->new("number");
322 48 $n->{pos} = {filename=>$self->filename(),
323 line=>$self->line(),
324 col=>$self->col()};
325 48 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $c or do { do { $c = $self->peekc; if (defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}") { if ($c =~ m[[\+\-\d\.xXabcdefABCDEF/\_]]) { $self->consume(1); $n->{"value"} .= $c; } else { $self->error('unexpect letter ' . $c . ' for number'); } ; } else { $c = undef; } } } 48 64 112
326 112 $c = $self->peekc();
327 112 ▶ if(defined $c
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c =~ /\S/ and $c ne ';' and $c ne '(' and $c ne ')' and $c ne '[' and $c ne ']' and $c ne '{' and $c ne '}') { } 64 48 112
Condition79%19/24
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}"
!ll&&!rl&&r
46264
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{"
!ll&&!rl&&r
46066
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]"
!ll&&!rl&&r
44266
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "["
!ll&&!rl&&r
44068
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")"
!ll&&!rl&&r
192568
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "("
!ll&&!rl&&r
19093
defined $c and $c =~ /\S/ and $c ne ";"
!ll&&!rl&&r
19093
defined $c and $c =~ /\S/
!ll&&!rl&&r
01993
MC/DC44%4/9
defined $c and $c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}"
defined $c $c =~ /\S/ $c ne ";" $c ne "(" $c ne ")" $c ne "[" $c ne "]" $c ne "{" $c ne "}"
Truth table50%5/10
A and B and C and D and E and F and G and H and I
A= defined $cB= $c =~ /\S/C= $c ne ";"D= $c ne "("E= $c ne ")"F= $c ne "["G= $c ne "]"H= $c ne "{"I= $c ne "}"
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110XXXXXX0
1110XXXXX0
11110XXXX0
111110XXX0
1111110XX0
11111110X0
1111111100
1111111111
328 and $c =~ /\S/
329 and $c ne ";"
330 and $c ne '(' and $c ne ')'
331 and $c ne '[' and $c ne ']'
332 and $c ne '{' and $c ne '}') {
333 64 ▶ if($c =~ /[\+\-\d\.xXabcdefABCDEF\/\_]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c =~ m[[\+\-\d\.xXabcdefABCDEF/\_]]) { } 64 0 64
334 64 $self->consume(1);
335 64 $n->{value} .= $c;
336 } else {
337 0 $self->error("unexpect letter " . $c . " for number");
338 };
339 } else {
340 48 $c = undef;
341 };
342 } until ! defined $c;
343 0 ▶ local $SIG{__WARN__} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
344 0 $n->error("invild number literal " . $n->{value});
345 48 };
346 48 $n->{value} = 0 + $n->{value};
347 48 delete $SIG{__WARN__};
348 48 $self->skip_blanks();
349 48 return $n;
350 }
351
352 1814 ▶ sub symbol {
Subroutine symbol: called CC=13 SCAR=25.9
Pod undocumented
353 1814 my $self = shift;
354 1814 my $c = undef;
355 1814 my $sym = CljPerl::Atom->new("symbol");
356 1814 $self->skip_blanks();
357 1814 $sym->{pos} = {filename=>$self->filename(),
358 line=>$self->line(),
359 col=>$self->col()};
360 1814 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $c or do { do { $c = $self->peekc; if (defined $c) { if ($c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}") { $self->error('unexpected letter ' . $c . ' for symbol') if $c =~ m([^0-9a-zA-Z_!&\?\*/\.\+\|=%\$<>#@\:\-\\]); $sym->{"value"} .= $c; $self->consume(1); } else { $c = undef; } ; } } } 1814 4411 6225
361 6225 $c = $self->peekc();
362 6225 ▶ if(defined $c){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c) 6225 0 6225
363 6225 ▶ if($c =~ /\S/
Branch: 1 branch
BranchTrueFalseTotal
if ($c =~ /\S/ and $c ne ';' and $c ne '(' and $c ne ')' and $c ne '[' and $c ne ']' and $c ne '{' and $c ne '}') { } 4411 1814 6225
Condition80%17/21
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}"
!ll&&!rl&&r
1790244411
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{"
!ll&&!rl&&r
179004435
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]"
!ll&&!rl&&r
15902004435
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "["
!ll&&!rl&&r
159004635
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")"
!ll&&!rl&&r
8357554635
$c =~ /\S/ and $c ne ";" and $c ne "("
!ll&&!rl&&r
83505390
$c =~ /\S/ and $c ne ";"
!ll&&!rl&&r
83505390
MC/DC50%4/8
$c =~ /\S/ and $c ne ";" and $c ne "(" and $c ne ")" and $c ne "[" and $c ne "]" and $c ne "{" and $c ne "}"
$c =~ /\S/ $c ne ";" $c ne "(" $c ne ")" $c ne "[" $c ne "]" $c ne "{" $c ne "}"
Truth table55%5/9
A and B and C and D and E and F and G and H
A= $c =~ /\S/B= $c ne ";"C= $c ne "("D= $c ne ")"E= $c ne "["F= $c ne "]"G= $c ne "{"H= $c ne "}"
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111110XX0
1111110X0
111111100
111111111
364 and $c ne ';'
365 and $c ne '(' and $c ne ')'
366 and $c ne '[' and $c ne ']'
367 and $c ne '{' and $c ne '}') {
368 4411 ▶ $self->error("unexpected letter " . $c . " for symbol")
Branch: 1 branch
BranchTrueFalseTotal
if $c =~ m([^0-9a-zA-Z_!&\?\*/\.\+\|=%\$<>#@\:\-\\]) 0 4411 4411
369 if $c =~ /[^0-9a-zA-Z_!&\?\*\/\.\+\|=%\$<>#@\:\-\\]/;
370 4411 $sym->{value} .= $c;
371 4411 $self->consume(1);
372 } else {
373 1814 $c = undef;
374 };
375 };
376 } until ! defined $c;
377 1814 $self->skip_blanks();
378 1814 ▶ if($sym->{value} eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sym->{'value'} eq '') { } 684 1130 1814
379 684 return undef;
380 } else {
381 1130 return $sym;
382 }
383 }
384
385 684 ▶ sub seq {
Subroutine seq: called CC=10 SCAR=24.2
Pod undocumented
386 684 my $self = shift;
387 684 my $type = shift;
388 684 my $begin = shift;
389 684 my $end = shift;
390 684 ▶ $type = "list" if !defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 684 684
391 684 ▶ $begin = "(" if !defined $begin;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $begin 0 684 684
392 684 ▶ $end = ")" if !defined $end;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $end 0 684 684
393 684 my $e = undef;
394 684 my $c = $self->peekc();
395 684 ▶ if(defined $c and $c eq $begin){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c eq $begin) { } 684 0 684
Condition33%1/3
defined $c and $c eq $begin
!ll&&!rl&&r
00684
MC/DC0%0/2
defined $c and $c eq $begin
defined $c $c eq $begin
Truth table33%1/3
A and B
A= defined $cB= $c eq $begin
ABresult
0X0
100
111
396 684 $self->consume(1);
397 } else {
398 0 $self->error("expect " . $begin);
399 };
400 684 $self->skip_blanks();
401 684 my $seq = CljPerl::Seq->new($type);
402 684 $seq->{pos} = {filename=>$self->filename(),
403 line=>$self->line(),
404 col=>$self->col()};
405 684 $self->{nest} += 1;
406 684 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not defined $e or do { do { $e = $self->lex; $self->skip_blanks; $seq->append($e) if defined $e } } 684 1771 2455
407 2455 $e = $self->lex();
408 2455 $self->skip_blanks();
409 2455 ▶ $seq->append($e) if defined $e;
Branch: 1 branch
BranchTrueFalseTotal
if defined $e 1771 684 2455
410 } until ! defined $e;
411 684 $c = $self->peekc();
412 684 ▶ if(defined $c and $c eq $end){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $c and $c eq $end) { } 684 0 684
Condition33%1/3
defined $c and $c eq $end
!ll&&!rl&&r
00684
MC/DC0%0/2
defined $c and $c eq $end
defined $c $c eq $end
Truth table33%1/3
A and B
A= defined $cB= $c eq $end
ABresult
0X0
100
111
413 684 $self->consume(1);
414 684 $self->{nest} -= 1;
415 } else {
416 0 $self->error("expect " . $end);
417 };
418 684 $self->skip_blanks();
419 684 return $seq;
420 }
421
422 0 ▶ sub error {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
423 0 my $self = shift;
424 0 my $msg = shift;
425 0 $msg .= " @[file: " . $self->filename();
426 0 $msg .= "; line: " . $self->line();
427 0 $msg .= "; col: " . $self->col() . "]";
428 0 CljPerl::Logger::error($msg);
429 }
430 2 1;
« CljPerl/Printer.pm ↑ Summary CljPerl/SocketServer.pm »