blib/lib/YATT/Lite/LRXML/ParseBody.pm

filter: Statementstmt 94.8% 165 / 174 Branchbran 86.8% 106 / 122 Conditioncond 81.1% 56 / 69 MC/DCmcdc 66.6% 28 / 42 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 86.7% 366 / 422 CC 86 SCAR 37.6
CC
86
Cov
90%
_parse_body
63.1
_parse_lcmsg
11.8
accept_leading_text
6.0
CRAP 43.1
« blib/lib/YATT/Lite/LanguageServer/Generic.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Partial/Session3.pm »
1 package YATT::Lite::LRXML::ParseBody; # dummy package, for lint.
2 48 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 48 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 48 ▶package YATT::Lite::LRXML; use YATT::Lite::LRXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 750 ▶sub _parse_body {
Subroutine _parse_body: called CC=62 SCAR=41.5
8 750 (my MY $self, my Widget $widget, my ($sink, $close, $parent, $par_ln)) = @_;
9 # $sink は最初、外側の $body 配列。
10 # <:option /> が出現した所から先は、 その option element の body が新しい $sink になる
11  
12 # XXX: 使い方の指針を解説せよ
13 # curpos, startln, endln
14  
15 750 my $has_nonspace; # 非空白文字が出現したか。 <:opt>HEAD</:opt> と BODY の間に
16 my $is_closed; # tag が閉じたか。
17  
18 750 my $last_foot; # last foot
19  
20 750 ▶ while (s{^(.*?)$$self{_re_body}}{}xs or my $retry = $self->_get_chunk($sink)) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^(.*?)$self->{"_re_body"}//sx or my $retry = $self->_get_chunk($sink)) 1723 637 2360
Condition100%3/3
s/^(.*?)$self->{"_re_body"}//sx or my $retry = $self->_get_chunk($sink)
l!l&&r!l&&!r
1146577637
MC/DC100%2/2
s/^(.*?)$self->{"_re_body"}//sx or my $retry = $self->_get_chunk($sink)
s/^(.*?)$self->{"_re_body"}//sx my $retry = $self->_get_chunk($sink)
Truth table100%3/3
A or B
A= s/^(.*?)$self->{"_re_body"}//sxB= my $retry = $self->_get_chunk($sink)
ABresult
1X1
011
000
21 1723 ▶ next if $retry;
Branch: 1 branch
BranchTrueFalseTotal
if $retry 577 1146 1723
22  
23 1146 my $startPos = $self->{_curpos} + length($1);
24  
25 1146 $self->accept_leading_text($sink, $parent, $par_ln, \$has_nonspace);
26  
27 1146 ▶ if ($+{lcmsg}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($+{'lcmsg'}) { } 5 1141 1146
elsif ($+{'entity'} or $+{'special'}) { } 585 556 1141
elsif (my $path = $+{'elem'}) { } 489 67 556
elsif ($path = $+{'pi'}) { } 67 0 67
28 5 ▶ if ($+{msgopn}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($+{'msgopn'}) { } 5 0 5
29 push @$sink, $self->_parse_lcmsg
30 5 ($+{entity}, $parent, $par_ln, \$has_nonspace);
31 } else {
32 die $self->synerror_at
33 0 ($self->{_startln}, q{Mismatched l10n msg});
34 }
35 ▶ } elsif ($+{entity} or $+{special}) {
Condition100%3/3
$+{"entity"} or $+{"special"}
l!l&&r!l&&!r
5832556
MC/DC100%2/2
$+{"entity"} or $+{"special"}
$+{"entity"} $+{"special"}
Truth table100%3/3
A or B
A= $+{"entity"}B= $+{"special"}
ABresult
1X1
011
000
36 # &yatt(?=:) までマッチしてる。
37 # XXX: space 許容モードも足すか。
38 585 $self->accept_entity($sink, $parent, $par_ln, \$has_nonspace);
39  
40 } elsif (my $path = $+{elem}) {
41 489 ▶ my $formal_path = ($+{opt} // '') . $+{elem};
Condition50%1/2
$+{"opt"} // ""
l!l
4890
MC/DC0%0/1
$+{"opt"} // ""
$+{"opt"}
Truth table50%1/2
A
A= $+{"opt"}
Aresult
11
00
42 489 ▶ if ($+{clo}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($+{"clo"}) 102 387 489
43 102 ▶ if ($last_foot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_foot) 16 86 102
44 16 $last_foot->[NODE_END] = $startPos;
45 }
46 102 $parent->[NODE_BODY_END] = $self->{_startpos};
47 102 ▶ if (defined $parent->[NODE_BODY_BEGIN]
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/) 78 24 102
Condition100%3/3
defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
!ll&&!rl&&r
12378
MC/DC100%2/2
defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
defined $parent->[5] $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
Truth table100%3/3
A and B
A= defined $parent->[5]B= $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
ABresult
0X0
100
111
48 and $self->{_template}->node_body_source($parent) =~ /(\r?\n)\Z/) {
49 78 $parent->[NODE_BODY_END] -= length $1;
50 }
51 102 $self->verify_tag($formal_path, $close);
52 96 ▶ if (@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//) 74 22 96
Condition100%6/6
@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//
!ll&&!rl&&r
71574
@$sink and not ref $sink->[-1]
!ll&&!rl&&r
1689
MC/DC100%3/3
@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//
@$sink not ref $sink->[-1] $sink->[-1] =~ s/(\r?\n)\Z//
Truth table100%4/4
A and not(B) and C
A= @$sinkB= not ref $sink->[-1]C= $sink->[-1] =~ s/(\r?\n)\Z//
ABCresult
0XX0
10X0
1100
1111
53 74 push @$sink, "\n";
54 }
55 # $self->add_lineinfo($sink);
56 96 $is_closed++;
57 96 last;
58 }
59 # /? > まで、その後、not ee なら clo まで。
60 387 my $is_opt = $+{opt};
61 387 my $elem = [];
62 387 ▶ $elem->[NODE_TYPE] = $is_opt ? TYPE_ATT_NESTED : TYPE_ELEMENT;
Branch: 1 branch
BranchTrueFalseTotal
$is_opt ? : 34 353 387
63 387 $elem->[NODE_BEGIN] = $self->{_startpos};
64 387 $elem->[NODE_LNO] = $self->{_endln};
65 387 $elem->[NODE_SYM_END] = $self->{_curpos};
66 387 $elem->[NODE_PATH] = [split /:/, $path];
67 387 $elem->[NODE_BODY] = undef;
68  
69 387 ▶ if (my @atts = $self->parse_attlist(\$_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@atts) = $self->parse_attlist(\$_)) 193 194 387
70 193 $elem->[NODE_ATTLIST] = \@atts;
71 }
72  
73 # タグの直後の改行は、独立したトークンにしておく
74 387 ▶ s{^(?<empty_elem>/)? >(\r?\n)?}{}xs or do {
Branch: 1 branch
BranchTrueFalseTotal
s[^(?<empty_elem>/)? >(\r?\n)?][]sx or do { my $diag = m[^\S*\s*?/?>] ? "Garbage before CLO(>)" : "Missing CLO(>)"; die $self->synerror_at($self->{"_startln"}, "%s for: <%s, rest: '%s'", $diag, $path, trimmed($_)) } 385 2 387
75 2 ▶ my $diag = m{^\S*\s*?/?>}
Branch: 1 branch
BranchTrueFalseTotal
m[^\S*\s*?/?>] ? : 2 0 2
76 ? "Garbage before CLO(>)"
77 : "Missing CLO(>)";
78 die $self->synerror_at($self->{_startln}
79 2 , q{%s for: <%s, rest: '%s'}
80 , $diag, $path, trimmed($_));
81 };
82  
83 385 ▶ ++$self->{_startln} if defined $2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 163 222 385
84  
85 # body slot の初期化
86 # $is_opt の時に、更に body を attribute として保存するのは冗長だし、後の処理も手間なので
87 385 my $body = [];
88 385 ▶ if (not $+{empty_elem} or $is_opt) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $+{"empty_elem"} or $is_opt) 127 258 385
Condition100%3/3
not $+{"empty_elem"} or $is_opt
l!l&&r!l&&!r
10423258
MC/DC100%2/2
not $+{"empty_elem"} or $is_opt
not $+{"empty_elem"} $is_opt
Truth table100%3/3
not(A) or B
A= not $+{"empty_elem"}B= $is_opt
ABresult
1X1
011
000
89 127 ▶ $elem->[NODE_BODY] = $is_opt ? $body : do {
Branch: 1 branch
BranchTrueFalseTotal
$is_opt ? : 34 93 127
90 93 my $att_node = [];
91 93 $att_node->[NODE_TYPE] = TYPE_ATTRIBUTE;
92 93 $att_node->[NODE_PATH] = $self->{body_argument};
93 93 $att_node->[NODE_BODY] = $body;
94 93 $att_node;
95 };
96 }
97  
98 385 ▶ my $bodyStartRef; $bodyStartRef = \ $elem->[NODE_BODY][NODE_LNO]
Branch: 1 branch
BranchTrueFalseTotal
if not $is_opt and $elem->[8] 93 292 385
Condition100%3/3
not $is_opt and $elem->[8]
!ll&&!rl&&r
3425893
MC/DC100%2/2
not $is_opt and $elem->[8]
not $is_opt $elem->[8]
Truth table100%3/3
not(A) and B
A= not $is_optB= $elem->[8]
ABresult
0X0
100
111
99 if not $is_opt and $elem->[NODE_BODY];
100  
101 385 ▶ $self->{_curpos} += 1 + ($1 ? length($1) : 0); # $& じゃないので注意。
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 281 104 385
102 385 ▶ $elem->[NODE_END] = $self->{_curpos} if $+{empty_elem};
Branch: 1 branch
BranchTrueFalseTotal
if $+{"empty_elem"} 281 104 385
103 385 ▶ $self->{_curpos} += length $2 if $2; # XXX: swap with below
Branch: 1 branch
BranchTrueFalseTotal
if $2 163 222 385
104 385 $elem->[NODE_BODY_BEGIN] = $self->{_curpos}; # XXX
105  
106 385 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 385 385
107  
108 385 ▶ if ($is_opt and not $+{empty_elem}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_opt and not $+{"empty_elem"}) 11 374 385
Condition100%3/3
$is_opt and not $+{"empty_elem"}
!ll&&!rl&&r
3512311
MC/DC100%2/2
$is_opt and not $+{"empty_elem"}
$is_opt not $+{"empty_elem"}
Truth table100%3/3
A and not(B)
A= $is_optB= not $+{"empty_elem"}
ABresult
0X0
100
111
109 11 drop_leading_ws($sink);
110 }
111  
112 385 ▶ if (not $is_opt) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $is_opt) { } 351 34 385
elsif ($+{'empty_elem'}) { } 23 11 34
113 351 push @$sink, $elem;
114 } elsif ($+{empty_elem}) {
115 # <:opt/> の時は $parent->[foot] へ
116 23 ▶ push @{$parent->[NODE_AELEM_FOOT] ||= []}, $elem;
Condition100%2/2
$parent->[11] ||= []
l!l
716
MC/DC100%1/1
$parent->[11] ||= []
$parent->[11]
Truth table100%2/2
A
A= $parent->[11]
Aresult
11
00
117 } else {
118 # <:opt> の時は, $parent->[head] へ
119 11 ▶ push @{$parent->[NODE_AELEM_HEAD] ||= []}, $elem
Condition50%1/2
$parent->[10] ||= []
l!l
011
MC/DC0%0/1
$parent->[10] ||= []
$parent->[10]
Truth table50%1/2
A
A= $parent->[10]
Aresult
11
00
120 }
121  
122 385 my $bodystartln = $self->{_endln};
123 # <TAG>\n タグ直後の改行について。
124 # <foo />\n だけは, 現在の $sink へ、それ以外は、今作る $elem の $body へ改行を足す
125 385 ▶ $self->{_endln}++, push @{!$is_opt && $+{empty_elem} ? $sink : $body}, "\n"
Branch: 2 branches
BranchTrueFalseTotal
if $2 163 222 385
!$is_opt && $+{'empty_elem'} ? : 78 85 163
Condition100%3/3
not $is_opt and $+{"empty_elem"}
!ll&&!rl&&r
186778
MC/DC100%2/2
not $is_opt and $+{"empty_elem"}
not $is_opt $+{"empty_elem"}
Truth table100%3/3
not(A) and B
A= not $is_optB= $+{"empty_elem"}
ABresult
0X0
100
111
126 if $2;
127  
128 385 ▶ unless ($is_opt) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_opt) { } 34 351 385
if (do { not $+{"empty_elem"} }) 11 23 34
129 351 ▶ $$par_ln = $self->{_startln} if not $has_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if not $has_nonspace++ and $parent 12 339 351
Condition100%3/3
not $has_nonspace++ and $parent
!ll&&!rl&&r
12421512
MC/DC100%2/2
not $has_nonspace++ and $parent
not $has_nonspace++ $parent
Truth table100%3/3
not(A) and B
A= not $has_nonspace++B= $parent
ABresult
0X0
100
111
130 0 } elsif (not $+{empty_elem}) {
131 # XXX: もし $is_opt かつ not ee だったら、
132 # $sink (親の $body) が空かどうかを調べる必要が有る。
133 # die $self->synerror_at(q{element option '%s' must precede body!}, $path)
134 # if $has_nonspace;
135 }
136 385 ▶ if (not $+{empty_elem}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $+{'empty_elem'}) { } 104 281 385
elsif ($is_opt) { } 23 258 281
137 # call <yatt:call> ... or complex option <:yatt:opt>
138 # expects </yatt:call> or </:yatt:opt>
139 # $self->{_startln} = $self->{_endln}; # No!
140 $self->_parse_body($widget, $body
141 104 ▶ , $+{empty_elem} ? $close : $formal_path
Branch: 1 branch
BranchTrueFalseTotal
$+{'empty_elem'} ? : 0 104 104
142 , $elem, $bodyStartRef);
143 #
144 # x substr($widget->{folder}->{string}, $elem->[NODE_BEGIN], $self->{_curpos} - $elem->[NODE_BEGIN])
145 # x $widget->{folder}->source_region($elem->[NODE_BEGIN], $self->{_curpos})
146 # x $self->{_template}->...
147  
148 #
149 96 $elem->[NODE_END] = $self->{_curpos};
150 96 ▶ $$bodyStartRef //= $bodystartln;
Condition66%2/3
$$bodyStartRef //= $bodystartln
l!l&&r!l&&!r
83130
MC/DC0%0/2
$$bodyStartRef //= $bodystartln
$$bodyStartRef $bodystartln
Truth table66%2/3
A //= B
A= $$bodyStartRefB= $bodystartln
ABresult
1X1
011
000
151 } elsif ($is_opt) {
152 # ee style option.
153 # <:yatt:foo/>bar 出現後は、以後の要素を att に加える。
154 23 $sink = $body;
155 23 ▶ if ($last_foot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_foot) 7 16 23
156 7 $last_foot->[NODE_END] = $startPos;
157 }
158 23 $last_foot = $elem;
159 } else {
160 } # simple call.
161 377 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 377 377
162 377 $self->add_lineinfo($sink);
163  
164 } elsif ($path = $+{pi}) {
165 67 ▶ $$par_ln = $self->{_startln} if not $has_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if not $has_nonspace++ and $parent 5 62 67
Condition100%3/3
not $has_nonspace++ and $parent
!ll&&!rl&&r
40225
MC/DC100%2/2
not $has_nonspace++ and $parent
not $has_nonspace++ $parent
Truth table100%3/3
not(A) and B
A= not $has_nonspace++B= $parent
ABresult
0X0
100
111
166 # ?> まで
167 67 ▶ unless (s{^(.*?)\?>(\r?\n)?}{}s) {
Branch: 1 branch
BranchTrueFalseTotal
unless (s/^(.*?)\?>(\r?\n)?//s) 0 67 67
168 0 die $self->synerror_at($self->{_startln}, q{Unbalanced pi});
169 }
170 67 my $end = $self->{_curpos} += 2 + length($1);
171 67 ▶ my $nl = "\n" if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 12 55 67
172 # XXX: parse_text の前なので、本当は良くない
173 67 ▶ $self->{_curpos} += length $2 if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 12 55 67
174 67 $self->{_endln} += numLines($1);
175 67 push @$sink, do {
176 67 my $node = [];
177 67 $node->[NODE_TYPE] = TYPE_PI;
178 67 $node->[NODE_BEGIN] = $self->{_startpos};
179 67 $node->[NODE_END] = $end;
180 67 $node->[NODE_LNO] = $self->{_endln};
181 67 $node->[NODE_PATH] = [split /:/, $path];
182 67 splice @$node, NODE_BODY, 0, lexpand($self->_parse_text_entities($1));
183 67 $node;
184 };
185 67 ▶ if ($nl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nl) 12 55 67
186 12 push @$sink, $nl;
187 12 $self->{_startln} = ++$self->{_endln};
188 }
189 67 $self->add_lineinfo($sink);
190 } else {
191 0 die join("", "Can't parse: ", nonmatched($_));
192 }
193 } continue {
194 1610 $self->{_startln} = $self->{_endln};
195 1610 $self->{_startpos} = $self->{_curpos};
196 1610 ▶ $self->_verify_token($self->{_startpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 1610 1610
197 }
198  
199 733 ▶ if ($close and not $is_closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close and not $is_closed) 1 732 733
Condition100%3/3
$close and not $is_closed
!ll&&!rl&&r
636961
MC/DC100%2/2
$close and not $is_closed
$close not $is_closed
Truth table100%3/3
A and not(B)
A= $closeB= not $is_closed
ABresult
0X0
100
111
200 1 die $self->synerror_at($self->{_startln}, q{Missing close tag '%s'}, $close);
201 }
202  
203 # if ($last_foot) {
204 # die "??really??" if not defined $last_foot->[NODE_END];
205 # $last_foot->[NODE_END] //= $self->{_curpos};
206 # }
207  
208 # To make body-less element easily detected.
209 732 ▶ if ($parent and $parent->[NODE_BODY]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent and $parent->[8]) 96 636 732
Condition66%2/3
$parent and $parent->[8]
!ll&&!rl&&r
636096
MC/DC50%1/2
$parent and $parent->[8]
$parent $parent->[8]
Truth table66%2/3
A and B
A= $parentB= $parent->[8]
ABresult
0X0
100
111
210 96 _undef_if_empty($self->node_body_slot($parent));
211 }
212 }
213  
214 1163 ▶sub accept_leading_text {
Subroutine accept_leading_text: called CC=6 SCAR=17.9
Pod undocumented
215 1163 (my MY $self, my ($sink, $parent, $par_ln, $rhas_nonspace)) = @_;
216 1163 $self->{_endln} += numLines($&);
217 1163 ▶ if ($self->add_posinfo(length($1), 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->add_posinfo(length $1, 1)) 752 411 1163
218 752 push @$sink, splitline($1);
219 $$par_ln = $self->{_startln}
220 752 ▶ if nonspace($1) and not $$rhas_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if nonspace($1) and not $$rhas_nonspace++ and $parent 78 674 752
Condition100%6/6
nonspace($1) and not $$rhas_nonspace++ and $parent
!ll&&!rl&&r
41925578
nonspace($1) and not $$rhas_nonspace++
!ll&&!rl&&r
154265333
MC/DC100%3/3
nonspace($1) and not $$rhas_nonspace++ and $parent
nonspace($1) not $$rhas_nonspace++ $parent
Truth table100%4/4
A and not(B) and C
A= nonspace($1)B= not $$rhas_nonspace++C= $parent
ABCresult
0XX0
10X0
1100
1111
221 752 $self->{_startln} += numLines($1);
222 }
223 1163 $self->{_curpos} += length($&) - length($1);
224 1163 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 1163 1163
225 }
226  
227 595 ▶sub accept_entity {
Subroutine accept_entity: called CC=5 SCAR=17.5
Pod undocumented
228 595 (my MY $self, my ($sink, $parent, $par_ln, $rhas_nonspace)) = @_;
229 push @$sink, my $node = $self->mkentity
230 595 ($self->{_startpos}, undef, $self->{_endln});
231 # ; まで
232 594 $node->[NODE_END] = $self->{_curpos};
233 594 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 594 594
234 594 $self->add_lineinfo($sink);
235 $$par_ln = $self->{_startln}
236 594 ▶ if nonspace($1) and not $$rhas_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if nonspace($1) and not $$rhas_nonspace++ and $parent 0 594 594
Condition50%3/6
nonspace($1) and not $$rhas_nonspace++ and $parent
!ll&&!rl&&r
59400
nonspace($1) and not $$rhas_nonspace++
!ll&&!rl&&r
1904040
MC/DC0%0/3
nonspace($1) and not $$rhas_nonspace++ and $parent
nonspace($1) not $$rhas_nonspace++ $parent
Truth table50%2/4
A and not(B) and C
A= nonspace($1)B= not $$rhas_nonspace++C= $parent
ABCresult
0XX0
10X0
1100
1111
237 }
238  
239 102 ▶sub verify_tag {
Subroutine verify_tag: called CC=4 SCAR=13.9
Pod undocumented
240 102 (my MY $self, my ($path, $close)) = @_;
241 # XXX: デバッグ時、この段階での sink の様子を見たくなる。
242 102 ▶ unless (s{^>}{}xs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (s/^>//sx) 1 101 102
243 1 die $self->synerror_at($self->{_endln}, q{Missing CLO(>) for: <%s}, $path);
244 }
245 101 $self->{_curpos} += 1;
246 101 ▶ unless (defined $close) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $close) { } 100 1 101
if (do { $path ne $close }) 4 96 100
247 1 die $self->synerror_at($self->{_endln}, q{TAG close without open! got </%s>}, $path);
248 0 } elsif ($path ne $close) {
249 4 die $self->synerror_at($self->{_endln}, q{TAG Mismatch! <%s> closed by </%s>}
250 , $close, $path);
251 }
252 }
253  
254 # $_ から &yatt]]; までを削って $node を返す
255  
256 5 ▶sub _parse_lcmsg {
Subroutine _parse_lcmsg: called CC=10 SCAR=24.7
257 5 (my MY $self, my ($ns, $parent, $par_ln, $rhas_nonspace)) = @_;
258  
259 5 my $path = [$ns];
260 5 ▶ if (s/^(?:\#(\w+))?\[{2,};//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^(?:\#(\w+))?\[{2,};//) { } 5 0 5
261 5 ▶ push @$path, $1 if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 2 3 5
262 } else {
263 die $self->synerror_at
264 ($self->{_startln}
265 0 , q{parse_lcmsg is called from invalid context: %s }, $_);
266 }
267  
268  
269 5 my $node = [];
270 5 $node->[NODE_TYPE] = TYPE_LCMSG;
271 5 $node->[NODE_BEGIN] = $self->{_startpos};
272 5 $node->[NODE_LNO] = $self->{_endln};
273 5 $node->[NODE_PATH] = $path;
274 5 $node->[NODE_BODY] = my $body = [my $sink = []];
275  
276 5 $self->{_curpos} += length $&;
277  
278 5 ▶ while (length $_ and s{^(.*?)$$self{_re_entopn}}{}s) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_ and s/^(.*?)$self->{"_re_entopn"}//s) 17 0 17
Condition33%1/3
length $_ and s/^(.*?)$self->{"_re_entopn"}//s
!ll&&!rl&&r
0017
MC/DC0%0/2
length $_ and s/^(.*?)$self->{"_re_entopn"}//s
length $_ s/^(.*?)$self->{"_re_entopn"}//s
Truth table33%1/3
A and B
A= length $_B= s/^(.*?)$self->{"_re_entopn"}//s
ABresult
0X0
100
111
279 17 $self->accept_leading_text($sink, $parent, $par_ln, $rhas_nonspace);
280 17 ▶ if ($+{msgopn}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($+{'msgopn'}) { } 0 17 17
elsif ($+{'msgsep'}) { } 2 15 17
elsif ($+{'msgclo'}) { } 5 10 15
elsif ($+{'entity'} or $+{'special'}) { } 10 0 10
281 die $self->synerror_at
282 0 ($self->{_startln}, q{nesting of l10n msg is not allowed});
283 } elsif ($+{msgsep}) {
284 2 s/^\|{2,};//;
285 2 $self->{_curpos} += length $&;
286 # switch to next sink.
287 2 push @$body, $sink = [];
288  
289 } elsif ($+{msgclo}) {
290 5 s/^\]{2,};//;
291 5 $self->{_curpos} += length $&;
292 5 $node->[NODE_END] = $self->{_curpos};
293 5 return $node;
294  
295 ▶ } elsif ($+{entity} or $+{special}) {
Condition33%1/3
$+{"entity"} or $+{"special"}
l!l&&r!l&&!r
1000
MC/DC0%0/2
$+{"entity"} or $+{"special"}
$+{"entity"} $+{"special"}
Truth table33%1/3
A or B
A= $+{"entity"}B= $+{"special"}
ABresult
1X1
011
000
296 10 $self->accept_entity($sink, $parent, $par_ln, $rhas_nonspace);
297 } else {
298 die $self->synerror_at
299 0 ($self->{_startln}, q{Unknown input: %s}, $_);
300 }
301 }
302  
303 die $self->synerror_at
304 ($self->{_startln}
305 0 , q{parse_lcmsg is not closed: %s}, $_);
306 }
307  
308 96 ▶sub _undef_if_empty {
Subroutine _undef_if_empty: called CC=4 SCAR=14.6
309 96 ▶ return unless defined $_[0] and ref $_[0] eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] and ref $_[0] eq "ARRAY" 0 96 96
Condition33%1/3
defined $_[0] and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
0096
MC/DC0%0/2
defined $_[0] and ref $_[0] eq "ARRAY"
defined $_[0] ref $_[0] eq "ARRAY"
Truth table33%1/3
A and B
A= defined $_[0]B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
310 96 ▶ unless (@{$_[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$_[0];}) 1 95 96
311 1 undef $_[0];
312 }
313 }
314  
315 2 ▶sub trimmed {
Subroutine trimmed: called CC=1 SCAR=0.0
Pod undocumented
316 2 my ($str) = @_;
317 2 $str =~ s/\n.*\z//s;
318 2 $str;
319 }
320  
321 48 ▶use YATT::Lite::Breakpoint qw(break_load_parsebody);
Subroutine BEGIN: called CC=1 SCAR=0.0
322 48 break_load_parsebody();
323  
324 48 1;
« blib/lib/YATT/Lite/LanguageServer/Generic.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Partial/Session3.pm »