|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Localizer::Scanner::Xslate;  | 
| 
2
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
86044
 | 
 use 5.008005;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
    | 
| 
3
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
10
 | 
 use strict;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
    | 
| 
4
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
18
 | 
 use warnings;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
128
 | 
    | 
| 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = "0.05";  | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub DEBUG () { 0 }  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
10
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
1541
 | 
 use Localizer::Dictionary;  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6818
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
71
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use Class::Accessor::Lite 0.05 (  | 
| 
13
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     ro => [qw(parser)],  | 
| 
14
 | 
2
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
14
 | 
 );  | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
26
 | 
    | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new {  | 
| 
17
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
30
 | 
     my $class = shift;  | 
| 
18
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
10
 | 
     my %args = @_==1 ? %{$_[0]} : @_;  | 
| 
 
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
     my $self = bless { }, $class;  | 
| 
21
 | 
1
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
6
 | 
     my $syntax = $args{syntax} || 'TTerse';  | 
| 
22
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     $self->{parser} = $self->_build_parser($syntax);  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
24
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5425
 | 
     return $self;  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $RESULT;  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $FILENAME;  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _build_parser {  | 
| 
31
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
3
 | 
     my ($self, $syntax) = @_;  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
33
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
 
 | 
129
 | 
     eval "use Text::Xslate::Syntax::${syntax};"; ## no critic  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1413
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
78538
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
25
 | 
    | 
| 
34
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     die $@ if $@;  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
     "Text::Xslate::Syntax::${syntax}"->new(),  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub scan {  | 
| 
40
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
4
 | 
     my($self, $result, $filename, $data) = @_;  | 
| 
41
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
     my $ast = $self->parser->parse($data);  | 
| 
42
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15612
 | 
     local $FILENAME = $filename;  | 
| 
43
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
     local $RESULT = $result;  | 
| 
44
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
     $self->_walker($ast);  | 
| 
45
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
146
 | 
     return $result;  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub scan_file {  | 
| 
49
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
1
  
 | 
8
 | 
     my ($self, $result, $filename) = @_;  | 
| 
50
 | 
1
 | 
  
 50
  
 | 
 
 | 
  
1
  
 | 
 
 | 
58
 | 
     open my $fh, '<:encoding(utf-8)', $filename  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
12
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
    | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         or die "Cannot open file '$filename' for reading: $!";  | 
| 
52
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15470
 | 
     my $data = do { local $/; <$fh> };  | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
    | 
| 
 
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
34
 | 
    | 
| 
53
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
30
 | 
     return $self->scan($result, $filename, $data);  | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 my $sp = '';  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub _walker {  | 
| 
58
 | 
241
 | 
 
 | 
 
 | 
  
241
  
 | 
 
 | 
225
 | 
     my($self, $ast) = @_;  | 
| 
59
 | 
241
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
605
 | 
     $ast = [ $ast ] if $ast && ref($ast) eq 'Text::Xslate::Symbol';  | 
| 
60
 | 
241
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
603
 | 
     return unless $ast && ref($ast) eq 'ARRAY';  | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
62
 | 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
52
 | 
     for my $sym (@{ $ast }) {  | 
| 
 
 | 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
74
 | 
    | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
64
 | 
80
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
267
 | 
         if ($sym->arity eq 'call' && $sym->value eq '(') {  | 
| 
65
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
             my $first = $sym->first;  | 
| 
66
 | 
11
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
71
 | 
             if ($first && ref($first) eq 'Text::Xslate::Symbol') {  | 
| 
67
 | 
11
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
78
 | 
                 if ($first->arity eq 'variable' && $first->value eq 'l') {  | 
| 
68
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
                     my $second = $sym->second;  | 
| 
69
 | 
11
 | 
  
 50
  
 | 
  
 33
  
 | 
 
 | 
 
 | 
90
 | 
                     if ($second && ref($second) eq 'ARRAY' && $second->[0] && ref($second->[0]) eq 'Text::Xslate::Symbol') {  | 
| 
 
 | 
 
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
 
 | 
 
 | 
 
 | 
  
 33
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
70
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
11
 | 
                         my $value = $second->[0];  | 
| 
71
 | 
11
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
30
 | 
                         if ($value->arity eq 'literal') {  | 
| 
72
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
                             $RESULT->add_entry_position($value->value, $FILENAME, $value->line);  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                         }  | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
75
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
79
 | 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
179
 | 
         unless (DEBUG) {  | 
| 
80
 | 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
217
 | 
             $self->_walker($sym->first);  | 
| 
81
 | 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
185
 | 
             $self->_walker($sym->second);  | 
| 
82
 | 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
177
 | 
             $self->_walker($sym->third);  | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         } else {  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp id: " . $sym->id;  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp line: " . $sym->line;  | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp ldp: ". $sym->lbp;  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp udp: ". $sym->ubp;  | 
| 
88
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp type: ". $sym->type;  | 
| 
89
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp arity: ". $sym->arity;  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp assignment: ". $sym->assignment;  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp value: ". $sym->value;  | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp first: " . $sym->first;  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp .= ' ';  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $self->_walker($sym->first);  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp =~ s/^.//;  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
99
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp second: " . $sym->second;  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp .= ' ';  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $self->_walker($sym->second);  | 
| 
102
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp =~ s/^.//;  | 
| 
103
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn "$sp third: " . $sym->third;  | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp .= ' ';  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $self->_walker($sym->third);  | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             $sp =~ s/^.//;  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             warn $sp . '----------';  | 
| 
110
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
111
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
114
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
115
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |