line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::I18N::Lexemes; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19250
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use base 'Mojo::Base'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
779
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.994; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10620
|
use Mojo::Template; |
|
1
|
|
|
|
|
67979
|
|
|
1
|
|
|
|
|
9
|
|
11
|
1
|
|
|
1
|
|
932
|
use Mojo::Server; |
|
1
|
|
|
|
|
14545
|
|
|
1
|
|
|
|
|
12
|
|
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
|
6
|
|
|
6
|
1
|
475
|
my ($self, $template) = @_; |
19
|
|
|
|
|
|
|
|
20
|
6
|
|
|
|
|
15
|
my $mt = $self->renderer; |
21
|
6
|
|
|
|
|
46
|
$mt->parse($template); |
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
1242
|
my $lexemes = []; |
24
|
|
|
|
|
|
|
|
25
|
6
|
|
|
|
|
8
|
my $multiline = 0; |
26
|
6
|
|
|
|
|
9
|
my $args = ''; |
27
|
6
|
|
|
|
|
7
|
foreach my $line (@{$mt->tree}) { |
|
6
|
|
|
|
|
16
|
|
28
|
49
|
|
|
|
|
83
|
for (my $j = 0; $j < @{$line}; $j += 2) { |
|
98
|
|
|
|
|
225
|
|
29
|
49
|
|
|
|
|
67
|
my $type = $line->[$j]; |
30
|
49
|
|
100
|
|
|
123
|
my $value = $line->[$j + 1] || ''; |
31
|
49
|
100
|
|
|
|
76
|
if ($value){ |
32
|
29
|
|
|
|
|
77
|
$value =~ s/^\s*//; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
49
|
100
|
100
|
|
|
326
|
if ($multiline) { |
|
|
100
|
66
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
36
|
15
|
100
|
66
|
|
|
74
|
if ($type eq 'expr' || $type eq 'escp' || $type eq 'line') { |
|
|
|
100
|
|
|
|
|
37
|
6
|
|
|
|
|
9
|
$args .= $value; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
9
|
|
|
|
|
11
|
$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
|
9
|
|
|
|
|
93
|
$args = substr $value, length($self->helper) + 1; |
50
|
|
|
|
|
|
|
|
51
|
9
|
50
|
50
|
|
|
75
|
unless (($line->[$j + 2] || '') eq 'text') { |
52
|
|
|
|
|
|
|
|
53
|
9
|
|
|
|
|
12
|
$multiline = 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif (($type eq 'expr' or $type eq 'escp') |
58
|
|
|
|
|
|
|
&& $value |
59
|
|
|
|
|
|
|
&& $value =~ $self->helper_re) |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
|
|
0
|
$args = $1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
49
|
100
|
100
|
|
|
157
|
if ($args && !$multiline) { |
65
|
9
|
|
|
|
|
410
|
my ($lexem) = (eval $args); |
66
|
9
|
50
|
|
|
|
107
|
push @$lexemes, $lexem if $lexem; |
67
|
|
|
|
|
|
|
|
68
|
9
|
|
|
|
|
21
|
$args = ''; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
6
|
|
|
|
|
30
|
return $lexemes; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |