line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
28025
|
use 5.010; use strict; use warnings; |
|
2
|
|
|
2
|
|
6
|
|
|
2
|
|
|
2
|
|
9
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
30
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
81
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package MarpaX::Repa::Test; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
855
|
use Marpa::R2; |
|
2
|
|
|
|
|
225362
|
|
|
2
|
|
|
|
|
73
|
|
6
|
2
|
|
|
2
|
|
663
|
use MarpaX::Repa::Lexer; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
7
|
2
|
|
|
2
|
|
578
|
use MarpaX::Repa::Actions; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub simple_lexer { |
10
|
9
|
|
|
9
|
0
|
17
|
my $self = shift; |
11
|
9
|
|
|
|
|
24
|
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
|
|
|
|
|
86
|
map { $_ => $args{$_} } grep exists $args{$_}, |
|
3
|
|
|
|
|
23
|
|
21
|
|
|
|
|
|
|
qw(start rules default_action), |
22
|
|
|
|
|
|
|
), |
23
|
|
|
|
|
|
|
}); |
24
|
9
|
|
|
|
|
4019
|
$grammar->precompute; |
25
|
9
|
|
|
|
|
1148
|
my $recognizer = Marpa::R2::Recognizer->new( { grammar => $grammar } ); |
26
|
9
|
|
|
|
|
1633
|
my $lexer = MarpaX::Repa::Lexer->new( |
27
|
|
|
|
|
|
|
tokens => { word => 'test' }, |
28
|
|
|
|
|
|
|
store => 'scalar', |
29
|
|
|
|
|
|
|
%args, |
30
|
|
|
|
|
|
|
recognizer => $recognizer, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
36
|
return ($lexer, $recognizer, $grammar); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub recognize { |
37
|
9
|
|
|
9
|
0
|
4072
|
my $self = shift; |
38
|
9
|
|
|
|
|
34
|
my %args = (@_); |
39
|
|
|
|
|
|
|
|
40
|
9
|
|
|
|
|
21
|
my $input = delete $args{'input'}; |
41
|
9
|
|
|
|
|
14
|
my $io; |
42
|
9
|
50
|
|
|
|
23
|
unless ( ref $input ) { |
43
|
2
|
|
|
2
|
|
14
|
open $io, '<', \$input; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
121
|
|
44
|
|
|
|
|
|
|
} else { |
45
|
0
|
|
|
|
|
0
|
$io = $input; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
1736
|
my ($lex, $rec, $gram) = $self->simple_lexer( %args ); |
49
|
9
|
|
|
|
|
39
|
$lex->recognize( $rec, $io ); |
50
|
7
|
|
|
|
|
45
|
return ($lex, $rec, $gram); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |