line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Maketext::Extract::Plugin::Xslate; |
2
|
2
|
|
|
2
|
|
69516
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
69
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
142
|
|
4
|
2
|
|
|
2
|
|
700
|
use parent qw(Locale::Maketext::Extract::Plugin::Base); |
|
2
|
|
|
|
|
341
|
|
|
2
|
|
|
|
|
14
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.0.3'; |
6
|
|
|
|
|
|
|
our $DEBUG = 0; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
4566
|
use Locale::Maketext::Extract; |
|
2
|
|
|
|
|
11257
|
|
|
2
|
|
|
|
|
82
|
|
9
|
|
|
|
|
|
|
$Locale::Maketext::Extract::Known_Plugins{xslate} = __PACKAGE__; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
5501
|
use Data::Dumper; |
|
2
|
|
|
|
|
16815
|
|
|
2
|
|
|
|
|
1688
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub file_types { |
14
|
1
|
|
|
1
|
1
|
195
|
qw( tt html ); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
1
|
113
|
my($class, $args) = @_; |
19
|
1
|
|
|
|
|
4
|
my $extensions = delete $args->{extensions}; |
20
|
1
|
|
50
|
|
|
6
|
my $syntax = delete $args->{syntax} || 'TTears'; |
21
|
1
|
|
|
|
|
15
|
my $self = $class->SUPER::new($extensions); |
22
|
1
|
|
|
1
|
|
172
|
eval "use Text::Xslate::Syntax::$syntax;"; ## no critic |
|
1
|
|
|
|
|
1098
|
|
|
1
|
|
|
|
|
94285
|
|
|
1
|
|
|
|
|
30
|
|
23
|
1
|
50
|
|
|
|
6
|
die $@ if $@; |
24
|
1
|
|
|
|
|
15
|
$self->{xslate_parser} = "Text::Xslate::Syntax::$syntax"->new($args); |
25
|
1
|
|
|
|
|
5204
|
$self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub extract { |
29
|
1
|
|
|
1
|
1
|
94
|
my($self, $data) = @_; |
30
|
1
|
|
|
|
|
28
|
my $ast = $self->{xslate_parser}->parse($data); |
31
|
1
|
|
|
|
|
20764
|
$self->walker($ast); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $sp = ''; |
35
|
|
|
|
|
|
|
sub walker { |
36
|
241
|
|
|
241
|
0
|
287
|
my($self, $ast) = @_; |
37
|
241
|
100
|
100
|
|
|
740
|
$ast = [ $ast ] if $ast && ref($ast) eq 'Text::Xslate::Symbol'; |
38
|
241
|
100
|
66
|
|
|
755
|
return unless $ast && ref($ast) eq 'ARRAY'; |
39
|
|
|
|
|
|
|
|
40
|
55
|
|
|
|
|
59
|
for my $sym (@{ $ast }) { |
|
55
|
|
|
|
|
92
|
|
41
|
|
|
|
|
|
|
|
42
|
80
|
100
|
66
|
|
|
348
|
if ($sym->arity eq 'call' && $sym->value eq '(') { |
43
|
11
|
|
|
|
|
30
|
my $first = $sym->first; |
44
|
11
|
50
|
33
|
|
|
62
|
if ($first && ref($first) eq 'Text::Xslate::Symbol') { |
45
|
11
|
50
|
33
|
|
|
118
|
if ($first->arity eq 'variable' && $first->value eq 'l') { |
46
|
11
|
|
|
|
|
24
|
my $second = $sym->second; |
47
|
11
|
50
|
33
|
|
|
111
|
if ($second && ref($second) eq 'ARRAY' && $second->[0] && ref($second->[0]) eq 'Text::Xslate::Symbol') { |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
48
|
11
|
|
|
|
|
15
|
my $value = $second->[0]; |
49
|
11
|
100
|
|
|
|
36
|
if ($value->arity eq 'literal') { |
50
|
10
|
|
|
|
|
67
|
$self->add_entry($value->value, $value->line); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
80
|
50
|
|
|
|
185
|
unless ($DEBUG) { |
58
|
80
|
|
|
|
|
287
|
$self->walker($sym->first); |
59
|
80
|
|
|
|
|
259
|
$self->walker($sym->second); |
60
|
80
|
|
|
|
|
227
|
$self->walker($sym->third); |
61
|
|
|
|
|
|
|
} else { |
62
|
0
|
|
|
|
|
0
|
warn "$sp id: " . $sym->id; |
63
|
0
|
|
|
|
|
0
|
warn "$sp line: " . $sym->line; |
64
|
0
|
|
|
|
|
0
|
warn "$sp ldp: ". $sym->lbp; |
65
|
0
|
|
|
|
|
0
|
warn "$sp udp: ". $sym->ubp; |
66
|
0
|
|
|
|
|
0
|
warn "$sp type: ". $sym->type; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
0
|
warn "$sp arity: ". $sym->arity; |
69
|
0
|
|
|
|
|
0
|
warn "$sp assignment: ". $sym->assignment; |
70
|
0
|
|
|
|
|
0
|
warn "$sp value: ". $sym->value; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
warn "$sp first: " . $sym->first; |
73
|
0
|
|
|
|
|
0
|
$sp .= ' '; |
74
|
0
|
|
|
|
|
0
|
$self->walker($sym->first); |
75
|
0
|
|
|
|
|
0
|
$sp =~ s/^.//; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
warn "$sp second: " . $sym->second; |
78
|
0
|
|
|
|
|
0
|
$sp .= ' '; |
79
|
0
|
|
|
|
|
0
|
$self->walker($sym->second); |
80
|
0
|
|
|
|
|
0
|
$sp =~ s/^.//; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
warn "$sp third: " . $sym->third; |
83
|
0
|
|
|
|
|
0
|
$sp .= ' '; |
84
|
0
|
|
|
|
|
0
|
$self->walker($sym->third); |
85
|
0
|
|
|
|
|
0
|
$sp =~ s/^.//; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
warn $sp . '----------'; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |