File Coverage

blib/lib/AtteanX/SPARQL/Constants.pm
Criterion Covered Total %
statement 29 29 100.0
branch 2 2 100.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 40 40 100.0


line stmt bran cond sub pod time code
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.032
11              
12             =head1 SYNOPSIS
13              
14             use AtteanX::SPARQL::Constants;
15              
16             =head1 METHODS
17              
18             =over 4
19              
20             =cut
21              
22             use v5.14;
23 50     50   147187 use warnings;
  50         151  
24 50     50   262 use AtteanX::Parser::Turtle::Constants;
  50         101  
  50         1514  
25 50     50   18362
  50         112  
  50         7115  
26             our @EXPORT;
27             our @LOCAL_TYPES;
28             BEGIN {
29             @LOCAL_TYPES = qw(
30 50     50   247 ANDAND
31             ANON
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             @EXPORT = (@AtteanX::Parser::Turtle::Constants::EXPORT, @LOCAL_TYPES);
56 50         982 };
57             use base 'Exporter';
58 50     50   258  
  50         80  
  50         7159  
59             {
60             my %mapping;
61             my %reverse;
62             BEGIN {
63             my $cx = scalar(@AtteanX::Parser::Turtle::Constants::EXPORT) - 1;
64 50     50   203 foreach my $name (grep { $_ ne 'decrypt_constant' } @LOCAL_TYPES) {
65 50         120 my $value = ++$cx;
  1000         1355  
66 950         1037 $reverse{ $value } = $name;
67 950         1725 $mapping{ $name } = $value;
68 950         4199 }
69             }
70             use constant +{ %mapping };
71 50     50   310  
  50         148  
  50         8822  
72             =item C<< decrypt_constant ( $type ) >>
73              
74             Returns the token name for the given token type.
75              
76             =cut
77              
78             no warnings 'redefine';
79 50     50   296 my $num = +shift;
  50         94  
  50         4948  
80             if (exists $reverse{$num}) {
81 1341     1341   6639 return $reverse{$num};
82 1341 100       2380 } else {
83 512         1000 return AtteanX::Parser::Turtle::Constants::decrypt_constant($num);
84             }
85 829         1505 }
86             }
87             }
88              
89             1;
90              
91              
92             =back
93              
94             =head1 BUGS
95              
96             Please report any bugs or feature requests to through the GitHub web interface
97             at L<https://github.com/kasei/perlrdf/issues>.
98              
99             =head1 AUTHOR
100              
101             Toby Inkster C<< <tobyink@cpan.org> >>
102              
103             Gregory Todd Williams C<< <gwilliams@cpan.org> >>
104              
105             =head1 COPYRIGHT
106              
107             Copyright (c) 2014--2022 Toby Inkster. This
108             program is free software; you can redistribute it and/or modify it under
109             the same terms as Perl itself.
110              
111             =cut