This file is indexed.

/usr/share/perl5/Attean/API/Expression.pm is in libattean-perl 0.017-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
use v5.14;
use warnings;

=head1 NAME

Attean::API::Expression - SPARQL expressions

=head1 VERSION

This document describes Attean::API::Expression version 0.017

=head1 DESCRIPTION

The Attean::API::Expression role defines a common API for SPARQL expressions
consisting of logical, numeric, and function operators, constant terms, and
variables. Expressions may be evaluated in the context of a
L<Attean::API::Result> object, and either return a L<Attean::API::Term> object
or throw a type error exception.

=head1 ROLES

This role consumes the L<Attean::API::DirectedAcyclicGraph> role which provide the following methods:

=over 4

=item C<< is_leaf >>

=item C<< walk( prefix => \&pre_cb, postfix => \&pre_cb ) >>

=item C<< cover( prefix => \&pre_cb, postfix => \&pre_cb ) >>

=back

and the following attributes:

=over 4

=item C<< children >>

=back

=head1 ATTRIBUTES

The following attributes exist:

=over 4

=item C<< operator >>

A string indicating the expression operator (e.g. C<'+'> or C<'||'>).

=back

=head1 REQUIRED METHODS

The following methods are required by the L<Attean::API::Expression> role:

=over 4

=item C<< as_string >>

Returns a string serialization of the expression object.

=back

=cut

package Attean::API::Expression 0.017 {
	use Moo::Role;
	use Types::Standard qw(Str);
	use namespace::clean;

	with 'Attean::API::DirectedAcyclicGraph', 'Attean::API::UnionScopeVariables';
	
	has 'operator' => (is => 'ro', isa => Str, required => 1);
	requires 'is_stable'; # is stable for sorting (won't change across evaluations)
	requires 'unaggregated_variables';
	requires 'as_string';
	requires 'as_sparql';
	
	sub BUILD {}
	if ($ENV{ATTEAN_TYPECHECK}) {
		around 'BUILD' => sub {
			my $orig	= shift;
			my $self	= shift;
			$self->$orig(@_);
			my $name	= ref($self);
			$name		=~ s/^.*://;
			if ($self->can('arity')) {
				my $arity		= $self->arity;
				if (defined($arity)) {
					my $children	= $self->children;
					my $size		= scalar(@$children);
					unless ($size == $arity) {
						die "${name} expression construction with bad number of children (expected $arity, but got $size)";
					}
				}
			}
		}
	}
}

package Attean::API::UnaryExpression 0.017 {
	use Moo::Role;
	use AtteanX::SPARQL::Constants;
	use AtteanX::SPARQL::Token;
	use namespace::clean;
	
	with 'Attean::API::Expression', 'Attean::API::UnaryQueryTree';
	with 'Attean::API::SPARQLSerializable';
	
	sub as_string {
		my $self	= shift;
		my ($data)	= @{ $self->children };
		return sprintf("%s(%s)", $self->operator, $data->as_string);
	}

	my %ops	= (
		'!'	=> AtteanX::SPARQL::Token->fast_constructor( BANG, -1, -1, -1, -1, ['!'] ),
		'-'	=> AtteanX::SPARQL::Token->fast_constructor( MINUS, -1, -1, -1, -1, ['-'] ),
		'+'	=> AtteanX::SPARQL::Token->fast_constructor( PLUS, -1, -1, -1, -1, ['+'] ),
	);

	sub unaggregated_variables {
		my $self	= shift;
		my ($child)	= @{ $self->children };
		return $child->unaggregated_variables;
	}
	
	sub sparql_tokens {
		my $self	= shift;
		my $op		= $ops{$self->operator} // die "No operator found in Attean::API::UnaryExpression->sparql_tokens";

		my @tokens;
		push(@tokens, $op);
		foreach my $t (@{ $self->children }) {
			push(@tokens, $t->sparql_tokens->elements);
		}
		return Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::SPARQL::Token' );
	}
}

package Attean::API::BinaryExpression 0.017 {
	use Moo::Role;
	use AtteanX::SPARQL::Constants;
	use AtteanX::SPARQL::Token;
	use namespace::clean;
	
	with 'Attean::API::Expression', 'Attean::API::BinaryQueryTree';
	with 'Attean::API::SPARQLSerializable';

	sub as_string {
		my $self	= shift;
		my ($lhs, $rhs)	= @{ $self->children };
		return sprintf("(%s %s %s)", $lhs->as_string, $self->operator, $rhs->as_string);
	}

	sub unaggregated_variables {
		my $self	= shift;
		return map { $_->unaggregated_variables } @{ $self->children };
	}
	
	my %ops	= (
		'-'		=> AtteanX::SPARQL::Token->fast_constructor( MINUS, -1, -1, -1, -1, ['-'] ),
		'+'		=> AtteanX::SPARQL::Token->fast_constructor( PLUS, -1, -1, -1, -1, ['+'] ),
		'*'		=> AtteanX::SPARQL::Token->fast_constructor( STAR, -1, -1, -1, -1, ['*'] ),
		'/'		=> AtteanX::SPARQL::Token->fast_constructor( SLASH, -1, -1, -1, -1, ['/'] ),
		'<'		=> AtteanX::SPARQL::Token->fast_constructor( LT, -1, -1, -1, -1, ['<'] ),
		'>'		=> AtteanX::SPARQL::Token->fast_constructor( GT, -1, -1, -1, -1, ['>'] ),
		'<='	=> AtteanX::SPARQL::Token->fast_constructor( LE, -1, -1, -1, -1, ['<='] ),
		'>='	=> AtteanX::SPARQL::Token->fast_constructor( GE, -1, -1, -1, -1, ['>='] ),
		'!='	=> AtteanX::SPARQL::Token->fast_constructor( NOTEQUALS, -1, -1, -1, -1, ['!='] ),
		'='		=> AtteanX::SPARQL::Token->fast_constructor( EQUALS, -1, -1, -1, -1, ['='] ),
		'&&'	=> AtteanX::SPARQL::Token->fast_constructor( ANDAND, -1, -1, -1, -1, ['&&'] ),
		'||'	=> AtteanX::SPARQL::Token->fast_constructor( OROR, -1, -1, -1, -1, ['||'] ),
	);
	
	sub sparql_tokens {
		my $self	= shift;
		my $op		= $ops{$self->operator} // die "No operator found in Attean::API::BinaryExpression->sparql_tokens";

		my @tokens;
		foreach my $t (@{ $self->children }) {
			push(@tokens, $t->sparql_tokens->elements);
			push(@tokens, $op);
		}
		pop(@tokens);
		return Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::SPARQL::Token' );
	}
}

package Attean::API::NaryExpression 0.017 {
	use Moo::Role;
	with 'Attean::API::Expression', 'Attean::API::QueryTree';
	sub as_string {
		my $self	= shift;
		my @children	= map { $_->as_string } @{ $self->children };
		return sprintf("%s(%s)", $self->operator, join(', ', @children));
	}

	sub as_sparql {
		my $self	= shift;
		return $self->as_string;
	}

	sub unaggregated_variables {
		my $self	= shift;
		return map { $_->unaggregated_variables } @{ $self->children };
	}
}

package Attean::API::AggregateExpression 0.017 {
	use Moo::Role;
	requires 'operator';
	requires 'scalar_vars';
	with 'Attean::API::Expression', 'Attean::API::DirectedAcyclicGraph';

	sub as_string {
		my $self	= shift;
		my @children	= map { $_->as_string } @{ $self->children };
		return sprintf("%s(%s)", $self->operator, join(', ', @children));
	}

	sub as_sparql {
		my $self	= shift;
		return $self->as_string;
	}

	sub unaggregated_variables {
		return;
	}
}

1;

__END__

=head1 BUGS

Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/attean/issues>.

=head1 SEE ALSO

L<http://www.perlrdf.org/>

=head1 AUTHOR

Gregory Todd Williams  C<< <gwilliams@cpan.org> >>

=head1 COPYRIGHT

Copyright (c) 2014--2016 Gregory Todd Williams.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=cut