| 1 | 50 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 50 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | AtteanX::Functions::CompositeLists - Functions and aggregates to work with composite lists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | This document describes AtteanX::Functions::CompositeLists version 0.040 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | use Attean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | This is a utility package that defines functions and aggregates to work with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | composite list datatypes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 50 | package AtteanX::Functions::CompositeLists::TurtleLexerWithNull { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 50 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 50 | ▶ | use AtteanX::Parser::Turtle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 50 | ▶ | use AtteanX::SPARQL::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 50 | extends 'AtteanX::Parser::Turtle::Lexer'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub get_token { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_token: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $self->fill_buffer unless (length($self->buffer)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($self->buffer =~ /^[ \r\n\t]+/o) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $start_column = $self->column; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $start_line = $self->line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $ws = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # we're ignoring whitespace tokens, but we could return them here instead of falling through to the 'next': | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | unless ($self->ignore_whitespace) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | return $self->new_token(WS, $start_line, $start_column, $ws); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $c = $self->peek_char(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return unless (defined($c)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($c eq ':') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->read_length(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return AtteanX::Parser::Turtle::Token->fast_constructor(PREFIXNAME, -1, -1, -1, -1, [':']); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($self->buffer =~ /^null\b/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return $self->SUPER::get_token(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 50 | package AtteanX::Functions::CompositeLists 0.040 { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 50 | ▶ | use Attean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 50 | ▶ | use Attean::RDF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 50 | ▶ | use Encode qw(decode_utf8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 50 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 50 | ▶ | use Digest::SHA qw(sha1_hex); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 50 | ▶ | use AtteanX::Serializer::TurtleTokens; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 50 | ▶ | use AtteanX::Parser::Turtle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 50 | ▶ | use AtteanX::SPARQL::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 50 | ▶ | use AtteanX::Functions::CompositeMaps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 50 | our $CDT_BASE = 'http://w3id.org/awslabs/neptune/SPARQL-CDTs/'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 50 | our $LIST_TYPE_IRI = "${CDT_BASE}List"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =item C<< lex_to_list($literal) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub lex_to_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lex_to_list: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | die 'TypeError: Cannot parse non-literal to cdt:List' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | die 'TypeError: not a datatype literal' unless ($dt); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | die 'TypeError: Expecting a List but found ' . $dt->value unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $lex = $l->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $lex =~ s/^\s*//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $lex =~ s/\s*$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | unless ($lex =~ m<^\[(.*)\]$>s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | die 'TypeError: Invalid lexical form for cdt:List literal: ' . $dt->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | open(my $fh, '<:encoding(UTF-8)', \$lex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $p = AtteanX::Parser::Turtle->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | local($p->{enable_cdt_rewriting}) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $lexer = AtteanX::Functions::CompositeLists::TurtleLexerWithNull->new(file => $fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $t = $p->_next_nonws($lexer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($t->type == LBRACKET) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | push(@nodes, @{AtteanX::Functions::CompositeMaps::_recursive_lexer_parse_cdt($p, $lexer)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # while (my $t = $p->_next_nonws($lexer)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # # warn "TOKEN: $t\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # if ($t and not blessed($t)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # # this is the special value returned from our lexer subclass that indicates a null values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # push(@nodes, undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # next if ($t->type == COMMA); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # push(@nodes, $p->_object($lexer, $t)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # this would create fresh bnodes on each access: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # my $mapper = Attean::TermMap->uuid_blank_map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # return map { blessed($_) ? $mapper->map($_) : $_ } @nodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | =item C<< list_to_lex(@terms) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub list_to_lex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_to_lex: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my @terms = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $s = AtteanX::Serializer::TurtleTokens->new( suppress_whitespace => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $bytes = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | open(my $io, '>', \$bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | foreach my $t (@terms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my @tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | unless ($first) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | push(@tokens, AtteanX::Parser::Turtle::Token->fast_constructor(COMMA, -1, -1, -1, -1, [','])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (blessed($t)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | push(@tokens, $t->sparql_tokens->elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $iter = Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::Parser::Turtle::Token' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $s->serialize_iter_to_io($io, $iter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $iter = Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::Parser::Turtle::Token' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $s->serialize_iter_to_io($io, $iter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | print {$io} "null"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | close($io); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $str = decode_utf8($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | chomp($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return dtliteral("[${str}]", $LIST_TYPE_IRI); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | =item C<< stringSplit($string, $pattern) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub stringSplit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringSplit: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my @parts = map { literal($_) } split(quotemeta($pattern->value), $string->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return list_to_lex(@parts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | =item C<< listCreate(@list) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub listCreate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listCreate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $literal = eval { list_to_lex(@_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | warn "cdt:List constructor error: $@" if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return $literal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | =item C<< ctGet($ct, $key) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub ctGet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ctGet: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $ct = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $pos = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | die 'TypeError: Cannot interpret non-literal as CDT type' unless ($ct->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $dt = $ct->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ($dt->value eq $LIST_TYPE_IRI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return listGet($model, $active_graph, $ct, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } elsif ($dt->value eq $AtteanX::Functions::CompositeMaps::MAP_TYPE_IRI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return AtteanX::Functions::CompositeMaps::mapGet($model, $active_graph, $ct, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | die 'TypeError: Unexpected non-CDT type: ' . $dt->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | =item C<< listGet($list, $pos) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub listGet { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listGet: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $pos = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | die 'TypeError: Cannot interpret non-literal as cdt:List' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | die 'TypeError: Unexpected non-List type: ' . $dt->value unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | die 'TypeError' unless ($pos->does('Attean::API::NumericLiteral') and $pos->datatype->value eq 'http://www.w3.org/2001/XMLSchema#integer'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$pos->does("Attean::API::NumericLiteral") and $pos->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
MC/DC0%0/2
$pos->does("Attean::API::NumericLiteral") and $pos->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
$pos->does("Attean::API::NumericLiteral")
$pos->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
Truth table0%0/3
A and B
A= $pos->does("Attean::API::NumericLiteral")B= $pos->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $i = int($pos->value) - 1; # cdt:get is 1-based, while the array index below is 0-based | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | die 'Unexpected non-positive get index' unless ($i >= 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return $nodes[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | =item C<< listSubseq($list, $pos, $len) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub listSubseq { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listSubseq: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | foreach my $term (@_) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | die 'TypeError' unless ($term->does('Attean::API::NumericLiteral') and $term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#integer'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$term->does("Attean::API::NumericLiteral") and $term->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
MC/DC0%0/2
$term->does("Attean::API::NumericLiteral") and $term->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
$term->does("Attean::API::NumericLiteral")
$term->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
Truth table0%0/3
A and B
A= $term->does("Attean::API::NumericLiteral")B= $term->datatype->value eq "http://www.w3.org/2001/XMLSchema#integer"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $pos = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my @len = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $start = int($pos->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | die 'Unexpected non-positive subseq start argument' unless ($start > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my @length = map { int($_->value) } @len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if ($start == (1+scalar(@nodes))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | die 'Unexpected subseq start argument at end of list with non-zero length' unless ((scalar(@length) and $length[0] == 0) or not(scalar(@length))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
scalar @length and $length[0] == 0 or not scalar @length
scalar @length and $length[0] == 0
MC/DC0%0/3
scalar @length and $length[0] == 0 or not scalar @length
scalar @length
$length[0] == 0
not scalar @length
Truth table0%0/5
A and B or not(C)
A= scalar @lengthB= $length[0] == 0C= not scalar @length
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | die 'Unexpected subseq start argument past end of list' unless ($start < (1+scalar(@nodes))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (scalar(@length)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $end = $start + $length[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | die 'Subseq start+length is beyond the end of the array' if ($end > (1+scalar(@nodes))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my @orig = @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $from = $start-1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $to = scalar(@length) ? ($from + $length[0] - 1) : $#nodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my @seq = @nodes[$from .. $to]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return list_to_lex(@seq); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | =item C<< listConcat(@lists) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub listConcat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listConcat: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my @lists = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | foreach my $l (@lists) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | push(@nodes, lex_to_list($l)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return list_to_lex(@nodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | =item C<< listReverse($list, $pos) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub listReverse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listReverse: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | return list_to_lex(reverse @nodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | =item C<< listHead($list, $pos) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub listHead { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listHead: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return shift(@nodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | =item C<< listTail($list, $pos) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub listTail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listTail: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | unless (scalar(@nodes)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | die 'cdt:tail called on an empty list'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | shift(@nodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return list_to_lex(@nodes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | =item C<< listContains($list, $term) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | sub listContains { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listContains: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $term = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | die 'TypeError: Not a literal' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | die 'TypeError: Not a cdt:List' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | foreach my $n (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | next unless (defined($n)); # null list elements cannot be tested for with CONTAINS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $equals = eval { $n->equals($term) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # warn $@ if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | return Attean::Literal->true if ($equals); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return Attean::Literal->false; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | =item C<< listContainsTerm($list, $term) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub listContainsTerm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listContainsTerm: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $term = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | foreach my $n (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | next unless (defined($n)); # null list elements cannot be tested for with CONTAINSTERM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if ($n->compare($term)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | if ($n->does('Attean::API::Binding')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | return Attean::Literal->true if ($n->sameTerms($term)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return Attean::Literal->true if ($n->value eq $term->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return Attean::Literal->false; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | =item C<< ctSize($ct) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub ctSize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ctSize: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $ct = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $pos = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | die 'TypeError' unless ($ct->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $dt = $ct->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ($dt->value eq $LIST_TYPE_IRI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return listSize($model, $active_graph, $ct, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } elsif ($dt->value eq $AtteanX::Functions::CompositeMaps::MAP_TYPE_IRI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | return AtteanX::Functions::CompositeMaps::mapSize($model, $active_graph, $ct, $pos); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | die 'TypeError'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | =item C<< listSize($list) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | sub listSize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listSize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | die 'TypeError' unless ($l->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $dt = $l->datatype; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | die 'TypeError' unless ($dt->value eq $LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my @nodes = lex_to_list($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return Attean::Literal->integer(scalar(@nodes)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =item C<< sequence($start, $end) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub sequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequence: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $start = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $end = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if (scalar(@_) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $start = shift->numeric_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $end = shift->numeric_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $end = shift->numeric_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my @values = ($start .. $end); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return list_to_lex(map { Attean::Literal->integer($_) } @values); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | =item C<< zip($list, $list) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | sub zip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zip: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $lhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my $rhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my @lhs_nodes = lex_to_list($lhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @rhs_nodes = lex_to_list($rhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | die 'zip operands are not the same length' unless (scalar(@lhs_nodes) == scalar(@rhs_nodes)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my @elements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | while (scalar(@lhs_nodes)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my @list = (shift(@lhs_nodes), shift(@rhs_nodes)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $l = list_to_lex(@list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | push(@elements, $l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return list_to_lex(@elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | =item C<< listCreate_agg_start() >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | sub listCreate_agg_start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listCreate_agg_start: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | values => [] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | =item C<< listCreate_agg_process($thunk, $term) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub listCreate_agg_process { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listCreate_agg_process: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $thunk = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my ($term) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | push(@{ $thunk->{'values' }}, $term); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | =item C<< listCreate_agg_finalize($thunk) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub listCreate_agg_finalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listCreate_agg_finalize: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $thunk = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my @terms = @{ $thunk->{'values' }}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return list_to_lex(@terms); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | =item C<< list_from_head($head) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | sub list_from_head { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_from_head: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my $model = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $active_graph = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $head = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $list = $model->get_list($active_graph, $head); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return list_to_lex($list->elements); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | =item C<< rewrite_lexical( $literal, \%bnode_map, $parse_id ) >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # lexer-based rewrite that will preserve the lexical representation of the literal for everything but the blank nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | sub rewrite_lexical { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rewrite_lexical: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $term = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $bnode_map = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | my $parse_id = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my %bnode_map = %{ $bnode_map }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | my $rewrite_tokens = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | return $t unless (blessed($t)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if ($t->type == BNODE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $v = $t->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if (my $b = $bnode_map{$v}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | return $l->new_token(BNODE, $t->start_line, $t->start_column, $b->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $value = 'b' . sha1_hex($parse_id . $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | my $b = Attean::Blank->new(value => $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $bnode_map{$value} = $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return $l->new_token(BNODE, $t->start_line, $t->start_column, $b->value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | return $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $r = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my %seen_hathat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | my %seen_cdt_iri; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my %seen_cdt_list_iri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my %seen_cdt_map_iri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $lex = $term->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | open(my $fh, '<:encoding(UTF-8)', \$lex); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $lexer = AtteanX::Functions::CompositeLists::TurtleLexerWithNull->new(file => $fh, ignore_whitespace => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $p = AtteanX::Parser::Turtle->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my @rewritten_tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | while (my $t = $rewrite_tokens->($lexer, $lexer->get_token())) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | if (blessed($t)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if ($t->type == HATHAT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $seen_hathat{$i-1}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } elsif ($t->type == IRI) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ($t->value eq 'http://w3id.org/awslabs/neptune/SPARQL-CDTs/Map') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $seen_cdt_map_iri{$i-2}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $seen_cdt_iri{$i-2}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } elsif ($t->value eq 'http://w3id.org/awslabs/neptune/SPARQL-CDTs/List') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $seen_cdt_list_iri{$i-2}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $seen_cdt_iri{$i-2}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | push(@rewritten_tokens, $t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | my @rewritten; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $j = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $s = AtteanX::Serializer::SPARQL->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | foreach my $t (@rewritten_tokens) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | if (blessed($t) and $t->is_string and $seen_hathat{$j} and $seen_cdt_iri{$j}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
builtin::blessed($t) and $t->is_string and $seen_hathat{$j} and $seen_cdt_iri{$j}
builtin::blessed($t) and $t->is_string and $seen_hathat{$j}
builtin::blessed($t) and $t->is_string
MC/DC0%0/4
builtin::blessed($t) and $t->is_string and $seen_hathat{$j} and $seen_cdt_iri{$j}
builtin::blessed($t)
$t->is_string
$seen_hathat{$j}
$seen_cdt_iri{$j}
Truth table0%0/5
A and B and C and D
A= builtin::blessed($t)B= $t->is_stringC= $seen_hathat{$j}D= $seen_cdt_iri{$j}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | my $ct_type = $seen_cdt_list_iri{$j} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | ? 'http://w3id.org/awslabs/neptune/SPARQL-CDTs/List' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | : 'http://w3id.org/awslabs/neptune/SPARQL-CDTs/Map'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $literal = Attean::Literal->new(value => $t->value, datatype => $ct_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my $rewritten = AtteanX::Functions::CompositeLists::rewrite_lexical($literal, $bnode_map, $parse_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my ($t) = $rewritten->sparql_tokens->elements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $i = Attean::ListIterator->new( values => [$t], item_type => 'AtteanX::SPARQL::Token' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $str = decode_utf8($s->serialize_iter_to_bytes($i)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | chomp($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | push(@rewritten, $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | push(@rewritten, blessed($t) ? $t->token_as_string() : "null"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $j++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $rewritten = join('', @rewritten); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | Attean::Literal->new(value => $rewritten, datatype => $term->datatype); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | warn $@ if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | return $r || $term; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$r || $term
MC/DC0%0/2
$r || $term
$r
$term
Truth table0%0/3
A || B
A= $rB= $term
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | =item C<< register() >> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 23 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 23 | Attean->register_datatype_role( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | "${CDT_BASE}List" => 'AtteanX::Functions::CompositeLists::ListLiteral' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 23 | Attean->register_global_functional_form( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | "${CDT_BASE}List" => \&listCreate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | "${CDT_BASE}listCreate" => \&listCreate, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 23 | Attean->register_global_function( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | "${CDT_BASE}get" => \&ctGet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | "${CDT_BASE}listGet" => \&listGet, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | "${CDT_BASE}subseq" => \&listSubseq, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | "${CDT_BASE}size" => \&ctSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | "${CDT_BASE}listSize" => \&listSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | "${CDT_BASE}reverse" => \&listReverse, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | "${CDT_BASE}head" => \&listHead, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | "${CDT_BASE}tail" => \&listTail, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | "${CDT_BASE}contains" => \&listContains, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | "${CDT_BASE}concat" => \&listConcat, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | "${CDT_BASE}containsTerm" => \&listContainsTerm, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | "${CDT_BASE}sequence" => \&sequence, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | "${CDT_BASE}zip" => \&zip, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | "${CDT_BASE}split" => \&stringSplit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | "${CDT_BASE}list_from_head" => \&list_from_head, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 23 | Attean->register_global_aggregate( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | "${CDT_BASE}listAgg" => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | start => \&listCreate_agg_start, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | process => \&listCreate_agg_process, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | finalize => \&listCreate_agg_finalize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 50 | package AtteanX::Functions::CompositeLists::ListLiteral { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 50 | ▶ | use Scalar::Util qw(blessed looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 50 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 50 | ▶ | use List::Util qw(min); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | sub equals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equals: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $lhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my $rhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # warn "LIST EQUALS?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # warn "- " . $lhs->as_string . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # warn "- " . $rhs->as_string . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | return 0 unless ($rhs->does('Attean::API::Literal') and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rhs->does("Attean::API::Literal") and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
MC/DC0%0/2
$rhs->does("Attean::API::Literal") and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
$rhs->does("Attean::API::Literal")
$rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
Truth table0%0/3
A and B
A= $rhs->does("Attean::API::Literal")B= $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $lhs_size = eval { AtteanX::Functions::CompositeLists::listSize(undef, undef, $lhs)->value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | return 0 if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $rhs_size = eval { AtteanX::Functions::CompositeLists::listSize(undef, undef, $rhs)->value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | return 0 if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return 0 unless ($lhs_size == $rhs_size); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | my $seen_error = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | foreach my $i (0 .. $lhs_size-1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $li = AtteanX::Functions::CompositeLists::listGet(undef, undef, $lhs, Attean::Literal->integer($i+1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $ri = AtteanX::Functions::CompositeLists::listGet(undef, undef, $rhs, Attean::Literal->integer($i+1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | if (not blessed($li) and not blessed($ri)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
builtin::blessed($li) || builtin::blessed($ri)
MC/DC0%0/2
builtin::blessed($li) || builtin::blessed($ri)
builtin::blessed($li)
builtin::blessed($ri)
Truth table0%0/3
A || B
A= builtin::blessed($li)B= builtin::blessed($ri)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # both null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | ▶ | } elsif (not blessed($li) or not blessed($ri)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::blessed($li) && builtin::blessed($ri)
MC/DC0%0/2
builtin::blessed($li) && builtin::blessed($ri)
builtin::blessed($li)
builtin::blessed($ri)
Truth table0%0/3
A && B
A= builtin::blessed($li)B= builtin::blessed($ri)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | if ($li->does('Attean::API::Blank') and $ri->does('Attean::API::Blank')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$li->does("Attean::API::Blank") and $ri->does("Attean::API::Blank")
MC/DC0%0/2
$li->does("Attean::API::Blank") and $ri->does("Attean::API::Blank")
$li->does("Attean::API::Blank")
$ri->does("Attean::API::Blank")
Truth table0%0/3
A and B
A= $li->does("Attean::API::Blank")B= $ri->does("Attean::API::Blank")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | if ($li->value eq $ri->value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $seen_error++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | return 0 unless ($li->equals($ri)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ($seen_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | die 'TypeError: Cannot compare cdt:List values with blank nodes'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | sub order { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | return _compare('order', $self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | sub compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | return _compare('compare', $self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | sub _compare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $cmp_method = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | my $lhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $rhs = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # warn "LIST-LESS-THAN?"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # warn "- " . $lhs->as_string . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # warn "- " . $rhs->as_string . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | die 'TypeError' unless (blessed($rhs) and $rhs->does('Attean::API::Literal') and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($rhs) and $rhs->does("Attean::API::Literal") and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
builtin::blessed($rhs) and $rhs->does("Attean::API::Literal")
MC/DC0%0/3
builtin::blessed($rhs) and $rhs->does("Attean::API::Literal") and $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
builtin::blessed($rhs)
$rhs->does("Attean::API::Literal")
$rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
Truth table0%0/4
A and B and C
A= builtin::blessed($rhs)B= $rhs->does("Attean::API::Literal")C= $rhs->datatype->value eq $AtteanX::Functions::CompositeLists::LIST_TYPE_IRI
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my @lhs = AtteanX::Functions::CompositeLists::lex_to_list($lhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | my @rhs = AtteanX::Functions::CompositeLists::lex_to_list($rhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my $lhs_size = scalar(@lhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $rhs_size = scalar(@rhs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $seen_error = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $length = min($lhs_size, $rhs_size); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | foreach my $i (0 .. $length-1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $li = AtteanX::Functions::CompositeLists::listGet(undef, undef, $lhs, Attean::Literal->integer($i+1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $ri = AtteanX::Functions::CompositeLists::listGet(undef, undef, $rhs, Attean::Literal->integer($i+1)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | if (not blessed($li) and not blessed($ri)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
builtin::blessed($li) || builtin::blessed($ri)
MC/DC0%0/2
builtin::blessed($li) || builtin::blessed($ri)
builtin::blessed($li)
builtin::blessed($ri)
Truth table0%0/3
A || B
A= builtin::blessed($li)B= builtin::blessed($ri)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # both null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | } elsif (not blessed($li)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | if ($cmp_method eq 'order') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | die 'TypeError'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | $seen_error++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } elsif (not blessed($ri)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | if ($cmp_method eq 'order') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | die 'TypeError'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $seen_error++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | if ($li->does('Attean::API::Blank') and $ri->does('Attean::API::Blank')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$li->does("Attean::API::Blank") and $ri->does("Attean::API::Blank")
MC/DC0%0/2
$li->does("Attean::API::Blank") and $ri->does("Attean::API::Blank")
$li->does("Attean::API::Blank")
$ri->does("Attean::API::Blank")
Truth table0%0/3
A and B
A= $li->does("Attean::API::Blank")B= $ri->does("Attean::API::Blank")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | die 'TypeError'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $seen_error++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $icmp = $li->$cmp_method($ri); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | next if ($icmp == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | return $icmp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | if ($seen_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | die 'TypeError'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | if ($lhs_size == $rhs_size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | return ($lhs_size > $rhs_size) ? 1 : -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | sub canonicalized_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalized_term: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | return $self->canonicalized_term_strict(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | sub canonicalized_term_strict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonicalized_term_strict: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my @values = AtteanX::Functions::CompositeLists::lex_to_list($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | return AtteanX::Functions::CompositeLists::list_to_lex(@values); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 50 | with 'Attean::API::Literal'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 50 | with 'Attean::API::CanonicalizingLiteral'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||