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 74 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 74 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 74 ▶package YATT::Lite::LRXML; use YATT::Lite::LRXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1085 ▶sub _parse_body {
Subroutine _parse_body: called CC=62 SCAR=41.5
8 1085 (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 1085 my $has_nonspace; # 非空白文字が出現したか。 <:opt>HEAD</:opt> と BODY の間に
16 my $is_closed; # tag が閉じたか。
17  
18 1085 my $last_foot; # last foot
19  
20 1085 ▶ 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)) 2530 885 3415
Condition100%3/3
s/^(.*?)$self->{"_re_body"}//sx or my $retry = $self->_get_chunk($sink)
l!l&&r!l&&!r
1711819885
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 2530 ▶ next if $retry;
Branch: 1 branch
BranchTrueFalseTotal
if $retry 819 1711 2530
22  
23 1711 my $startPos = $self->{_curpos} + length($1);
24  
25 1711 $self->accept_leading_text($sink, $parent, $par_ln, \$has_nonspace);
26  
27 1711 ▶ if ($+{lcmsg}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($+{'lcmsg'}) { } 6 1705 1711
elsif ($+{'entity'} or $+{'special'}) { } 861 844 1705
elsif (my $path = $+{'elem'}) { } 761 83 844
elsif ($path = $+{'pi'}) { } 83 0 83
28 6 ▶ if ($+{msgopn}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($+{'msgopn'}) { } 6 0 6
29 push @$sink, $self->_parse_lcmsg
30 6 ($+{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
8592844
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 861 $self->accept_entity($sink, $parent, $par_ln, \$has_nonspace);
39  
40 } elsif (my $path = $+{elem}) {
41 761 ▶ my $formal_path = ($+{opt} // '') . $+{elem};
Condition50%1/2
$+{"opt"} // ""
l!l
7610
MC/DC0%0/1
$+{"opt"} // ""
$+{"opt"}
Truth table50%1/2
A
A= $+{"opt"}
Aresult
11
00
42 761 ▶ if ($+{clo}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($+{"clo"}) 189 572 761
43 189 ▶ if ($last_foot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_foot) 21 168 189
44 21 $last_foot->[NODE_END] = $startPos;
45 }
46 189 $parent->[NODE_BODY_END] = $self->{_startpos};
47 189 ▶ if (defined $parent->[NODE_BODY_BEGIN]
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/) 85 104 189
Condition100%3/3
defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
!ll&&!rl&&r
110385
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 85 $parent->[NODE_BODY_END] -= length $1;
50 }
51 189 $self->verify_tag($formal_path, $close);
52 183 ▶ 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//) 82 101 183
Condition100%6/6
@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//
!ll&&!rl&&r
406182
@$sink and not ref $sink->[-1]
!ll&&!rl&&r
1129143
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 82 push @$sink, "\n";
54 }
55 # $self->add_lineinfo($sink);
56 183 $is_closed++;
57 183 last;
58 }
59 # /? > まで、その後、not ee なら clo まで。
60 572 my $is_opt = $+{opt};
61 572 my $elem = [];
62 572 ▶ $elem->[NODE_TYPE] = $is_opt ? TYPE_ATT_NESTED : TYPE_ELEMENT;
Branch: 1 branch
BranchTrueFalseTotal
$is_opt ? : 50 522 572
63 572 $elem->[NODE_BEGIN] = $self->{_startpos};
64 572 $elem->[NODE_LNO] = $self->{_endln};
65 572 $elem->[NODE_SYM_END] = $self->{_curpos};
66 572 $elem->[NODE_PATH] = [split /:/, $path];
67 572 $elem->[NODE_BODY] = undef;
68  
69 572 ▶ if (my @atts = $self->parse_attlist(\$_)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@atts) = $self->parse_attlist(\$_)) 319 253 572
70 319 $elem->[NODE_ATTLIST] = \@atts;
71 }
72  
73 # タグの直後の改行は、独立したトークンにしておく
74 572 ▶ 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($_)) } 570 2 572
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 570 ▶ ++$self->{_startln} if defined $2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 185 385 570
84  
85 # body slot の初期化
86 # $is_opt の時に、更に body を attribute として保存するのは冗長だし、後の処理も手間なので
87 570 my $body = [];
88 570 ▶ if (not $+{empty_elem} or $is_opt) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $+{"empty_elem"} or $is_opt) 219 351 570
Condition100%3/3
not $+{"empty_elem"} or $is_opt
l!l&&r!l&&!r
19128351
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 219 ▶ $elem->[NODE_BODY] = $is_opt ? $body : do {
Branch: 1 branch
BranchTrueFalseTotal
$is_opt ? : 50 169 219
90 169 my $att_node = [];
91 169 $att_node->[NODE_TYPE] = TYPE_ATTRIBUTE;
92 169 $att_node->[NODE_PATH] = $self->{body_argument};
93 169 $att_node->[NODE_BODY] = $body;
94 169 $att_node;
95 };
96 }
97  
98 570 ▶ my $bodyStartRef; $bodyStartRef = \ $elem->[NODE_BODY][NODE_LNO]
Branch: 1 branch
BranchTrueFalseTotal
if not $is_opt and $elem->[8] 169 401 570
Condition100%3/3
not $is_opt and $elem->[8]
!ll&&!rl&&r
50351169
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 570 ▶ $self->{_curpos} += 1 + ($1 ? length($1) : 0); # $& じゃないので注意。
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 379 191 570
102 570 ▶ $elem->[NODE_END] = $self->{_curpos} if $+{empty_elem};
Branch: 1 branch
BranchTrueFalseTotal
if $+{"empty_elem"} 379 191 570
103 570 ▶ $self->{_curpos} += length $2 if $2; # XXX: swap with below
Branch: 1 branch
BranchTrueFalseTotal
if $2 185 385 570
104 570 $elem->[NODE_BODY_BEGIN] = $self->{_curpos}; # XXX
105  
106 570 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 570 570
107  
108 570 ▶ if ($is_opt and not $+{empty_elem}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_opt and not $+{"empty_elem"}) 22 548 570
Condition100%3/3
$is_opt and not $+{"empty_elem"}
!ll&&!rl&&r
5202822
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 22 drop_leading_ws($sink);
110 }
111  
112 570 ▶ if (not $is_opt) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $is_opt) { } 520 50 570
elsif ($+{'empty_elem'}) { } 28 22 50
113 520 push @$sink, $elem;
114 } elsif ($+{empty_elem}) {
115 # <:opt/> の時は $parent->[foot] へ
116 28 ▶ push @{$parent->[NODE_AELEM_FOOT] ||= []}, $elem;
Condition100%2/2
$parent->[11] ||= []
l!l
721
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 22 ▶ push @{$parent->[NODE_AELEM_HEAD] ||= []}, $elem
Condition50%1/2
$parent->[10] ||= []
l!l
022
MC/DC0%0/1
$parent->[10] ||= []
$parent->[10]
Truth table50%1/2
A
A= $parent->[10]
Aresult
11
00
120 }
121  
122 570 my $bodystartln = $self->{_endln};
123 # <TAG>\n タグ直後の改行について。
124 # <foo />\n だけは, 現在の $sink へ、それ以外は、今作る $elem の $body へ改行を足す
125 570 ▶ $self->{_endln}++, push @{!$is_opt && $+{empty_elem} ? $sink : $body}, "\n"
Branch: 2 branches
BranchTrueFalseTotal
if $2 185 385 570
!$is_opt && $+{'empty_elem'} ? : 90 95 185
Condition100%3/3
not $is_opt and $+{"empty_elem"}
!ll&&!rl&&r
197690
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 570 ▶ unless ($is_opt) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_opt) { } 50 520 570
if (do { not $+{"empty_elem"} }) 22 28 50
129 520 ▶ $$par_ln = $self->{_startln} if not $has_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if not $has_nonspace++ and $parent 30 490 520
Condition100%3/3
not $has_nonspace++ and $parent
!ll&&!rl&&r
15233830
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 570 ▶ if (not $+{empty_elem}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $+{'empty_elem'}) { } 191 379 570
elsif ($is_opt) { } 28 351 379
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 191 ▶ , $+{empty_elem} ? $close : $formal_path
Branch: 1 branch
BranchTrueFalseTotal
$+{'empty_elem'} ? : 0 191 191
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 183 $elem->[NODE_END] = $self->{_curpos};
150 183 ▶ $$bodyStartRef //= $bodystartln;
Condition66%2/3
$$bodyStartRef //= $bodystartln
l!l&&r!l&&!r
143400
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 28 $sink = $body;
155 28 ▶ if ($last_foot) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_foot) 7 21 28
156 7 $last_foot->[NODE_END] = $startPos;
157 }
158 28 $last_foot = $elem;
159 } else {
160 } # simple call.
161 562 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 562 562
162 562 $self->add_lineinfo($sink);
163  
164 } elsif ($path = $+{pi}) {
165 83 ▶ $$par_ln = $self->{_startln} if not $has_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if not $has_nonspace++ and $parent 8 75 83
Condition100%3/3
not $has_nonspace++ and $parent
!ll&&!rl&&r
49268
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 83 ▶ unless (s{^(.*?)\?>(\r?\n)?}{}s) {
Branch: 1 branch
BranchTrueFalseTotal
unless (s/^(.*?)\?>(\r?\n)?//s) 0 83 83
168 0 die $self->synerror_at($self->{_startln}, q{Unbalanced pi});
169 }
170 83 my $end = $self->{_curpos} += 2 + length($1);
171 83 ▶ my $nl = "\n" if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 16 67 83
172 # XXX: parse_text の前なので、本当は良くない
173 83 ▶ $self->{_curpos} += length $2 if $2;
Branch: 1 branch
BranchTrueFalseTotal
if $2 16 67 83
174 83 $self->{_endln} += numLines($1);
175 83 push @$sink, do {
176 83 my $node = [];
177 83 $node->[NODE_TYPE] = TYPE_PI;
178 83 $node->[NODE_BEGIN] = $self->{_startpos};
179 83 $node->[NODE_END] = $end;
180 83 $node->[NODE_LNO] = $self->{_endln};
181 83 $node->[NODE_PATH] = [split /:/, $path];
182 83 splice @$node, NODE_BODY, 0, lexpand($self->_parse_text_entities($1));
183 83 $node;
184 };
185 83 ▶ if ($nl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nl) 16 67 83
186 16 push @$sink, $nl;
187 16 $self->{_startln} = ++$self->{_endln};
188 }
189 83 $self->add_lineinfo($sink);
190 } else {
191 0 die join("", "Can't parse: ", nonmatched($_));
192 }
193 } continue {
194 2330 $self->{_startln} = $self->{_endln};
195 2330 $self->{_startpos} = $self->{_curpos};
196 2330 ▶ $self->_verify_token($self->{_startpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 2330 2330
197 }
198  
199 1068 ▶ if ($close and not $is_closed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close and not $is_closed) 1 1067 1068
Condition100%3/3
$close and not $is_closed
!ll&&!rl&&r
8841831
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 1067 ▶ if ($parent and $parent->[NODE_BODY]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent and $parent->[8]) 183 884 1067
Condition66%2/3
$parent and $parent->[8]
!ll&&!rl&&r
8840183
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 183 _undef_if_empty($self->node_body_slot($parent));
211 }
212 }
213  
214 1730 ▶sub accept_leading_text {
Subroutine accept_leading_text: called CC=6 SCAR=17.9
Pod undocumented
215 1730 (my MY $self, my ($sink, $parent, $par_ln, $rhas_nonspace)) = @_;
216 1730 $self->{_endln} += numLines($&);
217 1730 ▶ if ($self->add_posinfo(length($1), 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->add_posinfo(length $1, 1)) 1074 656 1730
218 1074 push @$sink, splitline($1);
219 $$par_ln = $self->{_startln}
220 1074 ▶ if nonspace($1) and not $$rhas_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if nonspace($1) and not $$rhas_nonspace++ and $parent 128 946 1074
Condition100%6/6
nonspace($1) and not $$rhas_nonspace++ and $parent
!ll&&!rl&&r
611335128
nonspace($1) and not $$rhas_nonspace++
!ll&&!rl&&r
203408463
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 1074 $self->{_startln} += numLines($1);
222 }
223 1730 $self->{_curpos} += length($&) - length($1);
224 1730 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 1730 1730
225 }
226  
227 872 ▶sub accept_entity {
Subroutine accept_entity: called CC=5 SCAR=17.5
Pod undocumented
228 872 (my MY $self, my ($sink, $parent, $par_ln, $rhas_nonspace)) = @_;
229 push @$sink, my $node = $self->mkentity
230 872 ($self->{_startpos}, undef, $self->{_endln});
231 # ; まで
232 871 $node->[NODE_END] = $self->{_curpos};
233 871 ▶ $self->_verify_token($self->{_curpos}, $_) if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 871 871
234 871 $self->add_lineinfo($sink);
235 $$par_ln = $self->{_startln}
236 871 ▶ if nonspace($1) and not $$rhas_nonspace++ and $parent;
Branch: 1 branch
BranchTrueFalseTotal
if nonspace($1) and not $$rhas_nonspace++ and $parent 0 871 871
Condition50%3/6
nonspace($1) and not $$rhas_nonspace++ and $parent
!ll&&!rl&&r
87100
nonspace($1) and not $$rhas_nonspace++
!ll&&!rl&&r
2616100
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 189 ▶sub verify_tag {
Subroutine verify_tag: called CC=4 SCAR=13.9
Pod undocumented
240 189 (my MY $self, my ($path, $close)) = @_;
241 # XXX: デバッグ時、この段階での sink の様子を見たくなる。
242 189 ▶ unless (s{^>}{}xs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (s/^>//sx) 1 188 189
243 1 die $self->synerror_at($self->{_endln}, q{Missing CLO(>) for: <%s}, $path);
244 }
245 188 $self->{_curpos} += 1;
246 188 ▶ unless (defined $close) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $close) { } 187 1 188
if (do { $path ne $close }) 4 183 187
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 6 ▶sub _parse_lcmsg {
Subroutine _parse_lcmsg: called CC=10 SCAR=24.7
257 6 (my MY $self, my ($ns, $parent, $par_ln, $rhas_nonspace)) = @_;
258  
259 6 my $path = [$ns];
260 6 ▶ if (s/^(?:\#(\w+))?\[{2,};//) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^(?:\#(\w+))?\[{2,};//) { } 6 0 6
261 6 ▶ push @$path, $1 if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 2 4 6
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 6 my $node = [];
270 6 $node->[NODE_TYPE] = TYPE_LCMSG;
271 6 $node->[NODE_BEGIN] = $self->{_startpos};
272 6 $node->[NODE_LNO] = $self->{_endln};
273 6 $node->[NODE_PATH] = $path;
274 6 $node->[NODE_BODY] = my $body = [my $sink = []];
275  
276 6 $self->{_curpos} += length $&;
277  
278 6 ▶ while (length $_ and s{^(.*?)$$self{_re_entopn}}{}s) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_ and s/^(.*?)$self->{"_re_entopn"}//s) 19 0 19
Condition33%1/3
length $_ and s/^(.*?)$self->{"_re_entopn"}//s
!ll&&!rl&&r
0019
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 19 $self->accept_leading_text($sink, $parent, $par_ln, $rhas_nonspace);
280 19 ▶ if ($+{msgopn}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($+{'msgopn'}) { } 0 19 19
elsif ($+{'msgsep'}) { } 2 17 19
elsif ($+{'msgclo'}) { } 6 11 17
elsif ($+{'entity'} or $+{'special'}) { } 11 0 11
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 6 s/^\]{2,};//;
291 6 $self->{_curpos} += length $&;
292 6 $node->[NODE_END] = $self->{_curpos};
293 6 return $node;
294  
295 ▶ } elsif ($+{entity} or $+{special}) {
Condition33%1/3
$+{"entity"} or $+{"special"}
l!l&&r!l&&!r
1100
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 11 $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 183 ▶sub _undef_if_empty {
Subroutine _undef_if_empty: called CC=4 SCAR=14.6
309 183 ▶ return unless defined $_[0] and ref $_[0] eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] and ref $_[0] eq "ARRAY" 0 183 183
Condition33%1/3
defined $_[0] and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
00183
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 183 ▶ unless (@{$_[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$_[0];}) 11 172 183
311 11 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 74 ▶use YATT::Lite::Breakpoint qw(break_load_parsebody);
Subroutine BEGIN: called CC=1 SCAR=0.0
322 74 break_load_parsebody();
323  
324 74 1;
« blib/lib/YATT/Lite/LanguageServer/Generic.pm ↑ Summary blib/lib/YATT/Lite/WebMVC0/Partial/Session3.pm »