AtteanX/SPARQL/Constants.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 100% 47 / 47 CC 3 SCAR 3.1
CC
3
Cov
100%
BEGIN
2.0
decrypt_constant
2.0
BEGIN
1.0
CRAP 1.4
« AtteanX/Serializer/Turtle.pm ↑ Summary AtteanX/Serializer/NTuples.pm »
1 # AtteanX::SPARQL::Constants
2 # -----------------------------------------------------------------------------
3  
4 =head1 NAME
5  
6 AtteanX::SPARQL::Constants - Constant definitions for use in parsing and serializing SPARQL
7  
8 =head1 VERSION
9  
10 This document describes AtteanX::SPARQL::Constants version 0.040
11  
12 =head1 SYNOPSIS
13  
14 use AtteanX::SPARQL::Constants;
15  
16 =head1 METHODS
17  
18 =over 4
19  
20 =cut
21  
22 50 package AtteanX::SPARQL::Constants 0.040 {
23 50 ▶ use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 50 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 50 ▶ use AtteanX::Parser::Turtle::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
26
27 50 our @EXPORT;
28 50 our @LOCAL_TYPES;
29 50 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
30 50 @LOCAL_TYPES = qw(
31 ANDAND
32 BANG
33 GE
34 GT
35 HAT
36 KEYWORD
37 LE
38 LT
39 MINUS
40 NIL
41 NOTEQUALS
42 OR
43 OROR
44 PLUS
45 QUESTION
46 SLASH
47 STAR
48 VAR
49 decrypt_constant
50 );
51 # GTGT
52 # LTLT
53 # LANNOT
54 # RANNOT
55 50 @EXPORT = (@AtteanX::Parser::Turtle::Constants::EXPORT, @LOCAL_TYPES);
56 };
57 50 ▶ use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 {
60 50 my %mapping;
61 50 my %reverse;
62 50 ▶ BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
63 50 my $cx = scalar(@AtteanX::Parser::Turtle::Constants::EXPORT) - 1;
64 50 foreach my $name (grep { $_ ne 'decrypt_constant' } @LOCAL_TYPES) {
65 900 my $value = ++$cx;
66 900 $reverse{ $value } = $name;
67 900 $mapping{ $name } = $value;
68 }
69 }
70 50 ▶ use constant +{ %mapping };
Subroutine BEGIN: called CC=1 SCAR=0.0
71  
72 =item C<< decrypt_constant ( $type ) >>
73  
74 Returns the token name for the given token type.
75  
76 =cut
77  
78 50 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
79 1341 ▶ sub decrypt_constant {
Subroutine decrypt_constant: called CC=2 SCAR=6.9
80 1341 my $num = +shift;
81 1341 ▶ if (exists $reverse{$num}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $reverse{$num}) { } 512 829 1341
82 512 return $reverse{$num};
83 } else {
84 829 return AtteanX::Parser::Turtle::Constants::decrypt_constant($num);
85 }
86 }
87 }
88 50 }
89  
90 50 1;
91  
92 __END__
« AtteanX/Serializer/Turtle.pm ↑ Summary AtteanX/Serializer/NTuples.pm »