« 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
Condition100%3/3
s/^(.*?)$self->{"_re_body"}//sx or my $retry = $self->_get_chunk($sink)
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)
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2530 | ▶ | next if $retry; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | ▶ | if ($+{msgopn}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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"}
MC/DC100%2/2
$+{"entity"} or $+{"special"}
$+{"entity"}
$+{"special"}
Truth table100%3/3
A or B
A= $+{"entity"}B= $+{"special"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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"} // ""
MC/DC0%0/1
$+{"opt"} // ""
$+{"opt"}
Truth table50%1/2
A
A= $+{"opt"}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 761 | ▶ | if ($+{clo}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 189 | ▶ | if ($last_foot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $parent->[5] and $self->{"_template"}->node_body_source($parent) =~ /(\r?\n)\Z/
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/
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%6/6
@$sink and not ref $sink->[-1] and $sink->[-1] =~ s/(\r?\n)\Z//
@$sink and not ref $sink->[-1]
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//
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 319 | $elem->[NODE_ATTLIST] = \@atts; | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | # タグの直後の改行は、独立したトークンにしておく | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 572 | ▶ | s{^(?<empty_elem>/)? >(\r?\n)?}{}xs or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | my $diag = m{^\S*\s*?/?>} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
not $+{"empty_elem"} or $is_opt
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
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 219 | ▶ | $elem->[NODE_BODY] = $is_opt ? $body : do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
not $is_opt and $elem->[8]
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]
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | if not $is_opt and $elem->[NODE_BODY]; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 570 | ▶ | $self->{_curpos} += 1 + ($1 ? length($1) : 0); # $& じゃないので注意。 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 570 | ▶ | $elem->[NODE_END] = $self->{_curpos} if $+{empty_elem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 570 | ▶ | $self->{_curpos} += length $2 if $2; # XXX: swap with below | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 570 | $elem->[NODE_BODY_BEGIN] = $self->{_curpos}; # XXX | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 570 | ▶ | $self->_verify_token($self->{_curpos}, $_) if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 570 | ▶ | if ($is_opt and not $+{empty_elem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_opt and not $+{"empty_elem"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 22 | drop_leading_ws($sink); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 570 | ▶ | if (not $is_opt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 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] ||= []
MC/DC100%1/1
$parent->[11] ||= []
$parent->[11]
Truth table100%2/2
A
A= $parent->[11]
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # <:opt> の時は, $parent->[head] へ | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 22 | ▶ | push @{$parent->[NODE_AELEM_HEAD] ||= []}, $elem | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$parent->[10] ||= []
MC/DC0%0/1
$parent->[10] ||= []
$parent->[10]
Truth table50%1/2
A
A= $parent->[10]
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
not $is_opt and $+{"empty_elem"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | if $2; | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 570 | ▶ | unless ($is_opt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 520 | ▶ | $$par_ln = $self->{_startln} if not $has_nonspace++ and $parent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $has_nonspace++ and $parent
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$$bodyStartRef //= $bodystartln
$$bodyStartRef
$bodystartln
Truth table66%2/3
A //= B
A= $$bodyStartRefB= $bodystartln
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
not $has_nonspace++ and $parent
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
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | # ?> まで | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 83 | ▶ | unless (s{^(.*?)\?>(\r?\n)?}{}s) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | # XXX: parse_text の前なので、本当は良くない | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 83 | ▶ | $self->{_curpos} += length $2 if $2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1068 | ▶ | if ($close and not $is_closed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$close and not $is_closed
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$parent and $parent->[8]
MC/DC50%1/2
$parent and $parent->[8]
$parent
$parent->[8]
Truth table66%2/3
A and B
A= $parentB= $parent->[8]
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%6/6
nonspace($1) and not $$rhas_nonspace++ and $parent
nonspace($1) and not $$rhas_nonspace++
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition50%3/6
nonspace($1) and not $$rhas_nonspace++ and $parent
nonspace($1) and not $$rhas_nonspace++
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | ▶ | push @$path, $1 if $1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
length $_ and s/^(.*?)$self->{"_re_entopn"}//s
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
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 19 | $self->accept_leading_text($sink, $parent, $par_ln, $rhas_nonspace); | |||||||||||||||||||||||||||||||||||||||||
| 280 | 19 | ▶ | if ($+{msgopn}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 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"}
MC/DC0%0/2
$+{"entity"} or $+{"special"}
$+{"entity"}
$+{"special"}
Truth table33%1/3
A or B
A= $+{"entity"}B= $+{"special"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
defined $_[0] and ref $_[0] eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 183 | ▶ | unless (@{$_[0]}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||