line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Constants; |
2
|
11
|
|
|
11
|
|
1339
|
use strict; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
359
|
|
3
|
11
|
|
|
11
|
|
212
|
use warnings qw(FATAL all NONFATAL misc); |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
491
|
|
4
|
11
|
|
|
11
|
|
278
|
use 5.010; no if $] >= 5.017011, warnings => "experimental"; |
|
11
|
|
|
11
|
|
49
|
|
|
11
|
|
|
|
|
160
|
|
|
11
|
|
|
|
|
1690
|
|
|
11
|
|
|
|
|
114
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#======================================== |
9
|
|
|
|
|
|
|
# 今回は LRXML の serializability を捨てる |
10
|
|
|
|
|
|
|
use YATT::Lite::Util::Enum |
11
|
11
|
|
|
|
|
151
|
(TYPE_ => [qw(LINEINFO COMMENT |
12
|
|
|
|
|
|
|
LCMSG |
13
|
|
|
|
|
|
|
ENTITY PI ELEMENT |
14
|
|
|
|
|
|
|
ATTRIBUTE=ATT_NAMEONLY ATT_BARENAME ATT_TEXT ATT_NESTED |
15
|
|
|
|
|
|
|
ATT_MACRO=DECL_ENTITY)] |
16
|
|
|
|
|
|
|
, NODE_ => [qw(TYPE BEGIN END LNO PATH REST=VALUE=BODY ATTLIST |
17
|
|
|
|
|
|
|
AELEM_HEAD AELEM_FOOT BODY_BEGIN BODY_END)] |
18
|
|
|
|
|
|
|
# node item |
19
|
|
|
|
|
|
|
# BODY が必ず配列になるが、代わりに @attlist は配列不要に。 空の [] を pad しなくて済む |
20
|
|
|
|
|
|
|
# XXX: <:yatt:else /> とかもあったじゃん! |
21
|
11
|
|
|
11
|
|
2066
|
); |
|
11
|
|
|
|
|
19
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub cut_first (&@) { |
24
|
93
|
|
|
93
|
0
|
150
|
my ($code, $list) = @_; |
25
|
93
|
|
|
|
|
160
|
local $_; |
26
|
93
|
|
|
|
|
362
|
for (my $i = 0; $i < @$list; $i++) { |
27
|
93
|
|
|
|
|
167
|
$_ = $list->[$i]; |
28
|
93
|
50
|
|
|
|
220
|
next unless $code->($_); |
29
|
93
|
|
|
|
|
181
|
splice @$list, $i, 1; |
30
|
93
|
|
|
|
|
447
|
return $_; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub cut_first_att { |
35
|
93
|
|
|
93
|
0
|
159
|
my ($list) = @_; |
36
|
93
|
|
|
93
|
|
467
|
cut_first {$_->[NODE_TYPE] >= TYPE_ATTRIBUTE} $list; |
|
93
|
|
|
|
|
310
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# list expand if nested. |
40
|
|
|
|
|
|
|
sub lxnest { |
41
|
99
|
100
|
|
99
|
0
|
436
|
ref $_[0][0] ? @{$_[0]} : $_[0] |
|
5
|
|
|
|
|
25
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
# node expand. |
44
|
|
|
|
|
|
|
sub nx { |
45
|
409
|
|
100
|
409
|
0
|
1552
|
@{$_[0]}[(NODE_PATH + ($_[1] // 0)) .. $#{$_[0]}]; |
|
409
|
|
|
|
|
1725
|
|
|
409
|
|
|
|
|
960
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
sub bar_escape ($) { |
48
|
531
|
50
|
|
531
|
0
|
1114
|
unless (defined $_[0]) { |
49
|
0
|
|
|
|
|
0
|
Carp::confess "Undefined text"; |
50
|
|
|
|
|
|
|
} |
51
|
531
|
|
|
|
|
731
|
my $cp = shift; |
52
|
531
|
|
|
|
|
958
|
$cp =~ s{([\|\\])}{\\$1}g; |
53
|
531
|
|
|
|
|
2337
|
$cp; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub qtext ($) { |
56
|
531
|
|
|
531
|
0
|
1114
|
'q|'.bar_escape($_[0]).'|' |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub qqvalue ($) { |
59
|
42
|
|
|
42
|
0
|
99
|
'q'.qtext($_[0]); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
2
|
0
|
7
|
sub node_type { $_[1]->[NODE_TYPE] } |
63
|
0
|
|
|
0
|
0
|
0
|
sub node_path { $_[1]->[NODE_PATH] } |
64
|
0
|
|
|
0
|
0
|
0
|
sub node_attlist { $_[1]->[NODE_ATTLIST] } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub node_body { |
67
|
0
|
|
|
0
|
0
|
0
|
shift->node_value(@_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub node_body_slot { |
71
|
64
|
|
|
64
|
0
|
127
|
my ($self, $node) = @_; |
72
|
64
|
|
|
|
|
145
|
given ($node->[NODE_TYPE]) { |
73
|
64
|
|
|
|
|
170
|
when (TYPE_ELEMENT) { |
74
|
56
|
50
|
|
|
|
413
|
return $node->[NODE_BODY][NODE_VALUE] if defined $node->[NODE_BODY]; |
75
|
|
|
|
|
|
|
} |
76
|
8
|
|
|
|
|
23
|
when (TYPE_ATT_NESTED) { |
77
|
8
|
|
|
|
|
37
|
return $node->[NODE_VALUE]; |
78
|
|
|
|
|
|
|
} |
79
|
0
|
|
|
|
|
0
|
default { |
80
|
0
|
|
|
|
|
0
|
die "Invalid node type for node_body_slot: $_"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub node_value { |
86
|
2
|
|
|
2
|
0
|
5
|
my ($self, $node) = @_; |
87
|
2
|
50
|
|
|
|
14
|
wantarray ? YATT::Lite::Util::lexpand($node->[NODE_VALUE]) |
88
|
|
|
|
|
|
|
: $node->[NODE_VALUE]; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub node_extract { |
92
|
0
|
|
|
0
|
0
|
|
my ($self, $node) = splice @_, 0, 2; |
93
|
0
|
|
|
|
|
|
nx($node, @_); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#======================================== |
97
|
|
|
|
|
|
|
my $symtab = YATT::Lite::Util::symtab(__PACKAGE__); |
98
|
|
|
|
|
|
|
our @EXPORT = grep {*{$symtab->{$_}}{CODE}} keys %$symtab; |
99
|
|
|
|
|
|
|
our @EXPORT_OK = @EXPORT; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
require Exporter; |
102
|
|
|
|
|
|
|
import Exporter qw(import); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |