line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
32394
|
use 5.010; use strict; use warnings; |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
110
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package MarpaX::Repa::Test; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
953
|
use Marpa::R2; |
|
2
|
|
|
|
|
248278
|
|
|
2
|
|
|
|
|
80
|
|
6
|
2
|
|
|
2
|
|
871
|
use MarpaX::Repa::Lexer; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
65
|
|
7
|
2
|
|
|
2
|
|
644
|
use MarpaX::Repa::Actions; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub simple_lexer { |
10
|
9
|
|
|
9
|
0
|
11
|
my $self = shift; |
11
|
9
|
|
|
|
|
17
|
my %args = (@_); |
12
|
|
|
|
|
|
|
my $grammar = Marpa::R2::Grammar->new({ |
13
|
|
|
|
|
|
|
action_object => 'MarpaX::Repa::Actions', |
14
|
|
|
|
|
|
|
start => 'text', |
15
|
|
|
|
|
|
|
default_action => 'do_what_I_mean', |
16
|
|
|
|
|
|
|
rules => [ |
17
|
|
|
|
|
|
|
[ 'text' => [ 'word' ] ], |
18
|
|
|
|
|
|
|
], |
19
|
|
|
|
|
|
|
( |
20
|
9
|
|
|
|
|
106
|
map { $_ => $args{$_} } grep exists $args{$_}, |
|
3
|
|
|
|
|
24
|
|
21
|
|
|
|
|
|
|
qw(start rules default_action), |
22
|
|
|
|
|
|
|
), |
23
|
|
|
|
|
|
|
}); |
24
|
9
|
|
|
|
|
2442
|
$grammar->precompute; |
25
|
9
|
|
|
|
|
790
|
my $recognizer = Marpa::R2::Recognizer->new( { grammar => $grammar } ); |
26
|
9
|
|
|
|
|
941
|
my $lexer = MarpaX::Repa::Lexer->new( |
27
|
|
|
|
|
|
|
tokens => { word => 'test' }, |
28
|
|
|
|
|
|
|
store => 'scalar', |
29
|
|
|
|
|
|
|
%args, |
30
|
|
|
|
|
|
|
recognizer => $recognizer, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
30
|
return ($lexer, $recognizer, $grammar); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub recognize { |
37
|
9
|
|
|
9
|
0
|
3629
|
my $self = shift; |
38
|
9
|
|
|
|
|
32
|
my %args = (@_); |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
17
|
my $input = delete $args{'input'}; |
41
|
9
|
|
|
|
|
10
|
my $io; |
42
|
9
|
50
|
|
|
|
18
|
unless ( ref $input ) { |
43
|
2
|
|
|
2
|
|
16
|
open $io, '<', \$input; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
147
|
|
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
0
|
$io = $input; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
1697
|
my ($lex, $rec, $gram) = $self->simple_lexer( %args ); |
49
|
9
|
|
|
|
|
27
|
$lex->recognize( $rec, $io ); |
50
|
7
|
|
|
|
|
44
|
return ($lex, $rec, $gram); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |