line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::I18N::Lexemes; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
13549
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
93
|
|
4
|
4
|
|
|
4
|
|
16
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
105
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
26
|
use base 'Mojo::Base'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
714
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.994; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
7233
|
use Mojo::Template; |
|
4
|
|
|
|
|
44729
|
|
|
4
|
|
|
|
|
25
|
|
11
|
4
|
|
|
4
|
|
456
|
use Mojo::Server; |
|
4
|
|
|
|
|
9484
|
|
|
4
|
|
|
|
|
22
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->attr(renderer => sub { Mojo::Template->new }); |
14
|
|
|
|
|
|
|
__PACKAGE__->attr(helper => sub {'l'}); |
15
|
|
|
|
|
|
|
__PACKAGE__->attr(helper_re => sub {qr/l\s*(\([^\)]+\))/}); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub parse { |
18
|
11
|
|
|
11
|
1
|
695
|
my ($self, $template) = @_; |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
27
|
my $mt = $self->renderer; |
21
|
11
|
|
|
|
|
79
|
$mt->parse($template); |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
2397
|
my $lexemes = []; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
11
|
my $multiline = 0; |
26
|
11
|
|
|
|
|
15
|
my $args = ''; |
27
|
11
|
|
|
|
|
9
|
foreach my $line (@{$mt->tree}) { |
|
11
|
|
|
|
|
25
|
|
28
|
125
|
|
|
|
|
129
|
for (my $j = 0; $j < @{$line}; $j += 2) { |
|
250
|
|
|
|
|
366
|
|
29
|
125
|
|
|
|
|
95
|
my $type = $line->[$j]; |
30
|
125
|
|
100
|
|
|
234
|
my $value = $line->[$j + 1] || ''; |
31
|
125
|
100
|
|
|
|
139
|
if ($value){ |
32
|
71
|
|
|
|
|
156
|
$value =~ s/^\s*//; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
125
|
100
|
100
|
|
|
646
|
if ($multiline) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
36
|
32
|
100
|
100
|
|
|
134
|
if ($type eq 'expr' || $type eq 'escp' || $type eq 'line') { |
|
|
|
100
|
|
|
|
|
37
|
12
|
|
|
|
|
9
|
$args .= $value; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
20
|
|
|
|
|
15
|
$multiline = 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif (($type eq 'expr' or $type eq 'escp') |
44
|
|
|
|
|
|
|
&& $value |
45
|
|
|
|
|
|
|
&& substr($value, 0, length($self->helper) + 1) eq |
46
|
|
|
|
|
|
|
$self->helper . ' ') |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
|
49
|
20
|
|
|
|
|
137
|
$args = substr $value, length($self->helper) + 1; |
50
|
|
|
|
|
|
|
|
51
|
20
|
50
|
50
|
|
|
132
|
unless (($line->[$j + 2] || '') eq 'text') { |
52
|
|
|
|
|
|
|
|
53
|
20
|
|
|
|
|
22
|
$multiline = 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif (($type eq 'expr' or $type eq 'escp') |
58
|
|
|
|
|
|
|
&& $value |
59
|
|
|
|
|
|
|
&& $value =~ $self->helper_re) |
60
|
|
|
|
|
|
|
{ |
61
|
3
|
|
|
|
|
7
|
$args = $1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
125
|
100
|
100
|
|
|
268
|
if ($args && !$multiline) { |
65
|
23
|
|
|
|
|
991
|
my ($lexem) = (eval $args); |
66
|
23
|
50
|
|
|
|
91
|
push @$lexemes, $lexem if $lexem; |
67
|
|
|
|
|
|
|
|
68
|
23
|
|
|
|
|
71
|
$args = ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
11
|
|
|
|
|
38
|
return $lexemes; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |