line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::I18N::Lexemes; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
13421
|
use strict; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
95
|
|
4
|
4
|
|
|
4
|
|
13
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
97
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
13
|
use base 'Mojo::Base'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
644
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.994; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
8418
|
use Mojo::Template; |
|
4
|
|
|
|
|
43992
|
|
|
4
|
|
|
|
|
26
|
|
11
|
4
|
|
|
4
|
|
464
|
use Mojo::Server; |
|
4
|
|
|
|
|
8908
|
|
|
4
|
|
|
|
|
21
|
|
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
|
684
|
my ($self, $template) = @_; |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
30
|
my $mt = $self->renderer; |
21
|
11
|
|
|
|
|
86
|
$mt->parse($template); |
22
|
|
|
|
|
|
|
|
23
|
11
|
|
|
|
|
2497
|
my $lexemes = []; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
15
|
my $multiline = 0; |
26
|
11
|
|
|
|
|
13
|
my $args = ''; |
27
|
11
|
|
|
|
|
16
|
foreach my $line (@{$mt->tree}) { |
|
11
|
|
|
|
|
23
|
|
28
|
125
|
|
|
|
|
135
|
for (my $j = 0; $j < @{$line}; $j += 2) { |
|
250
|
|
|
|
|
382
|
|
29
|
125
|
|
|
|
|
108
|
my $type = $line->[$j]; |
30
|
125
|
|
100
|
|
|
243
|
my $value = $line->[$j + 1] || ''; |
31
|
125
|
100
|
|
|
|
146
|
if ($value){ |
32
|
71
|
|
|
|
|
152
|
$value =~ s/^\s*//; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
125
|
100
|
100
|
|
|
705
|
if ($multiline) { |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
36
|
32
|
100
|
100
|
|
|
127
|
if ($type eq 'expr' || $type eq 'escp' || $type eq 'line') { |
|
|
|
100
|
|
|
|
|
37
|
12
|
|
|
|
|
14
|
$args .= $value; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
20
|
|
|
|
|
20
|
$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
|
|
|
|
|
142
|
$args = substr $value, length($self->helper) + 1; |
50
|
|
|
|
|
|
|
|
51
|
20
|
50
|
50
|
|
|
132
|
unless (($line->[$j + 2] || '') eq 'text') { |
52
|
|
|
|
|
|
|
|
53
|
20
|
|
|
|
|
17
|
$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
|
|
|
290
|
if ($args && !$multiline) { |
65
|
23
|
|
|
|
|
1029
|
my ($lexem) = (eval $args); |
66
|
23
|
50
|
|
|
|
80
|
push @$lexemes, $lexem if $lexem; |
67
|
|
|
|
|
|
|
|
68
|
23
|
|
|
|
|
59
|
$args = ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
11
|
|
|
|
|
41
|
return $lexemes; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |