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   159727 use warnings;
  50         168  
24 50     50   265 use AtteanX::Parser::Turtle::Constants;
  50         102  
  50         1480  
25 50     50   18933
  50         102  
  50         7038  
26             our @EXPORT;
27             our @LOCAL_TYPES;
28             BEGIN {
29             @LOCAL_TYPES = qw(
30 50     50   261 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         967 };
57             use base 'Exporter';
58 50     50   291  
  50         86  
  50         7189  
59             {
60             my %mapping;
61             my %reverse;
62             BEGIN {
63             my $cx = scalar(@AtteanX::Parser::Turtle::Constants::EXPORT) - 1;
64 50     50   202 foreach my $name (grep { $_ ne 'decrypt_constant' } @LOCAL_TYPES) {
65 50         102 my $value = ++$cx;
  1000         1385  
66 950         1050 $reverse{ $value } = $name;
67 950         2659 $mapping{ $name } = $value;
68 950         3196 }
69             }
70             use constant +{ %mapping };
71 50     50   324  
  50         184  
  50         8756  
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   302 my $num = +shift;
  50         102  
  50         4982  
80             if (exists $reverse{$num}) {
81 1341     1341   6545 return $reverse{$num};
82 1341 100       2220 } else {
83 512         972 return AtteanX::Parser::Turtle::Constants::decrypt_constant($num);
84             }
85 829         1417 }
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