line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hailo::Tokenizer::Chars; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:AVAR'; |
3
|
|
|
|
|
|
|
$Hailo::Tokenizer::Chars::VERSION = '0.75'; |
4
|
3
|
|
|
3
|
|
97541
|
use v5.10.0; |
|
3
|
|
|
|
|
20
|
|
5
|
3
|
|
|
3
|
|
516
|
use Moose; |
|
3
|
|
|
|
|
457608
|
|
|
3
|
|
|
|
|
22
|
|
6
|
3
|
|
|
3
|
|
21949
|
use MooseX::StrictConstructor; |
|
3
|
|
|
|
|
31000
|
|
|
3
|
|
|
|
|
24
|
|
7
|
3
|
|
|
3
|
|
16520
|
use namespace::clean -except => 'meta'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
28
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with qw(Hailo::Role::Arguments |
10
|
|
|
|
|
|
|
Hailo::Role::Tokenizer); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# output -> tokens |
13
|
|
|
|
|
|
|
sub make_tokens { |
14
|
4402
|
|
|
4402
|
0
|
3060204
|
my ($self, $line) = @_; |
15
|
4402
|
|
|
|
|
11114
|
my @chars = split //, $line; |
16
|
4402
|
|
|
|
|
9080
|
my @tokens = map { [$self->{_spacing_normal}, $_] } @chars; |
|
8355
|
|
|
|
|
21725
|
|
17
|
4402
|
|
|
|
|
11560
|
return \@tokens; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# tokens -> output |
21
|
|
|
|
|
|
|
sub make_output { |
22
|
61
|
|
|
61
|
0
|
217
|
my ($self, $tokens) = @_; |
23
|
61
|
|
|
|
|
108
|
return trim(join '', map { $_->[1] } @$tokens); |
|
125
|
|
|
|
|
278
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub trim { |
27
|
61
|
|
|
61
|
0
|
104
|
my $txt = shift; |
28
|
61
|
|
|
|
|
233
|
$txt =~ s/^\s+//; |
29
|
61
|
|
|
|
|
141
|
$txt =~ s/\s+$//; |
30
|
61
|
|
|
|
|
166
|
return $txt; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding utf8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Hailo::Tokenizer::Chars - A character tokenizer for L<Hailo|Hailo> |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This tokenizer dumbly splits input with C<split //>. Use it to |
44
|
|
|
|
|
|
|
generate chains on a per-character basis. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 AUTHOR |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason <avar@cpan.org> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Copyright 2010 E<AElig>var ArnfjE<ouml>rE<eth> Bjarmason. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify |
55
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |