Repa/Test.pm

filter: Statementstmt 81.8% 9 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 86.6% 13 / 15 SCAR 0.1
CC
1
Cov
82%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Repa.pm ↑ Summary
1 1 ▶use 5.010; use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package MarpaX::Repa::Test;
4  
5 1 ▶use Marpa::R2;
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use MarpaX::Repa::Lexer;
7 use MarpaX::Repa::Actions;
8  
9 sub simple_lexer {
10 my $self = shift;
11 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 map { $_ => $args{$_} } grep exists $args{$_},
21 qw(start rules default_action),
22 ),
23 });
24 $grammar->precompute;
25 my $recognizer = Marpa::R2::Recognizer->new( { grammar => $grammar } );
26 my $lexer = MarpaX::Repa::Lexer->new(
27 tokens => { word => 'test' },
28 store => 'scalar',
29 %args,
30 recognizer => $recognizer,
31 );
32  
33 return ($lexer, $recognizer, $grammar);
34 }
35  
36 sub recognize {
37 my $self = shift;
38 my %args = (@_);
39  
40 my $input = delete $args{'input'};
41 my $io;
42 unless ( ref $input ) {
43 open $io, '<', \$input;
44 } else {
45 $io = $input;
46 }
47  
48 my ($lex, $rec, $gram) = $self->simple_lexer( %args );
49 $lex->recognize( $rec, $io );
50 return ($lex, $rec, $gram);
51 }
52  
53 1;
« Repa.pm ↑ Summary