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