line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YATT::Lite::Constants; |
2
|
17
|
|
|
17
|
|
1190
|
use strict; |
|
17
|
|
|
|
|
41
|
|
|
17
|
|
|
|
|
600
|
|
3
|
17
|
|
|
17
|
|
98
|
use warnings qw(FATAL all NONFATAL misc); |
|
17
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
805
|
|
4
|
17
|
|
|
17
|
|
423
|
use 5.010; no if $] >= 5.017011, warnings => "experimental"; |
|
17
|
|
|
17
|
|
125
|
|
|
17
|
|
|
|
|
152
|
|
|
17
|
|
|
|
|
1156
|
|
|
17
|
|
|
|
|
143
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Carp; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#======================================== |
9
|
|
|
|
|
|
|
# 今回は LRXML の serializability を捨てる |
10
|
|
|
|
|
|
|
use YATT::Lite::Util::Enum |
11
|
17
|
|
|
|
|
243
|
(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
|
17
|
|
|
17
|
|
2621
|
); |
|
17
|
|
|
|
|
45
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub cut_first (&@) { |
24
|
149
|
|
|
149
|
0
|
373
|
my ($code, $list) = @_; |
25
|
149
|
|
|
|
|
268
|
local $_; |
26
|
149
|
|
|
|
|
581
|
for (my $i = 0; $i < @$list; $i++) { |
27
|
149
|
|
|
|
|
376
|
$_ = $list->[$i]; |
28
|
149
|
50
|
|
|
|
375
|
next unless $code->($_); |
29
|
149
|
|
|
|
|
332
|
splice @$list, $i, 1; |
30
|
149
|
|
|
|
|
652
|
return $_; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub cut_first_att { |
35
|
149
|
|
|
149
|
0
|
341
|
my ($list) = @_; |
36
|
149
|
|
|
149
|
|
825
|
cut_first {$_->[NODE_TYPE] >= TYPE_ATTRIBUTE} $list; |
|
149
|
|
|
|
|
477
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# list expand if nested. |
40
|
|
|
|
|
|
|
sub lxnest { |
41
|
475
|
100
|
|
475
|
0
|
1599
|
ref $_[0][0] ? @{$_[0]} : $_[0] |
|
5
|
|
|
|
|
29
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
# node expand. |
44
|
|
|
|
|
|
|
sub nx { |
45
|
602
|
|
100
|
602
|
0
|
2464
|
@{$_[0]}[(NODE_PATH + ($_[1] // 0)) .. $#{$_[0]}]; |
|
602
|
|
|
|
|
2371
|
|
|
602
|
|
|
|
|
1489
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
sub bar_escape ($) { |
48
|
919
|
50
|
|
919
|
0
|
2114
|
unless (defined $_[0]) { |
49
|
0
|
|
|
|
|
0
|
Carp::confess "Undefined text"; |
50
|
|
|
|
|
|
|
} |
51
|
919
|
|
|
|
|
1583
|
my $cp = shift; |
52
|
919
|
|
|
|
|
2170
|
$cp =~ s{([\|\\])}{\\$1}g; |
53
|
919
|
|
|
|
|
3964
|
$cp; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
sub qtext ($) { |
56
|
919
|
|
|
919
|
0
|
2230
|
'q|'.bar_escape($_[0]).'|' |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub qqvalue ($) { |
59
|
316
|
|
|
316
|
0
|
620
|
'q'.qtext($_[0]); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
7
|
|
|
7
|
0
|
19
|
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
|
66
|
|
|
66
|
0
|
169
|
my ($self, $node) = @_; |
72
|
66
|
|
|
|
|
138
|
given ($node->[NODE_TYPE]) { |
73
|
66
|
|
|
|
|
197
|
when (TYPE_ELEMENT) { |
74
|
58
|
50
|
|
|
|
369
|
return $node->[NODE_BODY][NODE_VALUE] if defined $node->[NODE_BODY]; |
75
|
|
|
|
|
|
|
} |
76
|
8
|
|
|
|
|
24
|
when (TYPE_ATT_NESTED) { |
77
|
8
|
|
|
|
|
38
|
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
|
7
|
|
|
7
|
0
|
20
|
my ($self, $node) = @_; |
87
|
7
|
50
|
|
|
|
34
|
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; |