line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MarpaX::xPathLike::Actions; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
3
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2736
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
8
|
|
|
|
|
|
|
our @EXPORT = qw(); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.201'; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
1
|
|
sub new(){} |
13
|
|
|
|
|
|
|
sub _do_token{ |
14
|
0
|
|
|
0
|
|
|
my $arg = $_[1]; |
15
|
0
|
|
|
|
|
|
$arg =~ s/#([0-9]+)#/chr $1/ge; #recovery utf8 character |
|
0
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return $arg; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
sub _do_double_quoted { |
19
|
0
|
|
|
0
|
|
|
my $s = $_[1]; |
20
|
0
|
|
|
|
|
|
$s =~ s/#([0-9]+)#/chr $1/ge; #recovery utf8 character |
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$s =~ s/^"|"$//g; |
22
|
0
|
|
|
|
|
|
$s =~ s/\\("|\\)/$1/g; |
23
|
0
|
|
|
|
|
|
return $s; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
sub _do_single_quoted { |
26
|
0
|
|
|
0
|
|
|
my $s = $_[1]; |
27
|
0
|
|
|
|
|
|
$s =~ s/#([0-9]+)#/chr $1/ge; #recovery utf8 character |
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$s =~ s/^'|'$//g; |
29
|
0
|
|
|
|
|
|
$s =~ s/\\('|\\)/$1/g; |
30
|
0
|
|
|
|
|
|
return $s; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
# sub _do_curly_delimited_string{ |
33
|
|
|
|
|
|
|
# my $s = $_[1]; |
34
|
|
|
|
|
|
|
# $s =~ s/#([0-9]+)#/chr $1/ge; #recovery utf8 character |
35
|
|
|
|
|
|
|
# $s =~ s/^{|}$//g; |
36
|
|
|
|
|
|
|
# $s =~ s/\\{/{/g; |
37
|
|
|
|
|
|
|
# $s =~ s/\\}/}/g; |
38
|
|
|
|
|
|
|
# return $s; |
39
|
|
|
|
|
|
|
# } |
40
|
|
|
|
|
|
|
sub _do_re{ |
41
|
0
|
|
|
0
|
|
|
my $re = $_[2]; |
42
|
0
|
|
|
|
|
|
return qr/$re/; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
sub _do_func{ |
45
|
0
|
|
0
|
0
|
|
|
my $args = $_[3] || []; |
46
|
0
|
|
|
|
|
|
return {oper => [$_[1], $args]} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
sub _do_funcw2args{ |
49
|
0
|
|
|
0
|
|
|
return {oper => [$_[1], $_[3],$_[5]]} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
sub _do_join{ |
52
|
0
|
|
|
0
|
|
|
return join '', @_[1..$#_]; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
sub _do_group{ |
55
|
0
|
|
|
0
|
|
|
return $_[2] |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
sub _do_unaryOperator{ |
58
|
0
|
|
|
0
|
|
|
return {oper => [@_[1,2]]} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
sub _do_getValueOperator{ |
61
|
0
|
|
|
0
|
|
|
return {values => $_[1]} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
sub _do_binaryOperation{ |
64
|
0
|
|
|
0
|
|
|
my $oper = [$_[2]]; |
65
|
|
|
|
|
|
|
#$oper =~ s/^\s+|\s+$//g; |
66
|
0
|
|
|
|
|
|
my $args = [@_[1,3]]; |
67
|
0
|
|
|
|
|
|
foreach my $i (0..$#$args){ |
68
|
0
|
0
|
0
|
|
|
|
if (ref $args->[$i] eq q|HASH| |
|
|
|
0
|
|
|
|
|
69
|
|
|
|
|
|
|
and defined $args->[$i]->{q|oper|} |
70
|
|
|
|
|
|
|
and $args->[$i]->{q|oper|}->[0] eq $oper->[0]){ |
71
|
0
|
|
|
|
|
|
my $list = $args->[$i]->{q|oper|}; |
72
|
0
|
|
|
|
|
|
push @$oper, @{$list}[1..$#$list]; |
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
}else{ |
74
|
0
|
|
|
|
|
|
push @$oper, $args->[$i]; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
0
|
|
|
|
|
|
return {oper => $oper}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
sub _do_exists{ |
80
|
0
|
|
|
0
|
|
|
return {oper => [q|exists|, $_[1]]} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
sub _do_stepFilterSubpath(){ |
83
|
0
|
|
|
0
|
|
|
my ($step, $filter, $subpath) = @_[1..3]; |
84
|
0
|
0
|
|
|
|
|
carp q|arg is not a hash ref| unless ref $step eq q|HASH|; |
85
|
0
|
|
|
|
|
|
@{$step}{qw|filter subpath|} = ($filter,$subpath); |
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $step; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
sub _do_stepFilter(){ |
89
|
0
|
|
|
0
|
|
|
my ($step, $filter) = @_[1,2]; |
90
|
0
|
0
|
|
|
|
|
carp q|arg is not a hash ref| unless ref $step eq q|HASH|; |
91
|
0
|
|
|
|
|
|
$step->{filter} = $filter; |
92
|
0
|
|
|
|
|
|
return $step; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
sub _do_stepSubpath{ |
95
|
0
|
|
|
0
|
|
|
my ($step,$subpath) = @_[1,2]; |
96
|
0
|
0
|
|
|
|
|
carp q|arg is not a hash ref| unless ref $step eq q|HASH|; |
97
|
0
|
|
|
|
|
|
$step->{subpath} = $subpath; |
98
|
0
|
|
|
|
|
|
return $step; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
sub _do_path{ |
101
|
0
|
|
|
0
|
|
|
return {paths => $_[1]} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
sub _do_pushArgs2array{ |
104
|
0
|
|
|
0
|
|
|
my ($a,$b) = @_[1,3]; |
105
|
0
|
|
|
|
|
|
my @array = (@$a,@$b); |
106
|
0
|
|
|
|
|
|
return \@array; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
sub _do_absolutePath{ |
109
|
0
|
|
|
0
|
|
|
return [{absolute => 1, path => $_[1]}]; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
sub _do_relativePath{ |
112
|
0
|
|
|
0
|
|
|
return [{relative => 1, path => $_[1]}]; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
sub _do_relativePath2{ |
115
|
0
|
|
|
0
|
|
|
return [{relative => 1, path => $_[2]}]; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
sub _do_boolean_filter{ |
118
|
0
|
|
|
0
|
|
|
return {boolean => $_[2]} |
119
|
|
|
|
|
|
|
}; |
120
|
|
|
|
|
|
|
sub _do_mergeFilters{ |
121
|
0
|
|
|
0
|
|
|
my ($filters1, $filters2) = @_[1,2]; |
122
|
0
|
|
|
|
|
|
my @filters = (@$filters1, @$filters2); |
123
|
0
|
|
|
|
|
|
return \@filters; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
sub _do_index_filter{ |
126
|
0
|
|
|
0
|
|
|
return {indexes => $_[2]} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
sub _do_index_single{ |
129
|
0
|
|
|
0
|
|
|
return {index => $_[1]} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
sub _do_index_range{ |
132
|
0
|
|
|
0
|
|
|
return {range => [@_[1,3]]} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
sub _do_startRange{ |
135
|
0
|
|
|
0
|
|
|
{from => $_[1]} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
sub _do_endRange{ |
138
|
0
|
|
|
0
|
|
|
{to => $_[2]} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
sub _do_vlen{ |
141
|
|
|
|
|
|
|
return { |
142
|
0
|
|
|
0
|
|
|
slashslash => $_[1], |
143
|
|
|
|
|
|
|
subpath => $_[2] |
144
|
|
|
|
|
|
|
}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
sub _do_descendant{ |
147
|
0
|
|
|
0
|
|
|
return {descendant => $_[1]}; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
sub _do_descendantArray{ |
150
|
0
|
|
|
0
|
|
|
return {descendantArray => $_[1]}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
sub _do_descendantHash{ |
153
|
0
|
|
|
0
|
|
|
return {descendantHash => $_[1]}; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
sub _do_descendantNamed{ |
156
|
0
|
|
|
0
|
|
|
return {descendantNamed => $_[2]}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
sub _do_descendantIndexed{ |
159
|
0
|
|
|
0
|
|
|
return {descendantIndexed => $_[2]}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
sub _do_descendantIndexedOrNamed{ |
162
|
0
|
|
|
0
|
|
|
return {descendantIndexedOrNamed => $_[2]}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
sub _do_descendantOrSelf{ |
165
|
0
|
|
|
0
|
|
|
return {descendantOrSelf => $_[1]}; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
sub _do_descendantOrSelfArray{ |
168
|
0
|
|
|
0
|
|
|
return {descendantOrSelfArray => $_[1]}; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
sub _do_descendantOrSelfHash{ |
171
|
0
|
|
|
0
|
|
|
return {descendantOrSelfHash => $_[1]}; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
sub _do_descendantOrSelfNamed{ |
174
|
0
|
|
|
0
|
|
|
return {descendantOrSelfNamed => $_[2]}; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
sub _do_descendantOrSelfIndexed{ |
177
|
0
|
|
|
0
|
|
|
return {descendantOrSelfIndexed => $_[2]}; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
sub _do_descendantOrSelfIndexedOrNamed{ |
180
|
0
|
|
|
0
|
|
|
return {descendantOrSelfIndexedOrNamed => $_[2]}; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
sub _do_precedingSibling{ |
183
|
0
|
|
|
0
|
|
|
return {precedingSibling => $_[1]}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
sub _do_precedingSiblingArray{ |
186
|
0
|
|
|
0
|
|
|
return {precedingSiblingArray => $_[1]}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
sub _do_precedingSiblingHash{ |
189
|
0
|
|
|
0
|
|
|
return {precedingSiblingHash => $_[1]}; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
sub _do_precedingSiblingNamed{ |
192
|
0
|
|
|
0
|
|
|
return {precedingSiblingNamed => $_[2]}; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
sub _do_precedingSiblingIndexed{ |
195
|
0
|
|
|
0
|
|
|
return {precedingSiblingIndexed => $_[2]}; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
sub _do_precedingSiblingIndexedOrNamed{ |
198
|
0
|
|
|
0
|
|
|
return {precedingSiblingIndexedOrNamed => $_[2]}; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
sub _do_followingSibling{ |
201
|
0
|
|
|
0
|
|
|
return {followingSibling => $_[1]}; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
sub _do_followingSiblingArray{ |
204
|
0
|
|
|
0
|
|
|
return {followingSiblingArray => $_[1]}; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
sub _do_followingSiblingHash{ |
207
|
0
|
|
|
0
|
|
|
return {followingSiblingHash => $_[1]}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
sub _do_followingSiblingNamed{ |
210
|
0
|
|
|
0
|
|
|
return {followingSiblingNamed => $_[2]}; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
sub _do_followingSiblingIndexed{ |
213
|
0
|
|
|
0
|
|
|
return {followingSiblingIndexed => $_[2]}; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
sub _do_followingSiblingIndexedOrNamed{ |
216
|
0
|
|
|
0
|
|
|
return {followingSiblingIndexedOrNamed => $_[2]}; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
sub _do_child{ |
219
|
0
|
|
|
0
|
|
|
return {child => $_[1]}; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
sub _do_childArray{ |
222
|
0
|
|
|
0
|
|
|
return {childArray => $_[1]}; |
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
sub _do_childHash{ |
225
|
0
|
|
|
0
|
|
|
return {childHash => $_[1]}; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
sub _do_keyname{ |
228
|
0
|
|
|
0
|
|
|
return {childNamed => $_[1]}; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
sub _do_array_index{ |
231
|
0
|
|
|
0
|
|
|
return {childIndexed => $_[2]} |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
sub _do_array_hash_index{ |
234
|
0
|
|
|
0
|
|
|
return {childIndesxedOrNamed => $_[1]} |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
sub _do_childNamed{ |
237
|
0
|
|
|
0
|
|
|
return {childNamed => $_[2]}; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
sub _do_childIndexed{ |
240
|
0
|
|
|
0
|
|
|
return {childIndexed => $_[2]}; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
sub _do_childIndexedOrNamed{ |
243
|
0
|
|
|
0
|
|
|
return {childIndesxedOrNamed => $_[2]}; |
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
sub _do_self{ |
246
|
0
|
|
|
0
|
|
|
return {self => $_[1]}; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
sub _do_selfArray{ |
249
|
0
|
|
|
0
|
|
|
return {selfArray => $_[1]}; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
sub _do_selfHash{ |
252
|
0
|
|
|
0
|
|
|
return {selfHash => $_[1]}; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
sub _do_selfNamed{ |
255
|
0
|
|
|
0
|
|
|
return { selfNamed => $_[2]}; |
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
sub _do_selfIndexedOrNamed{ |
258
|
0
|
|
|
0
|
|
|
return { selfIndexedOrNamed => $_[2]}; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
sub _do_selfIndexed{ |
261
|
0
|
|
|
0
|
|
|
return { selfIndexed => $_[2]}; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
sub _do_parent{ |
264
|
0
|
|
|
0
|
|
|
return {parent => $_[1]}; |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
sub _do_parentArray{ |
267
|
0
|
|
|
0
|
|
|
return {parentArray => $_[1]}; |
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
sub _do_parentHash{ |
270
|
0
|
|
|
0
|
|
|
return {parentHash => $_[1]}; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
sub _do_parentNamed{ |
273
|
0
|
|
|
0
|
|
|
return {parentNamed => $_[2]}; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
sub _do_parentIndexed{ |
276
|
0
|
|
|
0
|
|
|
return {parentIndexed => $_[2]}; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
sub _do_parentIndexedOrNamed{ |
279
|
0
|
|
|
0
|
|
|
return {parentIndexedOrNamed => $_[2]}; |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
sub _do_ancestor{ |
282
|
0
|
|
|
0
|
|
|
return {ancestor => $_[1]}; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
sub _do_ancestorArray{ |
285
|
0
|
|
|
0
|
|
|
return {ancestorArray => $_[1]}; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
sub _do_ancestorHash{ |
288
|
0
|
|
|
0
|
|
|
return {ancestorHash => $_[1]}; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
sub _do_ancestorNamed{ |
291
|
0
|
|
|
0
|
|
|
return {ancestorNamed => $_[2]}; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
sub _do_ancestorIndexed{ |
294
|
0
|
|
|
0
|
|
|
return {ancestorIndexed => $_[2]}; |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
sub _do_ancestorIndexedOrNamed{ |
297
|
0
|
|
|
0
|
|
|
return {ancestorIndexedOrNamed => $_[2]}; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
sub _do_ancestorOrSelf{ |
300
|
0
|
|
|
0
|
|
|
return {ancestorOrSelf => $_[1]} |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
sub _do_ancestorOrSelfArray{ |
303
|
0
|
|
|
0
|
|
|
return {ancestorOrSelfArray => $_[1]} |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
sub _do_ancestorOrSelfHash{ |
306
|
0
|
|
|
0
|
|
|
return {ancestorOrSelfHash => $_[1]} |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
sub _do_ancestorOrSelfNamed{ |
309
|
0
|
|
|
0
|
|
|
return {ancestorOrSelfNamed => $_[2]} |
310
|
|
|
|
|
|
|
} |
311
|
|
|
|
|
|
|
sub _do_ancestorOrSelfIndexed{ |
312
|
0
|
|
|
0
|
|
|
return {ancestorOrSelfIndexed => $_[2]} |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
sub _do_ancestorOrSelfIndexedOrNamed{ |
315
|
0
|
|
|
0
|
|
|
return {ancestorOrSelfIndexedOrNamed => $_[2]} |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
1; |
318
|
|
|
|
|
|
|
__END__ |