MyParsePP.pm

filter: Statementstmt 98.2% 56 / 57 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 3 totaltotal 93.5% 73 / 78 SCAR 13.9
CC
4
Cov
97%
new
3.0
parse
2.0
BEGIN
1.0
CRAP 4.0
« MyParsePP/Query.pm ↑ Summary MyParsePP/Latin1.pm »
1 package DBIx::MyParsePP;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 6 ▶use DBIx::MyParsePP::Lexer;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use DBIx::MyParsePP::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use DBIx::MyParsePP::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 6 our $VERSION = '0.50';
10  
11 6 ▶use constant MYPARSEPP_YAPP => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 ▶use constant MYPARSEPP_CHARSET => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use constant MYPARSEPP_VERSION => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use constant MYPARSEPP_SQL_MODE => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use constant MYPARSEPP_CLIENT_CAPABILITIES => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use constant MYPARSEPP_STMT_PREPARE_MODE => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 6 my %args = (
19 charset => MYPARSEPP_CHARSET,
20 version => MYPARSEPP_VERSION,
21 sql_mode => MYPARSEPP_SQL_MODE,
22 client_capabilities => MYPARSEPP_CLIENT_CAPABILITIES,
23 stmt_prepare_mode => MYPARSEPP_STMT_PREPARE_MODE
24 );
25  
26 6 1;
27  
28 sub new {
29 9 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.1
Pod undocumented
30 9 my $parser = bless ([], $class );
31  
32 9 my $max_arg = (scalar(@_) / 2) - 1;
33  
34 9 foreach my $i (0..$max_arg) {
35 3 ▶ if (exists $args{$_[$i * 2]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{$_[$i * 2]}) { } 3 0 3
36 3 $parser->[$args{$_[$i * 2]}] = $_[$i * 2 + 1];
37 } else {
38 0 warn("Unkown argument '$_[$i * 2]' to DBIx::MyParsePP->new()");
39 }
40 }
41  
42 9 my $yapp = DBIx::MyParsePP::Parser->new();
43 9 $parser->[MYPARSEPP_YAPP] = $yapp;
44 9 return $parser;
45 }
46  
47 sub parse {
48 11 ▶ my ($parser, $string) = @_;
Subroutine parse: called CC=2 SCAR=6.9
Pod undocumented
49  
50 11 my $lexer = DBIx::MyParsePP::Lexer->new(
51 string => $string,
52 charset => $parser->[MYPARSEPP_CHARSET],
53 version => $parser->[MYPARSEPP_VERSION],
54 sql_mode => $parser->[MYPARSEPP_SQL_MODE],
55 client_capabilities => $parser->[MYPARSEPP_CLIENT_CAPABILITIES],
56 stmt_prepare_mode => $parser->[MYPARSEPP_CLIENT_CAPABILITIES]
57 );
58
59 11 my $query = DBIx::MyParsePP::Query->new(
60 lexer => $lexer
61 );
62  
63 11 my $yapp = $parser->[MYPARSEPP_YAPP];
64 11 ▶ my $result = $yapp->YYParse( yylex => sub { $lexer->yylex() }, yyerror => sub { $parser->error(@_, $query) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
65  
66 11 ▶ if (defined $result) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $result) 9 2 11
67 9 $query->setRoot($result->[0]);
68 }
69  
70 11 return $query;
71 }
72  
73 sub error {
74 2 ▶ my ($parser, $yapp, $query) = @_;
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
75 2 $query->setActual($yapp->YYCurval);
76 2 $query->setExpected($yapp->YYExpect);
77 }
78  
79 6 1;
80  
81 __END__
« MyParsePP/Query.pm ↑ Summary MyParsePP/Latin1.pm »