| 1 | # RDF::Query::Parser::SPARQL | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | RDF::Query::Parser::SPARQL - SPARQL Parser. | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | This document describes RDF::Query::Parser::SPARQL version 2.919. | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | use RDF::Query::Parser::SPARQL; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | my $parser = RDF::Query::Parser::SPARQL->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | my $iterator = $parser->parse( $query, $base_uri ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | Beyond the methods documented below, this class inherits methods from the | ||||||||||||||||||||||||||||||||||||||||||
| 25 | L<RDF::Query::Parser> class. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | package RDF::Query::Parser::SPARQL; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 36 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 36 | ▶ | use base qw(RDF::Query::Parser); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 36 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 36 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 36 | ▶ | use RDF::Query::Error qw(:try); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 36 | ▶ | use RDF::Query::Parser; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 36 | ▶ | use RDF::Query::Algebra; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 36 | ▶ | use RDF::Trine::Namespace qw(rdf); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 36 | ▶ | use Scalar::Util qw(blessed looks_like_number); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 36 | our ($VERSION); | |||||||||||||||||||||||||||||||||||||||||
| 49 | 36 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 36 | $VERSION = '2.919'; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 36 | my $rdf = RDF::Trine::Namespace->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#'); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 36 | my $xsd = RDF::Trine::Namespace->new('http://www.w3.org/2001/XMLSchema#'); | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 36 | our $r_ECHAR = qr/\\([tbnrf\\"'])/o; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 36 | our $r_STRING_LITERAL1 = qr/'(([^\x{27}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*'/o; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 36 | our $r_STRING_LITERAL2 = qr/"(([^\x{22}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*"/o; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 36 | our $r_STRING_LITERAL_LONG1 = qr/'''(('|'')?([^'\\]|${r_ECHAR}))*'''/o; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 36 | our $r_STRING_LITERAL_LONG2 = qr/"""(("|"")?([^"\\]|${r_ECHAR}))*"""/o; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 36 | our $r_LANGTAG = qr/@[a-zA-Z]+(-[a-zA-Z0-9]+)*/o; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 36 | our $r_IRI_REF = qr/<([^<>"{}|^`\\\x{00}-\x{20}])*>/o; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 36 | our $r_PN_CHARS_BASE = qr/([A-Z]|[a-z]|[\x{00C0}-\x{00D6}]|[\x{00D8}-\x{00F6}]|[\x{00F8}-\x{02FF}]|[\x{0370}-\x{037D}]|[\x{037F}-\x{1FFF}]|[\x{200C}-\x{200D}]|[\x{2070}-\x{218F}]|[\x{2C00}-\x{2FEF}]|[\x{3001}-\x{D7FF}]|[\x{F900}-\x{FDCF}]|[\x{FDF0}-\x{FFFD}]|[\x{10000}-\x{EFFFF}])/o; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 36 | our $r_PN_CHARS_U = qr/(_|${r_PN_CHARS_BASE})/o; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 36 | our $r_VARNAME = qr/((${r_PN_CHARS_U}|[0-9])(${r_PN_CHARS_U}|[0-9]|\x{00B7}|[\x{0300}-\x{036F}]|[\x{203F}-\x{2040}])*)/o; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 36 | our $r_VAR1 = qr/[?]${r_VARNAME}/o; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 36 | our $r_VAR2 = qr/[\$]${r_VARNAME}/o; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 36 | our $r_PN_CHARS = qr/${r_PN_CHARS_U}|-|[0-9]|\x{00B7}|[\x{0300}-\x{036F}]|[\x{203F}-\x{2040}]/o; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 36 | our $r_PN_PREFIX = qr/(${r_PN_CHARS_BASE}((${r_PN_CHARS}|[.])*${r_PN_CHARS})?)/o; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 36 | our $r_PN_LOCAL = qr/((${r_PN_CHARS_U}|[0-9])((${r_PN_CHARS}|[.])*${r_PN_CHARS})?)/o; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 36 | our $r_PNAME_NS = qr/((${r_PN_PREFIX})?:)/o; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 36 | our $r_PNAME_LN = qr/(${r_PNAME_NS}${r_PN_LOCAL})/o; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 36 | our $r_EXPONENT = qr/[eE][-+]?\d+/o; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 36 | our $r_DOUBLE = qr/\d+[.]\d*${r_EXPONENT}|[.]\d+${r_EXPONENT}|\d+${r_EXPONENT}/o; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 36 | our $r_DECIMAL = qr/(\d+[.]\d*)|([.]\d+)/o; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 36 | our $r_INTEGER = qr/\d+/o; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 36 | our $r_BLANK_NODE_LABEL = qr/_:${r_PN_LOCAL}/o; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 36 | our $r_ANON = qr/\[[\t\r\n ]*\]/o; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 36 | our $r_NIL = qr/\([\n\r\t ]*\)/o; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =item C<< new >> | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Returns a new Turtle parser. | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 89 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 89 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 89 | my $self = bless({ | |||||||||||||||||||||||||||||||||||||||||
| 92 | bindings => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | bnode_id => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 94 | }, $class); | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 89 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =item C<< parse ( $query, $base_uri ) >> | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | Parses the C<< $query >>, using the given C<< $base_uri >>. | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 88 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 88 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 88 | my $input = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 88 | my $baseuri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $input =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $input =~ s/\\U([0-9A-Fa-f]{8})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 88 | delete $self->{error}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 88 | local($self->{namespaces}) = {}; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 88 | local($self->{blank_ids}) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 88 | local($self->{baseURI}) = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 88 | local($self->{tokens}) = $input; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 88 | local($self->{stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 88 | local($self->{filters}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 88 | local($self->{pattern_container_stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 88 | my $triples = $self->_push_pattern_container(); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 88 | $self->{build} = { sources => [], triples => $triples }; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 88 | ▶ | if ($baseuri) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->{build}{base} = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 88 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 88 | $self->_Query(); | |||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | } catch RDF::Query::Error with { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | $self->{build} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | $self->{error} = $e->text; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 88 | }; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 88 | my $data = delete $self->{build}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | # $data->{triples} = $self->_pop_pattern_container(); | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 88 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =item C<< parse_pattern ( $pattern, $base_uri, \%namespaces ) >> | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | Parses the C<< $pattern >>, using the given C<< $base_uri >> and returns a | ||||||||||||||||||||||||||||||||||||||||||
| 143 | RDF::Query::Algebra pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 7 | ▶ | sub parse_pattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_pattern: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 7 | my $input = shift; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 7 | my $baseuri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 7 | my $ns = shift; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $input =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $input =~ s/\\U([0-9A-Fa-f]{8})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 7 | delete $self->{error}; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 7 | local($self->{namespaces}) = $ns; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 7 | local($self->{blank_ids}) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | local($self->{baseURI}) = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | local($self->{tokens}) = $input; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | local($self->{stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 7 | local($self->{filters}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | local($self->{pattern_container_stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 7 | my $triples = $self->_push_pattern_container(); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | $self->{build} = { sources => [], triples => $triples }; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 7 | ▶ | if ($baseuri) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $self->{build}{base} = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 7 | $self->_GroupGraphPattern(); | |||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | } catch RDF::Query::Error with { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $self->{build} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $self->{error} = $e->text; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 7 | }; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 7 | my $data = delete $self->{build}; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | return $data->{triples}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | =item C<< parse_expr ( $pattern, $base_uri, \%namespaces ) >> | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | Parses the C<< $pattern >>, using the given C<< $base_uri >> and returns a | ||||||||||||||||||||||||||||||||||||||||||
| 185 | RDF::Query::Expression pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub parse_expr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_expr: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $input = shift; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $baseuri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $ns = shift; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $input =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $input =~ s/\\U([0-9A-Fa-f]{8})/chr(hex($1))/ge; | |||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | delete $self->{error}; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | local($self->{namespaces}) = $ns; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | local($self->{blank_ids}) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | local($self->{baseURI}) = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | local($self->{tokens}) = $input; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | local($self->{stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | local($self->{filters}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | local($self->{pattern_container_stack}) = []; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $triples = $self->_push_pattern_container(); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $self->{build} = { sources => [], triples => $triples }; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ($baseuri) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->{build}{base} = $baseuri; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->_Expression(); | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | } catch RDF::Query::Error with { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $self->{build} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{error} = $e->text; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $data = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | =item C<< error >> | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | Returns the error encountered during the last parse. | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | return $self->{error}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 390 | ▶ | sub _add_patterns { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_patterns: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 390 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 390 | my @triples = @_; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 390 | my $container = $self->{ pattern_container_stack }[0]; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 390 | push( @{ $container }, @triples ); | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 22 | ▶ | sub _remove_pattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_pattern: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 22 | my $container = $self->{ pattern_container_stack }[0]; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 22 | my $pattern = pop( @{ $container } ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 22 | return $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 88 | ▶ | sub _peek_pattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_peek_pattern: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 88 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 88 | my $container = $self->{ pattern_container_stack }[0]; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 88 | my $pattern = $container->[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 88 | return $pattern; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 323 | ▶ | sub _push_pattern_container { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_push_pattern_container: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 323 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 323 | my $cont = []; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 323 | unshift( @{ $self->{ pattern_container_stack } }, $cont ); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 323 | return $cont; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 228 | ▶ | sub _pop_pattern_container { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pop_pattern_container: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 228 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 228 | my $cont = shift( @{ $self->{ pattern_container_stack } } ); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 228 | return $cont; | |||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 1586 | ▶ | sub _add_stack { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_stack: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 1586 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 1586 | my @items = @_; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 1586 | push( @{ $self->{stack} }, @items ); | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 25 | ▶ | sub _add_filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 25 | my @filters = shift; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 25 | push( @{ $self->{filters} }, @filters ); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 6344 | ▶ | sub _eat { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eat: called CC=7 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 6344 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 6344 | my $thing = shift; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 6344 | ▶ | if (not(length($self->{tokens}))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->_syntax_error("no tokens left"); | |||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | # if (substr($self->{tokens}, 0, 1) eq '^') { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | # Carp::cluck( "eating $thing with input $self->{tokens}" ); | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 6344 | ▶ | if (blessed($thing) and $thing->isa('Regexp')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
builtin::blessed($thing) and $thing->isa("Regexp")
MC/DC50%1/2
builtin::blessed($thing) and $thing->isa("Regexp")
builtin::blessed($thing)
$thing->isa("Regexp")
Truth table66%2/3
A and B
A= builtin::blessed($thing)B= $thing->isa("Regexp")
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 5758 | ▶ | if ($self->{tokens} =~ /^($thing)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 5758 | my $match = $1; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 5758 | substr($self->{tokens}, 0, length($match)) = ''; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 5758 | return $match; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $self->_syntax_error( $thing ); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } elsif (looks_like_number( $thing )) { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my ($token) = substr( $self->{tokens}, 0, $thing, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return $token | |||||||||||||||||||||||||||||||||||||||||
| 303 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | ### thing is a string | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 586 | ▶ | if (substr($self->{tokens}, 0, length($thing)) eq $thing) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 586 | substr($self->{tokens}, 0, length($thing)) = ''; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 586 | return $thing; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->_syntax_error( $thing ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | print $thing; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | throw RDF::Query::Error; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub _syntax_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_syntax_error: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $thing = shift; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $expect = $thing; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my $level = 2; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | while (my $sub = (caller($level++))[3]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if ($sub =~ m/::_([A-Z]\w*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $expect = $1; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $l = Log::Log4perl->get_logger("rdf.query.parser.sparql"); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ($l->is_debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $l->logcluck("Syntax error eating $thing with input <<$self->{tokens}>>"); | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: Expected $expect"; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 9941 | ▶ | sub _test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_test: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 9941 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 9941 | my $thing = shift; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 9941 | ▶ | if (blessed($thing) and $thing->isa('Regexp')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($thing) and $thing->isa("Regexp")
MC/DC50%1/2
builtin::blessed($thing) and $thing->isa("Regexp")
builtin::blessed($thing)
$thing->isa("Regexp")
Truth table66%2/3
A and B
A= builtin::blessed($thing)B= $thing->isa("Regexp")
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 4103 | ▶ | if ($self->{tokens} =~ m/^$thing/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 1584 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 342 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 2519 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 5838 | ▶ | if (substr($self->{tokens}, 0, length($thing)) eq $thing) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 288 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 5550 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 7270 | ▶ | sub _ws_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ws_test: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 7270 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 7270 | ▶ | unless (length($self->{tokens})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 81 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 7189 | ▶ | if ($self->{tokens} =~ m/^[\t\r\n #]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 4035 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 362 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 3154 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 4225 | ▶ | sub _ws { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ws: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 4225 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 369 | ### #x9 | #xA | #xD | #x20 | comment | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 4225 | ▶ | if ($self->_test('#')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $self->_eat(qr/#[^\x0d\x0a]*.?/); | |||||||||||||||||||||||||||||||||||||||||
| 372 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 4225 | $self->_eat(qr/[\n\r\t ]/); | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 3057 | ▶ | sub __consume_ws_opt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__consume_ws_opt: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 3057 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 3057 | ▶ | if ($self->_ws_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1822 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 2000 | ▶ | sub __consume_ws { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__consume_ws: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 2000 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 2000 | $self->_ws; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 2000 | ▶ | while ($self->_ws_test()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 2213 | $self->_ws() | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 235 | ▶ | sub __base { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__base: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 235 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 235 | my $build = $self->{build}; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 235 | ▶ | if (defined($build->{base})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | return $build->{base}; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 235 | return; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 208 | ▶ | sub __new_statement { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__new_statement: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 208 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 208 | my @nodes = @_; | |||||||||||||||||||||||||||||||||||||||||
| 405 | 208 | ▶ | if (my $graph = $self->{named_graph}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 10 | return RDF::Query::Algebra::Quad->new( @nodes, $graph ); | |||||||||||||||||||||||||||||||||||||||||
| 407 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 198 | return RDF::Query::Algebra::Triple->new( @nodes ); | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | ################################################################################ | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | # [1] Query ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 88 | ▶ | sub _Query { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Query: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 88 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 88 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 88 | $self->_Prologue; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 88 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 88 | ▶ | if ($self->_test(qr/SELECT/i)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 71 | $self->_SelectQuery(); | |||||||||||||||||||||||||||||||||||||||||
| 423 | } elsif ($self->_test(qr/CONSTRUCT/i)) { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | $self->_ConstructQuery(); | |||||||||||||||||||||||||||||||||||||||||
| 425 | } elsif ($self->_test(qr/DESCRIBE/i)) { | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 4 | $self->_DescribeQuery(); | |||||||||||||||||||||||||||||||||||||||||
| 427 | } elsif ($self->_test(qr/ASK/i)) { | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | $self->_AskQuery(); | |||||||||||||||||||||||||||||||||||||||||
| 429 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | my $l = Log::Log4perl->get_logger("rdf.query"); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | if ($l->is_debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $l->logcluck("Syntax error: Expected query type with input <<$self->{tokens}>>"); | |||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | throw RDF::Query::Error::ParseError -text => 'Syntax error: Expected query type'; | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 87 | my $remaining = $self->{tokens}; | |||||||||||||||||||||||||||||||||||||||||
| 438 | 87 | ▶ | if ($remaining =~ m/\S/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: Remaining input after query: $remaining"; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | # my %query = (%p, %body); | ||||||||||||||||||||||||||||||||||||||||||
| 443 | # return \%query; | ||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | # [2] Prologue ::= BaseDecl? PrefixDecl* | ||||||||||||||||||||||||||||||||||||||||||
| 448 | # [3] BaseDecl ::= 'BASE' IRI_REF | ||||||||||||||||||||||||||||||||||||||||||
| 449 | # [4] PrefixDecl ::= 'PREFIX' PNAME_NS IRI_REF | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 88 | ▶ | sub _Prologue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Prologue: called CC=6 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 88 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 88 | my $base; | |||||||||||||||||||||||||||||||||||||||||
| 454 | my @base; | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 88 | ▶ | if ($self->_test( qr/BASE/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $self->_eat( qr/BASE/i ); | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $iriref = $self->_eat( $r_IRI_REF ); | |||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my $iri = substr($iriref,1,length($iriref)-2); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $base = RDF::Query::Node::Resource->new( $iri ); | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | @base = $base; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $self->{base} = $base; | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 88 | my %namespaces; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 88 | ▶ | while ($self->_test( qr/PREFIX/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 155 | $self->_eat( qr/PREFIX/i ); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 155 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 155 | my $prefix = $self->_eat( $r_PNAME_NS ); | |||||||||||||||||||||||||||||||||||||||||
| 471 | 155 | my $ns = substr($prefix, 0, length($prefix) - 1); | |||||||||||||||||||||||||||||||||||||||||
| 472 | 155 | ▶ | if ($ns eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | $ns = '__DEFAULT__'; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 155 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 155 | my $iriref = $self->_eat( $r_IRI_REF ); | |||||||||||||||||||||||||||||||||||||||||
| 477 | 155 | my $iri = substr($iriref,1,length($iriref)-2); | |||||||||||||||||||||||||||||||||||||||||
| 478 | 155 | ▶ | if (@base) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $r = RDF::Query::Node::Resource->new( $iri, @base ); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $iri = $r->uri_value; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 155 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 155 | $namespaces{ $ns } = $iri; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 155 | $self->{namespaces}{$ns} = $iri; | |||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 88 | $self->{build}{namespaces} = \%namespaces; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 88 | ▶ | $self->{build}{base} = $base if (defined($base)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | # push(@data, (base => $base)) if (defined($base)); | ||||||||||||||||||||||||||||||||||||||||||
| 491 | # return @data; | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | # [5] SelectQuery ::= 'SELECT' ( 'DISTINCT' | 'REDUCED' )? ( Var+ | '*' ) DatasetClause* WhereClause SolutionModifier | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 71 | ▶ | sub _SelectQuery { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_SelectQuery: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 71 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 71 | $self->_eat(qr/SELECT/i); | |||||||||||||||||||||||||||||||||||||||||
| 499 | 71 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 71 | ▶ | if ($self->{tokens} =~ m/^(DISTINCT|REDUCED)/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 10 | my $mod = $self->_eat( qr/DISTINCT|REDUCED/i ); | |||||||||||||||||||||||||||||||||||||||||
| 503 | 10 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 504 | 10 | $self->{build}{options}{lc($mod)} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 71 | my $star = $self->__SelectVars; | |||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 71 | $self->_DatasetClause(); | |||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 71 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 512 | 71 | $self->_WhereClause; | |||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 71 | ▶ | if ($star) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | ▶ | my $triples = $self->{build}{triples} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'build'}{'triples'} || []
MC/DC0%0/1
$self->{'build'}{'triples'} || []
$self->{'build'}{'triples'}
Truth table50%1/2
A
A= $self->{'build'}{'triples'}
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | my @vars = RDF::Query::_uniq( map { $_->referenced_variables } @$triples ); | |||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | $self->{build}{variables} = [ map { $self->new_variable($_) } @vars ]; | |||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 71 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 521 | 71 | $self->_SolutionModifier(); | |||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 71 | ▶ | if ($self->{build}{options}{orderby}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 7 | my $order = delete $self->{build}{options}{orderby}; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 7 | my $pattern = pop(@{ $self->{build}{triples} }); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 7 | my $sort = RDF::Query::Algebra::Sort->new( $pattern, @$order ); | |||||||||||||||||||||||||||||||||||||||||
| 527 | 7 | push(@{ $self->{build}{triples} }, $sort); | |||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | 71 | $self->__solution_modifiers( $star ); | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 71 | delete $self->{build}{options}; | |||||||||||||||||||||||||||||||||||||||||
| 532 | 71 | $self->{build}{method} = 'SELECT'; | |||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 71 | ▶ | sub __SelectVars { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__SelectVars: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 71 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 537 | 71 | my $star = 0; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 71 | ▶ | if ($self->_test('*')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | $self->_eat('*'); | |||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | $star = 1; | |||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 542 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 70 | my @vars; | |||||||||||||||||||||||||||||||||||||||||
| 544 | 70 | $self->__SelectVar; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 70 | push( @vars, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 546 | 70 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 547 | 70 | ▶ | while ($self->__SelectVar_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | 55 | $self->__SelectVar; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 55 | push( @vars, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 550 | 55 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 70 | $self->{build}{variables} = \@vars; | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 71 | return $star; | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 125 | ▶ | sub __SelectVar_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__SelectVar_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 125 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 559 | 125 | return $self->{tokens} =~ m'^[?$]'; | |||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | 125 | ▶ | sub __SelectVar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__SelectVar: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 125 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 564 | 125 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | # [6] ConstructQuery ::= 'CONSTRUCT' ConstructTemplate DatasetClause* WhereClause SolutionModifier | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 4 | ▶ | sub _ConstructQuery { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConstructQuery: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 569 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 570 | 4 | $self->_eat(qr/CONSTRUCT/i); | |||||||||||||||||||||||||||||||||||||||||
| 571 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 572 | 4 | $self->_ConstructTemplate; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 4 | $self->_DatasetClause(); | |||||||||||||||||||||||||||||||||||||||||
| 575 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 4 | $self->_WhereClause; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 4 | $self->_SolutionModifier(); | |||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | my $pattern = $self->{build}{triples}[0]; | |||||||||||||||||||||||||||||||||||||||||
| 581 | 4 | my $triples = delete $self->{build}{construct_triples}; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 4 | my $construct = RDF::Query::Algebra::Construct->new( $pattern, $triples ); | |||||||||||||||||||||||||||||||||||||||||
| 583 | 4 | $self->{build}{triples}[0] = $construct; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 4 | $self->{build}{method} = 'CONSTRUCT'; | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||
| 587 | # [7] DescribeQuery ::= 'DESCRIBE' ( VarOrIRIref+ | '*' ) DatasetClause* WhereClause? SolutionModifier | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 4 | ▶ | sub _DescribeQuery { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_DescribeQuery: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 590 | 4 | $self->_eat(qr/DESCRIBE/i); | |||||||||||||||||||||||||||||||||||||||||
| 591 | 4 | $self->_ws; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 4 | ▶ | if ($self->_test('*')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $self->_eat('*'); | |||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $self->{build}{variables} = ['*']; | |||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 597 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 4 | $self->_VarOrIRIref; | |||||||||||||||||||||||||||||||||||||||||
| 599 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 600 | 4 | ▶ | while ($self->_VarOrIRIref_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $self->_VarOrIRIref; | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | 4 | $self->{build}{variables} = [ splice(@{ $self->{stack} }) ]; | |||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | 4 | $self->_DatasetClause(); | |||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 610 | 4 | ▶ | if ($self->_WhereClause_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | 3 | $self->_WhereClause; | |||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 4 | $self->_SolutionModifier(); | |||||||||||||||||||||||||||||||||||||||||
| 616 | 4 | $self->{build}{method} = 'DESCRIBE'; | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | # [8] AskQuery ::= 'ASK' DatasetClause* WhereClause | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 8 | ▶ | sub _AskQuery { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_AskQuery: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 622 | 8 | $self->_eat(qr/ASK/i); | |||||||||||||||||||||||||||||||||||||||||
| 623 | 8 | $self->_ws; | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 8 | $self->_DatasetClause(); | |||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | 8 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 628 | 8 | $self->_WhereClause; | |||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | 8 | $self->{build}{variables} = []; | |||||||||||||||||||||||||||||||||||||||||
| 631 | 8 | $self->{build}{method} = 'ASK'; | |||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | # [9] DatasetClause ::= 'FROM' ( DefaultGraphClause | NamedGraphClause ) | ||||||||||||||||||||||||||||||||||||||||||
| 635 | 87 | ▶ | sub _DatasetClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_DatasetClause: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 87 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | # my @dataset; | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 87 | $self->{build}{sources} = []; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 87 | ▶ | while ($self->_test( qr/FROM/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 22 | $self->_eat( qr/FROM/i ); | |||||||||||||||||||||||||||||||||||||||||
| 642 | 22 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 643 | 22 | ▶ | if ($self->_test( qr/NAMED/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 644 | 16 | $self->_NamedGraphClause; | |||||||||||||||||||||||||||||||||||||||||
| 645 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 646 | 6 | $self->_DefaultGraphClause; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | 22 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | # [10] DefaultGraphClause ::= SourceSelector | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 6 | ▶ | sub _DefaultGraphClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_DefaultGraphClause: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 655 | 6 | $self->_SourceSelector; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 6 | my ($source) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 657 | 6 | push( @{ $self->{build}{sources} }, [$source] ); | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | # [11] NamedGraphClause ::= 'NAMED' SourceSelector | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 16 | ▶ | sub _NamedGraphClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_NamedGraphClause: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 663 | 16 | $self->_eat( qr/NAMED/i ); | |||||||||||||||||||||||||||||||||||||||||
| 664 | 16 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 665 | 16 | $self->_SourceSelector; | |||||||||||||||||||||||||||||||||||||||||
| 666 | 16 | my ($source) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 667 | 16 | push( @{ $self->{build}{sources} }, [$source, 'NAMED'] ); | |||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | # [12] SourceSelector ::= IRIref | ||||||||||||||||||||||||||||||||||||||||||
| 671 | 22 | ▶ | sub _SourceSelector { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_SourceSelector: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 673 | 22 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | # [13] WhereClause ::= 'WHERE'? GroupGraphPattern | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 4 | ▶ | sub _WhereClause_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_WhereClause_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 679 | 4 | return $self->_test( qr/WHERE|{/i ); | |||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | 86 | ▶ | sub _WhereClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_WhereClause: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | 86 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 683 | 86 | ▶ | if ($self->_test( qr/WHERE/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | 77 | $self->_eat( qr/WHERE/i ); | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | 86 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 687 | 86 | $self->_GroupGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 86 | my $ggp = $self->_peek_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 86 | $ggp->check_duplicate_blanks; | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | # [14] SolutionModifier ::= OrderClause? LimitOffsetClauses? | ||||||||||||||||||||||||||||||||||||||||||
| 694 | 79 | ▶ | sub _SolutionModifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_SolutionModifier: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 79 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 79 | ▶ | if ($self->_OrderClause_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | 7 | $self->_OrderClause; | |||||||||||||||||||||||||||||||||||||||||
| 699 | 7 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 79 | ▶ | if ($self->_LimitOffsetClauses_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 703 | 8 | $self->_LimitOffsetClauses; | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | # [15] LimitOffsetClauses ::= ( LimitClause OffsetClause? | OffsetClause LimitClause? ) | ||||||||||||||||||||||||||||||||||||||||||
| 708 | 79 | ▶ | sub _LimitOffsetClauses_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_LimitOffsetClauses_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 79 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 710 | 79 | return $self->_test( qr/LIMIT|OFFSET/i ); | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 8 | ▶ | sub _LimitOffsetClauses { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_LimitOffsetClauses: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 715 | 8 | ▶ | if ($self->_LimitClause_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 716 | 6 | $self->_LimitClause; | |||||||||||||||||||||||||||||||||||||||||
| 717 | 6 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 718 | 6 | ▶ | if ($self->_OffsetClause_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | $self->_OffsetClause; | |||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | $self->_OffsetClause; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 2 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | ▶ | if ($self->_LimitClause_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | $self->_LimitClause; | |||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | # [16] OrderClause ::= 'ORDER' 'BY' OrderCondition+ | ||||||||||||||||||||||||||||||||||||||||||
| 731 | 79 | ▶ | sub _OrderClause_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OrderClause_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 732 | 79 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 733 | 79 | return $self->_test( qr/ORDER[\n\r\t ]+BY/i ); | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 7 | ▶ | sub _OrderClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OrderClause: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 737 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 738 | 7 | $self->_eat( qr/ORDER/i ); | |||||||||||||||||||||||||||||||||||||||||
| 739 | 7 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 740 | 7 | $self->_eat( qr/BY/i ); | |||||||||||||||||||||||||||||||||||||||||
| 741 | 7 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 7 | my @order; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 7 | $self->_OrderCondition; | |||||||||||||||||||||||||||||||||||||||||
| 744 | 7 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 745 | 7 | push(@order, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 746 | 7 | ▶ | while ($self->_OrderCondition_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $self->_OrderCondition; | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | push(@order, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 7 | $self->{build}{options}{orderby} = \@order; | |||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | # [17] OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression ) | ( Constraint | Var ) | ||||||||||||||||||||||||||||||||||||||||||
| 755 | 7 | ▶ | sub _OrderCondition_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OrderCondition_test: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 757 | 7 | ▶ | return 1 if $self->_test( qr/ASC|DESC|[?\$]/i ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | 7 | ▶ | return 1 if $self->_Constraint_test; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | 7 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 7 | ▶ | sub _OrderCondition { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OrderCondition: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 763 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 764 | 7 | my $dir = 'ASC'; | |||||||||||||||||||||||||||||||||||||||||
| 765 | 7 | ▶ | if ($self->_test( qr/ASC|DESC/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | $dir = uc( $self->_eat( qr/ASC|DESC/i ) ); | |||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 768 | 2 | $self->_BrackettedExpression; | |||||||||||||||||||||||||||||||||||||||||
| 769 | } elsif ($self->_test( qr/[?\$]/ )) { | ||||||||||||||||||||||||||||||||||||||||||
| 770 | 5 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 771 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | $self->_Constraint; | |||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||
| 774 | 7 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 775 | 7 | $self->_add_stack( [ $dir, $expr ] ); | |||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | # [18] LimitClause ::= 'LIMIT' INTEGER | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 10 | ▶ | sub _LimitClause_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_LimitClause_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 10 | return $self->_test( qr/LIMIT/i ); | |||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||
| 784 | 6 | ▶ | sub _LimitClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_LimitClause: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 785 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 786 | 6 | $self->_eat( qr/LIMIT/i ); | |||||||||||||||||||||||||||||||||||||||||
| 787 | 6 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | my $limit = $self->_eat( $r_INTEGER ); | |||||||||||||||||||||||||||||||||||||||||
| 789 | 6 | $self->{build}{options}{limit} = $limit; | |||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | # [19] OffsetClause ::= 'OFFSET' INTEGER | ||||||||||||||||||||||||||||||||||||||||||
| 793 | 6 | ▶ | sub _OffsetClause_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OffsetClause_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 794 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 795 | 6 | return $self->_test( qr/OFFSET/i ); | |||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | 3 | ▶ | sub _OffsetClause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OffsetClause: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 800 | 3 | $self->_eat( qr/OFFSET/i ); | |||||||||||||||||||||||||||||||||||||||||
| 801 | 3 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 802 | 3 | my $off = $self->_eat( $r_INTEGER ); | |||||||||||||||||||||||||||||||||||||||||
| 803 | 3 | $self->{build}{options}{offset} = $off; | |||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||
| 806 | # [20] GroupGraphPattern ::= '{' TriplesBlock? ( ( GraphPatternNotTriples | Filter ) '.'? TriplesBlock? )* '}' | ||||||||||||||||||||||||||||||||||||||||||
| 807 | 115 | ▶ | sub _GroupGraphPattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GroupGraphPattern: called CC=14 SCAR=27.2
| |||||||||||||||||||||||||||||||||||||||||||
| 808 | 115 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 115 | $self->_push_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 115 | $self->_eat('{'); | |||||||||||||||||||||||||||||||||||||||||
| 812 | 115 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 115 | my $got_pattern = 0; | |||||||||||||||||||||||||||||||||||||||||
| 815 | 115 | my $need_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 816 | 115 | ▶ | if ($self->_TriplesBlock_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 99 | $need_dot = 1; | |||||||||||||||||||||||||||||||||||||||||
| 818 | 99 | $got_pattern++; | |||||||||||||||||||||||||||||||||||||||||
| 819 | 99 | $self->_TriplesBlock; | |||||||||||||||||||||||||||||||||||||||||
| 820 | 99 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | 115 | my $pos = length($self->{tokens}); | |||||||||||||||||||||||||||||||||||||||||
| 824 | 115 | ▶ | while (not $self->_test('}')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | 45 | ▶ | if ($self->_GraphPatternNotTriples_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 826 | 20 | $need_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 827 | 20 | $got_pattern++; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 20 | $self->_GraphPatternNotTriples; | |||||||||||||||||||||||||||||||||||||||||
| 829 | 20 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 830 | 20 | my ($data) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 831 | 20 | $self->__handle_GraphPatternNotTriples( $data ); | |||||||||||||||||||||||||||||||||||||||||
| 832 | 20 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 833 | } elsif ($self->_test( qr/FILTER/i )) { | ||||||||||||||||||||||||||||||||||||||||||
| 834 | 25 | $got_pattern++; | |||||||||||||||||||||||||||||||||||||||||
| 835 | 25 | $need_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 836 | 25 | $self->_Filter; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 25 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | 45 | ▶ | if ($need_dot or $self->_test('.')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$need_dot or $self->_test(".")
MC/DC50%1/2
$need_dot or $self->_test(".")
$need_dot
$self->_test(".")
Truth table66%2/3
A or B
A= $need_dotB= $self->_test(".")
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | 26 | $self->_eat('.'); | |||||||||||||||||||||||||||||||||||||||||
| 842 | 26 | ▶ | if ($got_pattern) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | 26 | $need_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 26 | $got_pattern = 0; | |||||||||||||||||||||||||||||||||||||||||
| 845 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: Extra dot found without preceding pattern"; | |||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 26 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | 45 | ▶ | if ($self->_TriplesBlock_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | 2 | my $peek = $self->_peek_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 2 | ▶ | if (blessed($peek) and $peek->isa('RDF::Query::Algebra::BasicGraphPattern')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($peek) and $peek->isa("RDF::Query::Algebra::BasicGraphPattern")
MC/DC0%0/2
builtin::blessed($peek) and $peek->isa("RDF::Query::Algebra::BasicGraphPattern")
builtin::blessed($peek)
$peek->isa("RDF::Query::Algebra::BasicGraphPattern")
Truth table33%1/3
A and B
A= builtin::blessed($peek)B= $peek->isa("RDF::Query::Algebra::BasicGraphPattern")
| |||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | $self->_TriplesBlock; | |||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | my $rhs = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my $lhs = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $merged = RDF::Query::Algebra::BasicGraphPattern->new( map { $_->triples } ($lhs, $rhs) ); | |||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $self->_add_patterns( $merged ); | |||||||||||||||||||||||||||||||||||||||||
| 859 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 | $self->_TriplesBlock; | |||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 45 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 866 | 45 | ▶ | last unless ($self->_test( qr/\S/ )); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | 45 | my $new = length($self->{tokens}); | |||||||||||||||||||||||||||||||||||||||||
| 869 | 45 | ▶ | if ($pos == $new) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | # we haven't progressed, and so would infinite loop if we don't break out and throw an error. | ||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | $self->_syntax_error(''); | |||||||||||||||||||||||||||||||||||||||||
| 872 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 873 | 45 | $pos = $new; | |||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | 115 | $self->_eat('}'); | |||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 115 | my $cont = $self->_pop_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 115 | my @filters = splice(@{ $self->{filters} }); | |||||||||||||||||||||||||||||||||||||||||
| 882 | 115 | my @patterns; | |||||||||||||||||||||||||||||||||||||||||
| 883 | 115 | my $pattern = RDF::Query::Algebra::GroupGraphPattern->new( @$cont ); | |||||||||||||||||||||||||||||||||||||||||
| 884 | 115 | ▶ | while (my $f = shift @filters) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | 25 | $pattern = RDF::Query::Algebra::Filter->new( $f, $pattern ); | |||||||||||||||||||||||||||||||||||||||||
| 886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 115 | $self->_add_patterns( $pattern ); | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | 20 | ▶ | sub __handle_GraphPatternNotTriples { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__handle_GraphPatternNotTriples: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 892 | 20 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 20 | my ($class, @args) = @$data; | |||||||||||||||||||||||||||||||||||||||||
| 894 | 20 | ▶ | if ($class eq 'RDF::Query::Algebra::Optional') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 895 | 8 | my $cont = $self->_pop_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 896 | 8 | my $ggp = RDF::Query::Algebra::GroupGraphPattern->new( @$cont ); | |||||||||||||||||||||||||||||||||||||||||
| 897 | 8 | $self->_push_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 898 | # my $ggp = $self->_remove_pattern(); | ||||||||||||||||||||||||||||||||||||||||||
| 899 | 8 | ▶ | unless ($ggp) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $ggp = RDF::Query::Algebra::GroupGraphPattern->new(); | |||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | 8 | my $opt = $class->new( $ggp, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 903 | 8 | $self->_add_patterns( $opt ); | |||||||||||||||||||||||||||||||||||||||||
| 904 | } elsif ($class eq 'RDF::Query::Algebra::Union') { | ||||||||||||||||||||||||||||||||||||||||||
| 905 | # no-op | ||||||||||||||||||||||||||||||||||||||||||
| 906 | } elsif ($class eq 'RDF::Query::Algebra::NamedGraph') { | ||||||||||||||||||||||||||||||||||||||||||
| 907 | # no-op | ||||||||||||||||||||||||||||||||||||||||||
| 908 | } elsif ($class eq 'RDF::Query::Algebra::GroupGraphPattern') { | ||||||||||||||||||||||||||||||||||||||||||
| 909 | # no-op | ||||||||||||||||||||||||||||||||||||||||||
| 910 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | Carp::confess Dumper($class, \@args); | |||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | # [21] TriplesBlock ::= TriplesSameSubject ( '.' TriplesBlock? )? | ||||||||||||||||||||||||||||||||||||||||||
| 916 | 254 | ▶ | sub _TriplesBlock_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_TriplesBlock_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | 254 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 918 | # VarOrTerm | TriplesNode -> (Var | GraphTerm) | (Collection | BlankNodePropertyList) -> Var | IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | Collection | BlankNodePropertyList | ||||||||||||||||||||||||||||||||||||||||||
| 919 | # but since a triple can't start with a literal, this is reduced to: | ||||||||||||||||||||||||||||||||||||||||||
| 920 | # Var | IRIref | BlankNode | NIL | ||||||||||||||||||||||||||||||||||||||||||
| 921 | 254 | return $self->_test(qr/[\$?]|<|_:|\[[\n\r\t ]*\]|\([\n\r\t ]*\)|\[|[[(]|${r_PNAME_NS}/); | |||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | 101 | ▶ | sub _TriplesBlock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_TriplesBlock: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 925 | 101 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 926 | 101 | $self->_push_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 927 | 101 | $self->__TriplesBlock; | |||||||||||||||||||||||||||||||||||||||||
| 928 | 101 | my $triples = $self->_pop_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 929 | 101 | my $bgp = RDF::Query::Algebra::BasicGraphPattern->new( @$triples ); | |||||||||||||||||||||||||||||||||||||||||
| 930 | 101 | $self->_add_patterns( $bgp ); | |||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | ## this one (with two underscores) doesn't pop patterns off the stack and make a BGP. | ||||||||||||||||||||||||||||||||||||||||||
| 934 | ## instead, things are left on the stack so we can recurse without doing the wrong thing. | ||||||||||||||||||||||||||||||||||||||||||
| 935 | ## the one with one underscore (_TriplesBlock) will pop everything off and make the BGP. | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 145 | ▶ | sub __TriplesBlock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__TriplesBlock: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 937 | 145 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 938 | 145 | $self->_TriplesSameSubject; | |||||||||||||||||||||||||||||||||||||||||
| 939 | 145 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 940 | 145 | my $got_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 941 | 145 | ▶ | while ($self->_test('.')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | 90 | ▶ | if ($got_dot) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: found extra DOT after TriplesBlock"; | |||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | 90 | $self->_eat('.'); | |||||||||||||||||||||||||||||||||||||||||
| 946 | 90 | $got_dot++; | |||||||||||||||||||||||||||||||||||||||||
| 947 | 90 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 948 | 90 | ▶ | if ($self->_TriplesBlock_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 949 | 44 | $got_dot = 0; | |||||||||||||||||||||||||||||||||||||||||
| 950 | 44 | $self->__TriplesBlock; | |||||||||||||||||||||||||||||||||||||||||
| 951 | 44 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | # [22] GraphPatternNotTriples ::= OptionalGraphPattern | GroupOrUnionGraphPattern | GraphGraphPattern | ||||||||||||||||||||||||||||||||||||||||||
| 957 | 45 | ▶ | sub _GraphPatternNotTriples_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphPatternNotTriples_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 45 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 959 | 45 | return $self->_test(qr/OPTIONAL|{|GRAPH/i); | |||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||
| 962 | 20 | ▶ | sub _GraphPatternNotTriples { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphPatternNotTriples: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 963 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 964 | 20 | ▶ | if ($self->_OptionalGraphPattern_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 965 | 8 | $self->_OptionalGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 966 | } elsif ($self->_GroupOrUnionGraphPattern_test) { | ||||||||||||||||||||||||||||||||||||||||||
| 967 | 2 | $self->_GroupOrUnionGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 968 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 969 | 10 | $self->_GraphGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | # [23] OptionalGraphPattern ::= 'OPTIONAL' GroupGraphPattern | ||||||||||||||||||||||||||||||||||||||||||
| 974 | 20 | ▶ | sub _OptionalGraphPattern_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OptionalGraphPattern_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 975 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 976 | 20 | return $self->_test( qr/OPTIONAL/i ); | |||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 8 | ▶ | sub _OptionalGraphPattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_OptionalGraphPattern: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 981 | 8 | $self->_eat( qr/OPTIONAL/i ); | |||||||||||||||||||||||||||||||||||||||||
| 982 | 8 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 983 | 8 | $self->_GroupGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 984 | 8 | my $ggp = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 985 | 8 | my $opt = ['RDF::Query::Algebra::Optional', $ggp]; | |||||||||||||||||||||||||||||||||||||||||
| 986 | 8 | $self->_add_stack( $opt ); | |||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||
| 989 | # [24] GraphGraphPattern ::= 'GRAPH' VarOrIRIref GroupGraphPattern | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 10 | ▶ | sub _GraphGraphPattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphGraphPattern: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 992 | 10 | $self->_eat( qr/GRAPH/i ); | |||||||||||||||||||||||||||||||||||||||||
| 993 | 10 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 994 | 10 | $self->_VarOrIRIref; | |||||||||||||||||||||||||||||||||||||||||
| 995 | 10 | my ($graph) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 996 | 10 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | # if ($graph->isa('RDF::Trine::Node::Resource')) { | ||||||||||||||||||||||||||||||||||||||||||
| 999 | 10 | local($self->{named_graph}) = $graph; | |||||||||||||||||||||||||||||||||||||||||
| 1000 | 10 | $self->_GroupGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | # } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | # $self->_GroupGraphPattern; | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 10 | my $ggp = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 10 | my $pattern = RDF::Query::Algebra::NamedGraph->new( $graph, $ggp ); | |||||||||||||||||||||||||||||||||||||||||
| 1007 | 10 | $self->_add_patterns( $pattern ); | |||||||||||||||||||||||||||||||||||||||||
| 1008 | 10 | $self->_add_stack( [ 'RDF::Query::Algebra::NamedGraph' ] ); | |||||||||||||||||||||||||||||||||||||||||
| 1009 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | # [25] GroupOrUnionGraphPattern ::= GroupGraphPattern ( 'UNION' GroupGraphPattern )* | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | 12 | ▶ | sub _GroupOrUnionGraphPattern_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GroupOrUnionGraphPattern_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 12 | return $self->_test('{'); | |||||||||||||||||||||||||||||||||||||||||
| 1015 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | 2 | ▶ | sub _GroupOrUnionGraphPattern { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GroupOrUnionGraphPattern: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1018 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 2 | $self->_GroupGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 1020 | 2 | my $ggp = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 1021 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||
| 1023 | 2 | ▶ | if ($self->_test( qr/UNION/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1024 | 2 | ▶ | while ($self->_test( qr/UNION/i )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 2 | $self->_eat( qr/UNION/i ); | |||||||||||||||||||||||||||||||||||||||||
| 1026 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1027 | 2 | $self->_GroupGraphPattern; | |||||||||||||||||||||||||||||||||||||||||
| 1028 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1029 | 2 | my $rhs = $self->_remove_pattern; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | 2 | $ggp = RDF::Query::Algebra::Union->new( $ggp, $rhs ); | |||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | 2 | $self->_add_patterns( $ggp ); | |||||||||||||||||||||||||||||||||||||||||
| 1033 | 2 | $self->_add_stack( [ 'RDF::Query::Algebra::Union' ] ); | |||||||||||||||||||||||||||||||||||||||||
| 1034 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | $self->_add_patterns( $ggp ); | |||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | $self->_add_stack( [ 'RDF::Query::Algebra::GroupGraphPattern' ] ); | |||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||
| 1040 | # [26] Filter ::= 'FILTER' Constraint | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | 25 | ▶ | sub _Filter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 25 | $self->_eat( qr/FILTER/i ); | |||||||||||||||||||||||||||||||||||||||||
| 1044 | 25 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1045 | 25 | $self->_Constraint; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 25 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1047 | 25 | $self->_add_filter( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | # [27] Constraint ::= BrackettedExpression | BuiltInCall | FunctionCall | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | 7 | ▶ | sub _Constraint_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Constraint_test: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1052 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1053 | 7 | ▶ | return 1 if $self->_test( qr/[(]/ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1054 | 7 | ▶ | return 1 if $self->_BuiltInCall_test; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 7 | ▶ | return 1 if $self->_FunctionCall_test; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 7 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | 25 | ▶ | sub _Constraint { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Constraint: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 25 | ▶ | if ($self->_BrackettedExpression_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 18 | $self->_BrackettedExpression(); | |||||||||||||||||||||||||||||||||||||||||
| 1063 | } elsif ($self->_BuiltInCall_test) { | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | 6 | $self->_BuiltInCall(); | |||||||||||||||||||||||||||||||||||||||||
| 1065 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | 1 | $self->_FunctionCall(); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | # [28] FunctionCall ::= IRIref ArgList | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | 7 | ▶ | sub _FunctionCall_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_FunctionCall_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1073 | 7 | return $self->_IRIref_test; | |||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||
| 1076 | 1 | ▶ | sub _FunctionCall { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_FunctionCall: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1077 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1078 | 1 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1079 | 1 | my ($iri) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | 1 | $self->_ArgList; | |||||||||||||||||||||||||||||||||||||||||
| 1084 | 1 | my @args = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1085 | 1 | my $func = $self->new_function_expression( $iri, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 1086 | 1 | $self->_add_stack( $func ); | |||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||
| 1089 | # [29] ArgList ::= ( NIL | '(' Expression ( ',' Expression )* ')' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | 13 | ▶ | sub _ArgList_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ArgList_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1092 | 13 | return $self->_test('('); | |||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 12 | ▶ | sub _ArgList { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ArgList: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1097 | 12 | $self->_eat('('); | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 12 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1099 | 12 | my @args; | |||||||||||||||||||||||||||||||||||||||||
| 1100 | 12 | ▶ | unless ($self->_test(')')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 12 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1102 | 12 | push( @args, splice(@{ $self->{stack} }) ); | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 12 | ▶ | while ($self->_test(',')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1104 | 9 | $self->_eat(','); | |||||||||||||||||||||||||||||||||||||||||
| 1105 | 9 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1106 | 9 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 9 | push( @args, splice(@{ $self->{stack} }) ); | |||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | 12 | $self->_eat(')'); | |||||||||||||||||||||||||||||||||||||||||
| 1111 | 12 | $self->_add_stack( @args ); | |||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||
| 1114 | # [30] ConstructTemplate ::= '{' ConstructTriples? '}' | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | 4 | ▶ | sub _ConstructTemplate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConstructTemplate: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1116 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 4 | $self->_push_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 1118 | 4 | $self->_eat( '{' ); | |||||||||||||||||||||||||||||||||||||||||
| 1119 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 4 | ▶ | if ($self->_ConstructTriples_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1122 | 4 | $self->_ConstructTriples; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1126 | 4 | $self->_eat( '}' ); | |||||||||||||||||||||||||||||||||||||||||
| 1127 | 4 | my $cont = $self->_pop_pattern_container; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | 4 | $self->{build}{construct_triples} = $cont; | |||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||
| 1131 | # [31] ConstructTriples ::= TriplesSameSubject ( '.' ConstructTriples? )? | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | 4 | ▶ | sub _ConstructTriples_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConstructTriples_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1133 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1134 | 4 | return $self->_TriplesBlock_test; | |||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | 4 | ▶ | sub _ConstructTriples { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConstructTriples: called CC=3 SCAR=15.7
| |||||||||||||||||||||||||||||||||||||||||||
| 1138 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1139 | 4 | $self->_TriplesSameSubject; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | 4 | ▶ | while ($self->_test(qr/[.]/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1142 | 0 | $self->_eat( qr/[.]/ ); | |||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | if ($self->_ConstructTriples_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | $self->_TriplesSameSubject; | |||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||
| 1150 | # [32] TriplesSameSubject ::= VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | 149 | ▶ | sub _TriplesSameSubject { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_TriplesSameSubject: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1152 | 149 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1153 | 149 | my @triples; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | 149 | ▶ | if ($self->_TriplesNode_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1155 | 4 | $self->_TriplesNode; | |||||||||||||||||||||||||||||||||||||||||
| 1156 | 4 | my ($s) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1157 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1158 | 4 | $self->_PropertyList; | |||||||||||||||||||||||||||||||||||||||||
| 1159 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||
| 1161 | 4 | my @list = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1162 | 4 | foreach my $data (@list) { | |||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | push(@triples, $self->__new_statement( $s, @$data )); | |||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | 145 | $self->_VarOrTerm; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | 145 | my ($s) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||
| 1169 | 145 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1170 | 145 | $self->_PropertyListNotEmpty; | |||||||||||||||||||||||||||||||||||||||||
| 1171 | 145 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1172 | 145 | my (@list) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1173 | 145 | foreach my $data (@list) { | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 185 | push(@triples, $self->__new_statement( $s, @$data )); | |||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | 149 | $self->_add_patterns( @triples ); | |||||||||||||||||||||||||||||||||||||||||
| 1179 | # return @triples; | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | # [33] PropertyListNotEmpty ::= Verb ObjectList ( ';' ( Verb ObjectList )? )* | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | 148 | ▶ | sub _PropertyListNotEmpty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_PropertyListNotEmpty: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 148 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1185 | 148 | $self->_Verb; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 148 | my ($v) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | 148 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1188 | 148 | $self->_ObjectList; | |||||||||||||||||||||||||||||||||||||||||
| 1189 | 148 | my @l = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1190 | 148 | my @props = map { [$v, $_] } @l; | |||||||||||||||||||||||||||||||||||||||||
| 1191 | 148 | ▶ | while ($self->_test(qr'\s*;')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1192 | 45 | $self->_eat(';'); | |||||||||||||||||||||||||||||||||||||||||
| 1193 | 45 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1194 | 45 | ▶ | if ($self->_Verb_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1195 | 45 | $self->_Verb; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | 45 | my ($v) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1197 | 45 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1198 | 45 | $self->_ObjectList; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | 45 | my @l = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1200 | 45 | push(@props, map { [$v, $_] } @l); | |||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | 148 | $self->_add_stack( @props ); | |||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | # [34] PropertyList ::= PropertyListNotEmpty? | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | 4 | ▶ | sub _PropertyList { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_PropertyList: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | 4 | ▶ | if ($self->_Verb_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | $self->_PropertyListNotEmpty; | |||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | # [35] ObjectList ::= Object ( ',' Object )* | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 193 | ▶ | sub _ObjectList { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ObjectList: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 193 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 193 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 1219 | 193 | $self->_Object; | |||||||||||||||||||||||||||||||||||||||||
| 1220 | 193 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||
| 1222 | 193 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1223 | 193 | ▶ | while ($self->_test(',')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | 1 | $self->_eat(','); | |||||||||||||||||||||||||||||||||||||||||
| 1225 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 1 | $self->_Object; | |||||||||||||||||||||||||||||||||||||||||
| 1227 | 1 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | 193 | $self->_add_stack( @list ); | |||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||
| 1233 | # [36] Object ::= GraphNode | ||||||||||||||||||||||||||||||||||||||||||
| 1234 | 194 | ▶ | sub _Object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Object: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1235 | 194 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | 194 | $self->_GraphNode; | |||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||
| 1239 | # [37] Verb ::= VarOrIRIref | 'a' | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | 49 | ▶ | sub _Verb_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Verb_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1241 | 49 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | 49 | return $self->_test( qr/a[\n\t\r <]|[?\$]|<|${r_PNAME_LN}|${r_PNAME_NS}/ ); | |||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||
| 1245 | 193 | ▶ | sub _Verb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Verb: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1246 | 193 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1247 | 193 | ▶ | if ($self->_test(qr/a[\n\t\r <]/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1248 | 41 | $self->_eat('a'); | |||||||||||||||||||||||||||||||||||||||||
| 1249 | 41 | $self->__consume_ws; | |||||||||||||||||||||||||||||||||||||||||
| 1250 | 41 | my $type = RDF::Query::Node::Resource->new( $rdf->type->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 41 | $self->_add_stack( $type ); | |||||||||||||||||||||||||||||||||||||||||
| 1252 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1253 | 152 | $self->_VarOrIRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | # [38] TriplesNode ::= Collection | BlankNodePropertyList | ||||||||||||||||||||||||||||||||||||||||||
| 1258 | 349 | ▶ | sub _TriplesNode_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_TriplesNode_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 349 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 349 | return $self->_test(qr/[[(](?![\n\r\t ]*\])(?![\n\r\t ]*\))/); | |||||||||||||||||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||
| 1263 | 5 | ▶ | sub _TriplesNode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_TriplesNode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1264 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1265 | 5 | ▶ | if ($self->_test(qr/\(/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1266 | 2 | $self->_Collection; | |||||||||||||||||||||||||||||||||||||||||
| 1267 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | 3 | $self->_BlankNodePropertyList; | |||||||||||||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | |||||||||||||||||||||||||||||||||||||||||||
| 1272 | # [39] BlankNodePropertyList ::= '[' PropertyListNotEmpty ']' | ||||||||||||||||||||||||||||||||||||||||||
| 1273 | 3 | ▶ | sub _BlankNodePropertyList { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BlankNodePropertyList: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1274 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1275 | 3 | $self->_eat('['); | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 3 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1277 | 3 | $self->_PropertyListNotEmpty; | |||||||||||||||||||||||||||||||||||||||||
| 1278 | 3 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1279 | 3 | $self->_eat(']'); | |||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||
| 1281 | 3 | my @props = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1282 | 3 | my $subj = $self->new_blank; | |||||||||||||||||||||||||||||||||||||||||
| 1283 | 3 | my @triples = map { $self->__new_statement( $subj, @$_ ) } @props; | |||||||||||||||||||||||||||||||||||||||||
| 1284 | 3 | $self->_add_patterns( @triples ); | |||||||||||||||||||||||||||||||||||||||||
| 1285 | 3 | $self->_add_stack( $subj ); | |||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||
| 1288 | # [40] Collection ::= '(' GraphNode+ ')' | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | 2 | ▶ | sub _Collection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Collection: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1290 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1291 | 2 | $self->_eat('('); | |||||||||||||||||||||||||||||||||||||||||
| 1292 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1293 | 2 | $self->_GraphNode; | |||||||||||||||||||||||||||||||||||||||||
| 1294 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||
| 1296 | 2 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||
| 1297 | 2 | push(@nodes, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||
| 1299 | 2 | ▶ | while ($self->_GraphNode_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1300 | 4 | $self->_GraphNode; | |||||||||||||||||||||||||||||||||||||||||
| 1301 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1302 | 4 | push(@nodes, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||
| 1305 | 2 | $self->_eat(')'); | |||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||
| 1307 | 2 | my $subj = $self->new_blank; | |||||||||||||||||||||||||||||||||||||||||
| 1308 | 2 | my $cur = $subj; | |||||||||||||||||||||||||||||||||||||||||
| 1309 | 2 | my $last; | |||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||
| 1311 | 2 | my $first = RDF::Query::Node::Resource->new( $rdf->first->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1312 | 2 | my $rest = RDF::Query::Node::Resource->new( $rdf->rest->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1313 | 2 | my $nil = RDF::Query::Node::Resource->new( $rdf->nil->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||
| 1316 | 2 | my @triples; | |||||||||||||||||||||||||||||||||||||||||
| 1317 | 2 | foreach my $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||
| 1318 | 6 | push(@triples, $self->__new_statement( $cur, $first, $node ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1319 | 6 | my $new = $self->new_blank; | |||||||||||||||||||||||||||||||||||||||||
| 1320 | 6 | push(@triples, $self->__new_statement( $cur, $rest, $new ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1321 | 6 | $last = $cur; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | 6 | $cur = $new; | |||||||||||||||||||||||||||||||||||||||||
| 1323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | 2 | pop(@triples); | |||||||||||||||||||||||||||||||||||||||||
| 1325 | 2 | push(@triples, $self->__new_statement( $last, $rest, $nil )); | |||||||||||||||||||||||||||||||||||||||||
| 1326 | 2 | $self->_add_patterns( @triples ); | |||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||
| 1328 | 2 | $self->_add_stack( $subj ); | |||||||||||||||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||
| 1331 | # [41] GraphNode ::= VarOrTerm | TriplesNode | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | 6 | ▶ | sub _GraphNode_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphNode_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1333 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | # VarOrTerm | TriplesNode -> (Var | GraphTerm) | (Collection | BlankNodePropertyList) -> Var | IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | Collection | BlankNodePropertyList | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | # but since a triple can't start with a literal, this is reduced to: | ||||||||||||||||||||||||||||||||||||||||||
| 1336 | # Var | IRIref | BlankNode | NIL | ||||||||||||||||||||||||||||||||||||||||||
| 1337 | 6 | return $self->_test(qr/[\$?]|<|['"]|(true\b|false\b)|([+-]?\d)|_:|${r_ANON}|${r_NIL}|\[|[[(]/); | |||||||||||||||||||||||||||||||||||||||||
| 1338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||
| 1340 | 200 | ▶ | sub _GraphNode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphNode: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1341 | 200 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1342 | 200 | ▶ | if ($self->_TriplesNode_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1343 | 1 | $self->_TriplesNode; | |||||||||||||||||||||||||||||||||||||||||
| 1344 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | 199 | $self->_VarOrTerm; | |||||||||||||||||||||||||||||||||||||||||
| 1346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||
| 1349 | # [42] VarOrTerm ::= Var | GraphTerm | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | ▶ | sub _VarOrTerm_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VarOrTerm_test: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1351 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | return 1 if ($self->_test(qr/[\$?]/)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | ▶ | return 1 if ($self->_test(qr/[<'".0-9]|(true|false)\b|_:|\([\n\r\t ]*\)/)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1354 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||
| 1357 | 344 | ▶ | sub _VarOrTerm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VarOrTerm: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 344 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1359 | 344 | ▶ | if ($self->{tokens} =~ m'^[?$]') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1360 | 250 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 1361 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | 94 | $self->_GraphTerm; | |||||||||||||||||||||||||||||||||||||||||
| 1363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||
| 1366 | # [43] VarOrIRIref ::= Var | IRIref | ||||||||||||||||||||||||||||||||||||||||||
| 1367 | 4 | ▶ | sub _VarOrIRIref_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VarOrIRIref_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1368 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1369 | 4 | return $self->_test(qr/[\$?]|<|${r_PNAME_LN}|${r_PNAME_NS}/); | |||||||||||||||||||||||||||||||||||||||||
| 1370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||
| 1372 | 166 | ▶ | sub _VarOrIRIref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_VarOrIRIref: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1373 | 166 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1374 | 166 | ▶ | if ($self->{tokens} =~ m'^[?$]') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1375 | 20 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 1376 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | 146 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||
| 1381 | # [44] Var ::= VAR1 | VAR2 | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | 426 | ▶ | sub _Var { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Var: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1383 | 426 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1384 | 426 | ▶ | my $var = ($self->_test( $r_VAR1 )) ? $self->_eat( $r_VAR1 ) : $self->_eat( $r_VAR2 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1385 | 426 | $self->_add_stack( RDF::Query::Node::Variable->new( substr($var,1) ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | # [45] GraphTerm ::= IRIref | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | 94 | ▶ | sub _GraphTerm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GraphTerm: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1390 | 94 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1391 | 94 | ▶ | if ($self->_test(qr/(true|false)\b/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | $self->_BooleanLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1393 | } elsif ($self->_test('(')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | $self->_NIL; | |||||||||||||||||||||||||||||||||||||||||
| 1395 | ▶ | } elsif ($self->_test( $r_ANON ) or $self->_test('_:')) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->_test($RDF::Query::Parser::SPARQL::r_ANON) or $self->_test("_:")
MC/DC50%1/2
$self->_test($RDF::Query::Parser::SPARQL::r_ANON) or $self->_test("_:")
$self->_test($RDF::Query::Parser::SPARQL::r_ANON)
$self->_test("_:")
Truth table66%2/3
A or B
A= $self->_test($RDF::Query::Parser::SPARQL::r_ANON)B= $self->_test("_:")
| |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 2 | $self->_BlankNode; | |||||||||||||||||||||||||||||||||||||||||
| 1397 | } elsif ($self->_test(qr/[-+]?\d/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1398 | 0 | $self->_NumericLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1399 | } elsif ($self->_test(qr/['"]/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | 46 | $self->_RDFLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1401 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | 46 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||
| 1406 | # [46] Expression ::= ConditionalOrExpression | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | 68 | ▶ | sub _Expression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Expression: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1408 | 68 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1409 | 68 | $self->_ConditionalOrExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||
| 1412 | # [47] ConditionalOrExpression ::= ConditionalAndExpression ( '||' ConditionalAndExpression )* | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | 68 | ▶ | sub _ConditionalOrExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConditionalOrExpression: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1414 | 68 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1415 | 68 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||
| 1417 | 68 | $self->_ConditionalAndExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1418 | 68 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||
| 1420 | 68 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1421 | 68 | ▶ | while ($self->_test('||')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1422 | 1 | $self->_eat('||'); | |||||||||||||||||||||||||||||||||||||||||
| 1423 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1424 | 1 | $self->_ConditionalAndExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1425 | 1 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||
| 1428 | 68 | ▶ | if (scalar(@list) > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1429 | 1 | $self->_add_stack( $self->new_function_expression( 'sparql:logical-or', @list ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1430 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | 67 | $self->_add_stack( @list ); | |||||||||||||||||||||||||||||||||||||||||
| 1432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1433 | 68 | ▶ | Carp::confess $self->{tokens} if (scalar(@{ $self->{stack} }) == 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||
| 1436 | # [48] ConditionalAndExpression ::= ValueLogical ( '&&' ValueLogical )* | ||||||||||||||||||||||||||||||||||||||||||
| 1437 | 69 | ▶ | sub _ConditionalAndExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ConditionalAndExpression: called CC=4 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1438 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1439 | 69 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 1440 | |||||||||||||||||||||||||||||||||||||||||||
| 1441 | 69 | $self->_ValueLogical; | |||||||||||||||||||||||||||||||||||||||||
| 1442 | 69 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1443 | 69 | ▶ | Carp::confess Dumper(\@list) if (scalar(@list) > 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||
| 1445 | 69 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1446 | 69 | ▶ | while ($self->_test('&&')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | $self->_eat('&&'); | |||||||||||||||||||||||||||||||||||||||||
| 1448 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1449 | 0 | $self->_ValueLogical; | |||||||||||||||||||||||||||||||||||||||||
| 1450 | 0 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | |||||||||||||||||||||||||||||||||||||||||||
| 1453 | 69 | ▶ | if (scalar(@list) > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1454 | 0 | $self->_add_stack( $self->new_function_expression( 'sparql:logical-and', @list ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1455 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | 69 | $self->_add_stack( @list ); | |||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||
| 1460 | # [49] ValueLogical ::= RelationalExpression | ||||||||||||||||||||||||||||||||||||||||||
| 1461 | 69 | ▶ | sub _ValueLogical { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ValueLogical: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1462 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1463 | 69 | $self->_RelationalExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | # [50] RelationalExpression ::= NumericExpression ( '=' NumericExpression | '!=' NumericExpression | '<' NumericExpression | '>' NumericExpression | '<=' NumericExpression | '>=' NumericExpression )? | ||||||||||||||||||||||||||||||||||||||||||
| 1467 | 69 | ▶ | sub _RelationalExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_RelationalExpression: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1468 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1469 | 69 | $self->_NumericExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||||||||||
| 1471 | 69 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1472 | 69 | ▶ | if ($self->_test(qr/[!<>]?=|[<>]/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1473 | 13 | ▶ | if ($self->_test( $r_IRI_REF )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1474 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: IRI found where expression expected"; | |||||||||||||||||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | 13 | my @list = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1477 | 13 | my $op = $self->_eat(qr/[!<>]?=|[<>]/); | |||||||||||||||||||||||||||||||||||||||||
| 1478 | 13 | ▶ | $op = '==' if ($op eq '='); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1479 | 13 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1480 | 13 | $self->_NumericExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1481 | 13 | push(@list, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1482 | 13 | $self->_add_stack( $self->new_binary_expression( $op, @list ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||
| 1486 | # [51] NumericExpression ::= AdditiveExpression | ||||||||||||||||||||||||||||||||||||||||||
| 1487 | 82 | ▶ | sub _NumericExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_NumericExpression: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 82 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1489 | 82 | $self->_AdditiveExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||||||||||||
| 1492 | # [52] AdditiveExpression ::= MultiplicativeExpression ( '+' MultiplicativeExpression | '-' MultiplicativeExpression | NumericLiteralPositive | NumericLiteralNegative )* | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | 82 | ▶ | sub _AdditiveExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_AdditiveExpression: called CC=2 SCAR=8.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1494 | 82 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1495 | 82 | $self->_MultiplicativeExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1496 | 82 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||
| 1498 | 82 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1499 | 82 | ▶ | while ($self->_test(qr/[-+]/)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1500 | 0 | my $op = $self->_eat(qr/[-+]/); | |||||||||||||||||||||||||||||||||||||||||
| 1501 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1502 | 0 | $self->_MultiplicativeExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | 0 | my ($rhs) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1504 | 0 | $expr = $self->new_binary_expression( $op, $expr, $rhs ); | |||||||||||||||||||||||||||||||||||||||||
| 1505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1506 | 82 | $self->_add_stack( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||
| 1509 | # [53] MultiplicativeExpression ::= UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )* | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | 82 | ▶ | sub _MultiplicativeExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_MultiplicativeExpression: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1511 | 82 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1512 | 82 | $self->_UnaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1513 | 82 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||
| 1515 | 82 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1516 | 82 | ▶ | while ($self->_test(qr#[*/]#)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1517 | 2 | my $op = $self->_eat(qr#[*/]#); | |||||||||||||||||||||||||||||||||||||||||
| 1518 | 2 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1519 | 2 | $self->_UnaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1520 | 2 | my ($rhs) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1521 | 2 | $expr = $self->new_binary_expression( $op, $expr, $rhs ); | |||||||||||||||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | 82 | $self->_add_stack( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1525 | |||||||||||||||||||||||||||||||||||||||||||
| 1526 | # [54] UnaryExpression ::= '!' PrimaryExpression | '+' PrimaryExpression | '-' PrimaryExpression | PrimaryExpression | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | 84 | ▶ | sub _UnaryExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_UnaryExpression: called CC=10 SCAR=36.2
| |||||||||||||||||||||||||||||||||||||||||||
| 1528 | 84 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1529 | 84 | ▶ | if ($self->_test('!')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1530 | 0 | $self->_eat('!'); | |||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | $self->_PrimaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | my $not = $self->new_unary_expression( '!', $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1535 | 0 | $self->_add_stack( $not ); | |||||||||||||||||||||||||||||||||||||||||
| 1536 | } elsif ($self->_test('+')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1537 | 0 | $self->_eat('+'); | |||||||||||||||||||||||||||||||||||||||||
| 1538 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1539 | 0 | $self->_PrimaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1540 | 0 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||
| 1542 | ### if it's just a literal, force the positive down into the literal | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | 0 | ▶ | if (blessed($expr) and $expr->isa('RDF::Trine::Node::Literal') and $expr->is_numeric_type) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal") and $expr->is_numeric_type
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal")
MC/DC0%0/3
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal") and $expr->is_numeric_type
builtin::blessed($expr)
$expr->isa("RDF::Trine::Node::Literal")
$expr->is_numeric_type
Truth table0%0/4
A and B and C
A= builtin::blessed($expr)B= $expr->isa("RDF::Trine::Node::Literal")C= $expr->is_numeric_type
| |||||||||||||||||||||||||||||||||||||||||||
| 1544 | 0 | my $value = '+' . $expr->literal_value; | |||||||||||||||||||||||||||||||||||||||||
| 1545 | 0 | $expr->literal_value( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 1546 | 0 | $self->_add_stack( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1547 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | $self->_add_stack( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | } elsif ($self->_test('-')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1551 | 4 | $self->_eat('-'); | |||||||||||||||||||||||||||||||||||||||||
| 1552 | 4 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1553 | 4 | $self->_PrimaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1554 | 4 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||
| 1556 | ### if it's just a literal, force the negative down into the literal instead of make an unnecessary multiplication. | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | 4 | ▶ | if (blessed($expr) and $expr->isa('RDF::Trine::Node::Literal') and $expr->is_numeric_type) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal") and $expr->is_numeric_type
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal")
MC/DC0%0/3
builtin::blessed($expr) and $expr->isa("RDF::Trine::Node::Literal") and $expr->is_numeric_type
builtin::blessed($expr)
$expr->isa("RDF::Trine::Node::Literal")
$expr->is_numeric_type
Truth table25%1/4
A and B and C
A= builtin::blessed($expr)B= $expr->isa("RDF::Trine::Node::Literal")C= $expr->is_numeric_type
| |||||||||||||||||||||||||||||||||||||||||||
| 1558 | 4 | my $value = -1 * $expr->literal_value; | |||||||||||||||||||||||||||||||||||||||||
| 1559 | 4 | $expr->literal_value( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 1560 | 4 | $self->_add_stack( $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1561 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | my $int = $xsd->integer->uri_value; | |||||||||||||||||||||||||||||||||||||||||
| 1563 | 0 | my $neg = $self->new_binary_expression( '*', $self->new_literal('-1', undef, $int), $expr ); | |||||||||||||||||||||||||||||||||||||||||
| 1564 | 0 | $self->_add_stack( $neg ); | |||||||||||||||||||||||||||||||||||||||||
| 1565 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1566 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1567 | 80 | $self->_PrimaryExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||
| 1571 | # [55] PrimaryExpression ::= BrackettedExpression | BuiltInCall | IRIrefOrFunction | RDFLiteral | NumericLiteral | BooleanLiteral | Var | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | 84 | ▶ | sub _PrimaryExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_PrimaryExpression: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1573 | 84 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1574 | 84 | ▶ | if ($self->_BrackettedExpression_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1575 | 0 | $self->_BrackettedExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1576 | } elsif ($self->_BuiltInCall_test) { | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | 15 | $self->_BuiltInCall; | |||||||||||||||||||||||||||||||||||||||||
| 1578 | } elsif ($self->_IRIref_test) { | ||||||||||||||||||||||||||||||||||||||||||
| 1579 | 13 | $self->_IRIrefOrFunction; | |||||||||||||||||||||||||||||||||||||||||
| 1580 | } elsif ($self->_test(qr/[\$?]/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | 25 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 1582 | } elsif ($self->_test(qr/(true|false)\b/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1583 | 0 | $self->_BooleanLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1584 | } elsif ($self->_test(qr/[-+]?\d/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | 8 | $self->_NumericLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1586 | } else { # if ($self->_test(qr/['"]/)) { | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | 23 | $self->_RDFLiteral; | |||||||||||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||||||||||||||||
| 1591 | # [56] BrackettedExpression ::= '(' Expression ')' | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | 109 | ▶ | sub _BrackettedExpression_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BrackettedExpression_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1593 | 109 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1594 | 109 | return $self->_test('('); | |||||||||||||||||||||||||||||||||||||||||
| 1595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||||||||||||||||
| 1597 | 20 | ▶ | sub _BrackettedExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BrackettedExpression: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1598 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1599 | 20 | $self->_eat('('); | |||||||||||||||||||||||||||||||||||||||||
| 1600 | 20 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1601 | 20 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1602 | 20 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1603 | 20 | $self->_eat(')'); | |||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||
| 1606 | # [57] BuiltInCall ::= 'STR' '(' Expression ')' | 'LANG' '(' Expression ')' | 'LANGMATCHES' '(' Expression ',' Expression ')' | 'DATATYPE' '(' Expression ')' | 'BOUND' '(' Var ')' | 'sameTerm' '(' Expression ',' Expression ')' | 'isIRI' '(' Expression ')' | 'isURI' '(' Expression ')' | 'isBLANK' '(' Expression ')' | 'isLITERAL' '(' Expression ')' | RegexExpression | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | 98 | ▶ | sub _BuiltInCall_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BuiltInCall_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1608 | 98 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1609 | 98 | return $self->_test(qr/STR|LANG|LANGMATCHES|DATATYPE|BOUND|sameTerm|isIRI|isURI|isBLANK|isLITERAL|REGEX/i); | |||||||||||||||||||||||||||||||||||||||||
| 1610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | 21 | ▶ | sub _BuiltInCall { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BuiltInCall: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1613 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1614 | 21 | ▶ | if ($self->_RegexExpression_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1615 | 6 | $self->_RegexExpression; | |||||||||||||||||||||||||||||||||||||||||
| 1616 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1617 | 15 | my $op = $self->_eat( qr/\w+/ ); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | 15 | my $iri = RDF::Query::Node::Resource->new( 'sparql:' . lc($op) ); | |||||||||||||||||||||||||||||||||||||||||
| 1619 | 15 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1620 | 15 | $self->_eat('('); | |||||||||||||||||||||||||||||||||||||||||
| 1621 | 15 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1622 | 15 | ▶ | if ($op =~ /^(STR|LANG|DATATYPE|isIRI|isURI|isBLANK|isLITERAL)$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1623 | ### one-arg functions that take an expression | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | 13 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1625 | 13 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1626 | 13 | $self->_add_stack( $self->new_function_expression($iri, $expr) ); | |||||||||||||||||||||||||||||||||||||||||
| 1627 | } elsif ($op =~ /^(LANGMATCHES|sameTerm)$/i) { | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | ### two-arg functions that take expressions | ||||||||||||||||||||||||||||||||||||||||||
| 1629 | 1 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1630 | 1 | my ($arg1) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1631 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1632 | 1 | $self->_eat(','); | |||||||||||||||||||||||||||||||||||||||||
| 1633 | 1 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1634 | 1 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1635 | 1 | my ($arg2) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1636 | 1 | $self->_add_stack( $self->new_function_expression($iri, $arg1, $arg2) ); | |||||||||||||||||||||||||||||||||||||||||
| 1637 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | ### BOUND(Var) | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | 1 | $self->_Var; | |||||||||||||||||||||||||||||||||||||||||
| 1640 | 1 | my ($expr) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1641 | 1 | $self->_add_stack( $self->new_function_expression($iri, $expr) ); | |||||||||||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | 15 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1644 | 15 | $self->_eat(')'); | |||||||||||||||||||||||||||||||||||||||||
| 1645 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1646 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1647 | |||||||||||||||||||||||||||||||||||||||||||
| 1648 | # [58] RegexExpression ::= 'REGEX' '(' Expression ',' Expression ( ',' Expression )? ')' | ||||||||||||||||||||||||||||||||||||||||||
| 1649 | 21 | ▶ | sub _RegexExpression_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_RegexExpression_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1650 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1651 | 21 | return $self->_test( qr/REGEX/i ); | |||||||||||||||||||||||||||||||||||||||||
| 1652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | |||||||||||||||||||||||||||||||||||||||||||
| 1654 | 6 | ▶ | sub _RegexExpression { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_RegexExpression: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1655 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1656 | 6 | $self->_eat( qr/REGEX/i ); | |||||||||||||||||||||||||||||||||||||||||
| 1657 | 6 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1658 | 6 | $self->_eat('('); | |||||||||||||||||||||||||||||||||||||||||
| 1659 | 6 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1660 | 6 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1661 | 6 | my $string = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||
| 1663 | 6 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1664 | 6 | $self->_eat(','); | |||||||||||||||||||||||||||||||||||||||||
| 1665 | 6 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1666 | 6 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1667 | 6 | my $pattern = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||
| 1669 | 6 | my @args = ($string, $pattern); | |||||||||||||||||||||||||||||||||||||||||
| 1670 | 6 | ▶ | if ($self->_test(',')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | $self->_eat(','); | |||||||||||||||||||||||||||||||||||||||||
| 1672 | 0 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | $self->_Expression; | |||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | push(@args, splice(@{ $self->{stack} })); | |||||||||||||||||||||||||||||||||||||||||
| 1675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||||||||||||||||
| 1677 | 6 | $self->__consume_ws_opt; | |||||||||||||||||||||||||||||||||||||||||
| 1678 | 6 | $self->_eat(')'); | |||||||||||||||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||||||||||||||||
| 1680 | 6 | my $iri = RDF::Query::Node::Resource->new( 'sparql:regex' ); | |||||||||||||||||||||||||||||||||||||||||
| 1681 | 6 | $self->_add_stack( $self->new_function_expression( $iri, @args ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||||||||||||||||
| 1684 | # [59] IRIrefOrFunction ::= IRIref ArgList? | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | ▶ | sub _IRIrefOrFunction_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_IRIrefOrFunction_test: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1686 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | $self->_IRIref_test; | |||||||||||||||||||||||||||||||||||||||||
| 1688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||||||||||||
| 1690 | 13 | ▶ | sub _IRIrefOrFunction { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_IRIrefOrFunction: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1692 | 13 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1693 | 13 | ▶ | if ($self->_ArgList_test) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1694 | 11 | my ($iri) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1695 | 11 | $self->_ArgList; | |||||||||||||||||||||||||||||||||||||||||
| 1696 | 11 | my @args = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1697 | 11 | my $func = $self->new_function_expression( $iri, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 1698 | 11 | $self->_add_stack( $func ); | |||||||||||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1700 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | |||||||||||||||||||||||||||||||||||||||||||
| 1702 | # [60] RDFLiteral ::= String ( LANGTAG | ( '^^' IRIref ) )? | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | 69 | ▶ | sub _RDFLiteral { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_RDFLiteral: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1705 | 69 | $self->_String; | |||||||||||||||||||||||||||||||||||||||||
| 1706 | 69 | my @args = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1707 | 69 | ▶ | if ($self->_test('@')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1708 | 1 | my $lang = $self->_eat( $r_LANGTAG ); | |||||||||||||||||||||||||||||||||||||||||
| 1709 | 1 | substr($lang,0,1) = ''; # remove '@' | |||||||||||||||||||||||||||||||||||||||||
| 1710 | 1 | push(@args, lc($lang)); | |||||||||||||||||||||||||||||||||||||||||
| 1711 | } elsif ($self->_test('^^')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1712 | 7 | $self->_eat('^^'); | |||||||||||||||||||||||||||||||||||||||||
| 1713 | 7 | push(@args, undef); | |||||||||||||||||||||||||||||||||||||||||
| 1714 | 7 | $self->_IRIref; | |||||||||||||||||||||||||||||||||||||||||
| 1715 | 7 | my ($iri) = splice(@{ $self->{stack} }); | |||||||||||||||||||||||||||||||||||||||||
| 1716 | 7 | push(@args, $iri->uri_value); | |||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | 69 | $self->_add_stack( RDF::Query::Node::Literal->new( @args ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||
| 1721 | # [61] NumericLiteral ::= NumericLiteralUnsigned | NumericLiteralPositive | NumericLiteralNegative | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | # [62] NumericLiteralUnsigned ::= INTEGER | DECIMAL | DOUBLE | ||||||||||||||||||||||||||||||||||||||||||
| 1723 | # [63] NumericLiteralPositive ::= INTEGER_POSITIVE | DECIMAL_POSITIVE | DOUBLE_POSITIVE | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | # [64] NumericLiteralNegative ::= INTEGER_NEGATIVE | DECIMAL_NEGATIVE | DOUBLE_NEGATIVE | ||||||||||||||||||||||||||||||||||||||||||
| 1725 | 8 | ▶ | sub _NumericLiteral { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_NumericLiteral: called CC=6 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1726 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1727 | 8 | my $sign = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1728 | 8 | ▶ | if ($self->_test('+')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | $self->_eat('+'); | |||||||||||||||||||||||||||||||||||||||||
| 1730 | 0 | $sign = '+'; | |||||||||||||||||||||||||||||||||||||||||
| 1731 | } elsif ($self->_test('-')) { | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | 0 | $self->_eat('-'); | |||||||||||||||||||||||||||||||||||||||||
| 1733 | 0 | $sign = '-'; | |||||||||||||||||||||||||||||||||||||||||
| 1734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||
| 1736 | 8 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 1737 | my $type; | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | 8 | ▶ | if ($self->_test( $r_DOUBLE )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1739 | 0 | $value = $self->_eat( $r_DOUBLE ); | |||||||||||||||||||||||||||||||||||||||||
| 1740 | 0 | my $double = RDF::Query::Node::Resource->new( $xsd->double->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | $type = $double | |||||||||||||||||||||||||||||||||||||||||
| 1742 | } elsif ($self->_test( $r_DECIMAL )) { | ||||||||||||||||||||||||||||||||||||||||||
| 1743 | 4 | $value = $self->_eat( $r_DECIMAL ); | |||||||||||||||||||||||||||||||||||||||||
| 1744 | 4 | my $decimal = RDF::Query::Node::Resource->new( $xsd->decimal->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1745 | 4 | $type = $decimal; | |||||||||||||||||||||||||||||||||||||||||
| 1746 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1747 | 4 | $value = $self->_eat( $r_INTEGER ); | |||||||||||||||||||||||||||||||||||||||||
| 1748 | 4 | my $integer = RDF::Query::Node::Resource->new( $xsd->integer->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1749 | 4 | $type = $integer; | |||||||||||||||||||||||||||||||||||||||||
| 1750 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||
| 1752 | 8 | ▶ | if ($sign) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1753 | 0 | $value = $sign . $value; | |||||||||||||||||||||||||||||||||||||||||
| 1754 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | 8 | $self->_add_stack( RDF::Query::Node::Literal->new( $value, undef, $type->uri_value ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||
| 1758 | # [65] BooleanLiteral ::= 'true' | 'false' | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | sub _BooleanLiteral { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BooleanLiteral: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1760 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | my $bool = $self->_eat(qr/(true|false)\b/); | |||||||||||||||||||||||||||||||||||||||||
| 1762 | 0 | $self->_add_stack( RDF::Query::Node::Literal->new( $bool, undef, $xsd->boolean->uri_value ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||||||||||
| 1765 | # [66] String ::= STRING_LITERAL1 | STRING_LITERAL2 | STRING_LITERAL_LONG1 | STRING_LITERAL_LONG2 | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | 69 | ▶ | sub _String { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_String: called CC=4 SCAR=14.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1767 | 69 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1768 | 69 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 1769 | 69 | ▶ | if ($self->_test( $r_STRING_LITERAL_LONG1 )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1770 | 0 | my $string = $self->_eat( $r_STRING_LITERAL_LONG1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1771 | 0 | $value = substr($string, 3, length($string) - 6); | |||||||||||||||||||||||||||||||||||||||||
| 1772 | } elsif ($self->_test( $r_STRING_LITERAL_LONG2 )) { | ||||||||||||||||||||||||||||||||||||||||||
| 1773 | 0 | my $string = $self->_eat( $r_STRING_LITERAL_LONG2 ); | |||||||||||||||||||||||||||||||||||||||||
| 1774 | 0 | $value = substr($string, 3, length($string) - 6); | |||||||||||||||||||||||||||||||||||||||||
| 1775 | } elsif ($self->_test( $r_STRING_LITERAL1 )) { | ||||||||||||||||||||||||||||||||||||||||||
| 1776 | 1 | my $string = $self->_eat( $r_STRING_LITERAL1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1777 | 1 | $value = substr($string, 1, length($string) - 2); | |||||||||||||||||||||||||||||||||||||||||
| 1778 | } else { # ($self->_test( $r_STRING_LITERAL2 )) { | ||||||||||||||||||||||||||||||||||||||||||
| 1779 | 68 | my $string = $self->_eat( $r_STRING_LITERAL2 ); | |||||||||||||||||||||||||||||||||||||||||
| 1780 | 68 | $value = substr($string, 1, length($string) - 2); | |||||||||||||||||||||||||||||||||||||||||
| 1781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1782 | # $value =~ s/(${r_ECHAR})/"$1"/ge; | ||||||||||||||||||||||||||||||||||||||||||
| 1783 | 69 | $value =~ s/\\t/\t/g; | |||||||||||||||||||||||||||||||||||||||||
| 1784 | 69 | $value =~ s/\\b/\x08/g; | |||||||||||||||||||||||||||||||||||||||||
| 1785 | 69 | $value =~ s/\\n/\n/g; | |||||||||||||||||||||||||||||||||||||||||
| 1786 | 69 | $value =~ s/\\r/\r/g; | |||||||||||||||||||||||||||||||||||||||||
| 1787 | 69 | $value =~ s/\\"/"/g; | |||||||||||||||||||||||||||||||||||||||||
| 1788 | 69 | $value =~ s/\\'/'/g; | |||||||||||||||||||||||||||||||||||||||||
| 1789 | 69 | $value =~ s/\\\\/\\/g; # backslash must come last, so it doesn't accidentally create a new escape | |||||||||||||||||||||||||||||||||||||||||
| 1790 | 69 | $self->_add_stack( $value ); | |||||||||||||||||||||||||||||||||||||||||
| 1791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||
| 1793 | # [67] IRIref ::= IRI_REF | PrefixedName | ||||||||||||||||||||||||||||||||||||||||||
| 1794 | 76 | ▶ | sub _IRIref_test { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_IRIref_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1795 | 76 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1796 | 76 | return $self->_test(qr/<|${r_PNAME_LN}|${r_PNAME_NS}/); | |||||||||||||||||||||||||||||||||||||||||
| 1797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||
| 1799 | 235 | ▶ | sub _IRIref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_IRIref: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1800 | 235 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1801 | 235 | ▶ | if ($self->_test( $r_IRI_REF )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1802 | 28 | my $iri = $self->_eat( $r_IRI_REF ); | |||||||||||||||||||||||||||||||||||||||||
| 1803 | 28 | my $node = RDF::Query::Node::Resource->new( substr($iri,1,length($iri)-2), $self->__base ); | |||||||||||||||||||||||||||||||||||||||||
| 1804 | 28 | $self->_add_stack( $node ); | |||||||||||||||||||||||||||||||||||||||||
| 1805 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1806 | 207 | $self->_PrefixedName; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||
| 1810 | # [68] PrefixedName ::= PNAME_LN | PNAME_NS | ||||||||||||||||||||||||||||||||||||||||||
| 1811 | 207 | ▶ | sub _PrefixedName { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_PrefixedName: called CC=6 SCAR=24.5
| |||||||||||||||||||||||||||||||||||||||||||
| 1812 | 207 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1813 | 207 | ▶ | if ($self->_test( $r_PNAME_LN )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1814 | 207 | my $ln = $self->_eat( $r_PNAME_LN ); | |||||||||||||||||||||||||||||||||||||||||
| 1815 | 207 | my ($ns,$local) = split(/:/, $ln); | |||||||||||||||||||||||||||||||||||||||||
| 1816 | 207 | ▶ | if ($ns eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 3 | $ns = '__DEFAULT__'; | |||||||||||||||||||||||||||||||||||||||||
| 1818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||
| 1820 | 207 | ▶ | unless (exists $self->{namespaces}{$ns}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: Use of undefined namespace '$ns'"; | |||||||||||||||||||||||||||||||||||||||||
| 1822 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1823 | |||||||||||||||||||||||||||||||||||||||||||
| 1824 | 207 | my $iri = $self->{namespaces}{$ns} . $local; | |||||||||||||||||||||||||||||||||||||||||
| 1825 | 207 | $self->_add_stack( RDF::Query::Node::Resource->new( $iri, $self->__base ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1826 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | my $ns = $self->_eat( $r_PNAME_NS ); | |||||||||||||||||||||||||||||||||||||||||
| 1828 | 0 | ▶ | if ($ns eq ':') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1829 | 0 | $ns = '__DEFAULT__'; | |||||||||||||||||||||||||||||||||||||||||
| 1830 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1831 | 0 | chop($ns); | |||||||||||||||||||||||||||||||||||||||||
| 1832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||
| 1834 | 0 | ▶ | unless (exists $self->{namespaces}{$ns}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1835 | 0 | throw RDF::Query::Error::ParseError -text => "Syntax error: Use of undefined namespace '$ns'"; | |||||||||||||||||||||||||||||||||||||||||
| 1836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||
| 1838 | 0 | my $iri = $self->{namespaces}{$ns}; | |||||||||||||||||||||||||||||||||||||||||
| 1839 | 0 | $self->_add_stack( RDF::Query::Node::Resource->new( $iri, $self->__base ) ); | |||||||||||||||||||||||||||||||||||||||||
| 1840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||
| 1843 | # [69] BlankNode ::= BLANK_NODE_LABEL | ANON | ||||||||||||||||||||||||||||||||||||||||||
| 1844 | 2 | ▶ | sub _BlankNode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_BlankNode: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1845 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1846 | 2 | ▶ | if ($self->_test( $r_BLANK_NODE_LABEL )) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1847 | 2 | my $label = $self->_eat( $r_BLANK_NODE_LABEL ); | |||||||||||||||||||||||||||||||||||||||||
| 1848 | 2 | my $id = substr($label,2); | |||||||||||||||||||||||||||||||||||||||||
| 1849 | 2 | $self->_add_stack( $self->new_blank($id) ); | |||||||||||||||||||||||||||||||||||||||||
| 1850 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | 0 | $self->_eat( $r_ANON ); | |||||||||||||||||||||||||||||||||||||||||
| 1852 | 0 | $self->_add_stack( $self->new_blank ); | |||||||||||||||||||||||||||||||||||||||||
| 1853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||
| 1856 | 0 | ▶ | sub _NIL { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_NIL: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1857 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1858 | 0 | $self->_eat( $r_NIL ); | |||||||||||||||||||||||||||||||||||||||||
| 1859 | 0 | my $nil = RDF::Query::Node::Resource->new( $rdf->nil->uri_value ); | |||||||||||||||||||||||||||||||||||||||||
| 1860 | 0 | $self->_add_stack( $nil ); | |||||||||||||||||||||||||||||||||||||||||
| 1861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||
| 1863 | 71 | ▶ | sub __solution_modifiers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__solution_modifiers: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1864 | 71 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1865 | 71 | my $star = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1866 | |||||||||||||||||||||||||||||||||||||||||||
| 1867 | 71 | my $vars = $self->{build}{variables}; | |||||||||||||||||||||||||||||||||||||||||
| 1868 | 71 | my $pattern = pop(@{ $self->{build}{triples} }); | |||||||||||||||||||||||||||||||||||||||||
| 1869 | 71 | my $proj = RDF::Query::Algebra::Project->new( $pattern, $vars ); | |||||||||||||||||||||||||||||||||||||||||
| 1870 | 71 | push(@{ $self->{build}{triples} }, $proj); | |||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||
| 1872 | 71 | ▶ | if ($self->{build}{options}{distinct}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1873 | 10 | delete $self->{build}{options}{distinct}; | |||||||||||||||||||||||||||||||||||||||||
| 1874 | 10 | my $pattern = pop(@{ $self->{build}{triples} }); | |||||||||||||||||||||||||||||||||||||||||
| 1875 | 10 | my $sort = RDF::Query::Algebra::Distinct->new( $pattern ); | |||||||||||||||||||||||||||||||||||||||||
| 1876 | 10 | push(@{ $self->{build}{triples} }, $sort); | |||||||||||||||||||||||||||||||||||||||||
| 1877 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 71 | ▶ | if (exists $self->{build}{options}{offset}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1880 | 3 | my $offset = delete $self->{build}{options}{offset}; | |||||||||||||||||||||||||||||||||||||||||
| 1881 | 3 | my $pattern = pop(@{ $self->{build}{triples} }); | |||||||||||||||||||||||||||||||||||||||||
| 1882 | 3 | my $offseted = RDF::Query::Algebra::Offset->new( $pattern, $offset ); | |||||||||||||||||||||||||||||||||||||||||
| 1883 | 3 | push(@{ $self->{build}{triples} }, $offseted); | |||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||
| 1886 | 71 | ▶ | if (exists $self->{build}{options}{limit}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1887 | 6 | my $limit = delete $self->{build}{options}{limit}; | |||||||||||||||||||||||||||||||||||||||||
| 1888 | 6 | my $pattern = pop(@{ $self->{build}{triples} }); | |||||||||||||||||||||||||||||||||||||||||
| 1889 | 6 | my $limited = RDF::Query::Algebra::Limit->new( $pattern, $limit ); | |||||||||||||||||||||||||||||||||||||||||
| 1890 | 6 | push(@{ $self->{build}{triples} }, $limited); | |||||||||||||||||||||||||||||||||||||||||
| 1891 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1892 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||
| 1894 | 36 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||
| 1896 | __END__ | ||||||||||||||||||||||||||||||||||||||||||