line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::I18N::Lexemes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23486
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
12
|
use base 'Mojo::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
862
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.992_2; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10887
|
use Mojo::Template; |
|
1
|
|
|
|
|
89423
|
|
|
1
|
|
|
|
|
15
|
|
11
|
1
|
|
|
1
|
|
841
|
use Mojo::Server; |
|
1
|
|
|
|
|
27361
|
|
|
1
|
|
|
|
|
16
|
|
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
|
5
|
|
|
5
|
1
|
781
|
my ($self, $template) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
136
|
my $mt = $self->renderer; |
21
|
5
|
|
|
|
|
58
|
$mt->parse($template); |
22
|
|
|
|
|
|
|
|
23
|
5
|
|
|
|
|
2568
|
my $lexemes = []; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
8
|
my $multiline = 0; |
26
|
5
|
|
|
|
|
9
|
my $args = ''; |
27
|
5
|
|
|
|
|
9
|
foreach my $line (@{$mt->tree}) { |
|
5
|
|
|
|
|
115
|
|
28
|
44
|
|
|
|
|
91
|
for (my $j = 0; $j < @{$line}; $j += 2) { |
|
88
|
|
|
|
|
210
|
|
29
|
44
|
|
|
|
|
55
|
my $type = $line->[$j]; |
30
|
44
|
|
|
|
|
94
|
my $value = $line->[$j + 1]; |
31
|
|
|
|
|
|
|
|
32
|
44
|
100
|
100
|
|
|
594
|
if ($multiline) { |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
33
|
8
|
50
|
33
|
|
|
33
|
if ($type eq 'expr' || $type eq 'escp') { |
34
|
0
|
|
|
|
|
0
|
$args .= $value; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
8
|
|
|
|
|
11
|
$multiline = 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif (($type eq 'expr' or $type eq 'escp') |
41
|
|
|
|
|
|
|
&& $value |
42
|
|
|
|
|
|
|
&& substr($value, 0, length($self->helper) + 1) eq |
43
|
|
|
|
|
|
|
$self->helper . ' ') |
44
|
|
|
|
|
|
|
{ |
45
|
8
|
|
|
|
|
251
|
$args = substr $value, length($self->helper) + 1; |
46
|
|
|
|
|
|
|
|
47
|
8
|
50
|
50
|
|
|
84
|
unless (($line->[$j + 2] || '') eq 'text') { |
48
|
|
|
|
|
|
|
|
49
|
8
|
|
|
|
|
10
|
$multiline = 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif (($type eq 'expr' or $type eq 'escp') |
54
|
|
|
|
|
|
|
&& $value |
55
|
|
|
|
|
|
|
&& $value =~ $self->helper_re) |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
|
|
0
|
$args = $1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
44
|
100
|
100
|
|
|
231
|
if ($args && !$multiline) { |
61
|
8
|
|
|
|
|
370
|
my $lexem = eval $args; |
62
|
8
|
100
|
|
|
|
29
|
push @$lexemes, $lexem if $lexem; |
63
|
|
|
|
|
|
|
|
64
|
8
|
|
|
|
|
17
|
$args = ''; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
5
|
|
|
|
|
35
|
return $lexemes; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
__END__ |