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.033
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   157201 use warnings;
  50         154  
24 50     50   270 use AtteanX::Parser::Turtle::Constants;
  50         93  
  50         1389  
25 50     50   17802
  50         97  
  50         6791  
26             our @EXPORT;
27             our @LOCAL_TYPES;
28             BEGIN {
29             @LOCAL_TYPES = qw(
30 50     50   236 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         922 };
57             use base 'Exporter';
58 50     50   257  
  50         114  
  50         6921  
59             {
60             my %mapping;
61             my %reverse;
62             BEGIN {
63             my $cx = scalar(@AtteanX::Parser::Turtle::Constants::EXPORT) - 1;
64 50     50   189 foreach my $name (grep { $_ ne 'decrypt_constant' } @LOCAL_TYPES) {
65 50         107 my $value = ++$cx;
  1000         1311  
66 950         991 $reverse{ $value } = $name;
67 950         2808 $mapping{ $name } = $value;
68 950         2933 }
69             }
70             use constant +{ %mapping };
71 50     50   313  
  50         166  
  50         8354  
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   293 my $num = +shift;
  50         79  
  50         4794  
80             if (exists $reverse{$num}) {
81 1341     1341   5546 return $reverse{$num};
82 1341 100       2177 } else {
83 512         736 return AtteanX::Parser::Turtle::Constants::decrypt_constant($num);
84             }
85 829         1173 }
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