line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
50
|
|
|
50
|
|
563
|
use v5.14; |
|
50
|
|
|
|
|
186
|
|
2
|
50
|
|
|
50
|
|
218
|
use warnings; |
|
50
|
|
|
|
|
99
|
|
|
50
|
|
|
|
|
2114
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
AtteanX::SPARQL::Token - Token objects used for parsing and serializing SPARQL |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes AtteanX::SPARQL::Token version 0.032 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use v5.14; |
15
|
|
|
|
|
|
|
use Attean; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The AtteanX::SPARQL::Token class represents tokens produced and used |
20
|
|
|
|
|
|
|
during parsing and serializing of SPARQL. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item C<< type >> |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
An integer indicating the token type, defined in L<AtteanX::Parser::Turtle::Constants> |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item C<< start_line >> |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The line number in the source text that this token begins on. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item C<< start_column >> |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The column number in the source text that this token begins on. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item C<< line >> |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
The line number in the source text that this token ends on. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item C<< column >> |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The column number in the source text that this token ends on. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item C<< args >> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
An array of values associated with the token (e.g. the integer value of an INT token). |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=over 4 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
use Moo; |
60
|
50
|
|
|
50
|
|
21571
|
use Types::Standard qw(ArrayRef Str); |
|
50
|
|
|
|
|
108747
|
|
|
50
|
|
|
|
|
246
|
|
61
|
50
|
|
|
50
|
|
86401
|
use List::MoreUtils qw(zip); |
|
50
|
|
|
|
|
3106029
|
|
|
50
|
|
|
|
|
479
|
|
62
|
50
|
|
|
50
|
|
68014
|
use Sub::Util qw(set_subname); |
|
50
|
|
|
|
|
411944
|
|
|
50
|
|
|
|
|
394
|
|
63
|
50
|
|
|
50
|
|
46067
|
use AtteanX::SPARQL::Constants; |
|
50
|
|
|
|
|
97
|
|
|
50
|
|
|
|
|
2232
|
|
64
|
50
|
|
|
50
|
|
275
|
use namespace::clean; |
|
50
|
|
|
|
|
91
|
|
|
50
|
|
|
|
|
6784
|
|
65
|
50
|
|
|
50
|
|
21286
|
|
|
50
|
|
|
|
|
409826
|
|
|
50
|
|
|
|
|
306
|
|
66
|
|
|
|
|
|
|
has type => ( is => 'ro', ); |
67
|
|
|
|
|
|
|
has start_line => ( is => 'ro', ); |
68
|
|
|
|
|
|
|
has start_column => ( is => 'ro', ); |
69
|
|
|
|
|
|
|
has line => ( is => 'ro', ); |
70
|
|
|
|
|
|
|
has column => ( is => 'ro', ); |
71
|
|
|
|
|
|
|
has args => ( is => 'ro', isa => ArrayRef[Str]); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
extends 'AtteanX::Parser::Turtle::Token'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item C<< value >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Returns the token value. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
my $args = $self->args; |
83
|
1636
|
|
|
1636
|
1
|
2238
|
return $args->[0]; |
84
|
1636
|
|
|
|
|
2808
|
} |
85
|
1636
|
|
|
|
|
8528
|
|
86
|
|
|
|
|
|
|
=item C<< fast_constructor ( $type, $start_line, $start_col, $line, $col, \@args ) >> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns a new token object. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my @KEYS = qw(type start_line start_column line column args); |
93
|
|
|
|
|
|
|
my $class = shift; |
94
|
|
|
|
|
|
|
return $class->new( |
95
|
|
|
|
|
|
|
zip @KEYS, @_ |
96
|
2696
|
|
|
2696
|
1
|
125753
|
); |
97
|
2696
|
|
|
|
|
51065
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
{ |
100
|
|
|
|
|
|
|
my %tokens = ( |
101
|
|
|
|
|
|
|
a => [A, 'a'], |
102
|
|
|
|
|
|
|
prefix => [PREFIX, '@prefix'], |
103
|
|
|
|
|
|
|
base => [BASE, '@base'], |
104
|
|
|
|
|
|
|
lparen => [LPAREN, '('], |
105
|
|
|
|
|
|
|
rparen => [RPAREN, ')'], |
106
|
|
|
|
|
|
|
lbracket => [LBRACKET, '['], |
107
|
|
|
|
|
|
|
rbracket => [RBRACKET, ']'], |
108
|
|
|
|
|
|
|
dot => [DOT, '.'], |
109
|
|
|
|
|
|
|
comma => [COMMA, ','], |
110
|
|
|
|
|
|
|
semicolon => [SEMICOLON, ';'], |
111
|
|
|
|
|
|
|
hathat => [HATHAT, '^^'], |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
lbrace => [LBRACE, '{'], |
114
|
|
|
|
|
|
|
rbrace => [RBRACE, '}'], |
115
|
|
|
|
|
|
|
op_andand => [ANDAND, '&&'], |
116
|
|
|
|
|
|
|
anon => [ANON, '[]'], |
117
|
|
|
|
|
|
|
op_bang => [BANG, '!'], |
118
|
|
|
|
|
|
|
op_ge => [GE, '>='], |
119
|
|
|
|
|
|
|
op_gt => [GT, '>'], |
120
|
|
|
|
|
|
|
path_hat => [HAT, '^'], |
121
|
|
|
|
|
|
|
op_le => [LE, '<='], |
122
|
|
|
|
|
|
|
op_lt => [LT, '<'], |
123
|
|
|
|
|
|
|
minus => [MINUS, '-'], |
124
|
|
|
|
|
|
|
nil => [NIL, '()'], |
125
|
|
|
|
|
|
|
op_ne => [NOTEQUALS, '!='], |
126
|
|
|
|
|
|
|
path_or => [OR, '|'], |
127
|
|
|
|
|
|
|
op_oror => [OROR, '||'], |
128
|
|
|
|
|
|
|
op_plus => [PLUS, '+'], |
129
|
|
|
|
|
|
|
question => [QUESTION, '?'], |
130
|
|
|
|
|
|
|
slash => [SLASH, '/'], |
131
|
|
|
|
|
|
|
star => [STAR, '*'], |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
ltlt => [LTLT, '<<'], |
134
|
|
|
|
|
|
|
gtgt => [GTGT, '>>'], |
135
|
|
|
|
|
|
|
lannot => [LANNOT, '{|'], |
136
|
|
|
|
|
|
|
rannot => [RANNOT, '|}'], |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
for my $name (keys %tokens) { |
140
|
|
|
|
|
|
|
my ($type, $value) = @{ $tokens{ $name } }; |
141
|
|
|
|
|
|
|
my $code = sub { |
142
|
|
|
|
|
|
|
my $class = shift; |
143
|
|
|
|
|
|
|
return $class->fast_constructor($type, -1, -1, -1, -1, [$value]); |
144
|
|
|
|
|
|
|
}; |
145
|
434
|
|
|
434
|
|
827
|
Sub::Install::install_sub({ |
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
434
|
|
|
|
146
|
434
|
|
|
|
|
1561
|
code => set_subname($name, $code), |
147
|
|
|
|
|
|
|
as => $name |
148
|
|
|
|
|
|
|
}); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item C<< keyword( $kw ) >> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns a new L<AtteanX::SPARQL::Token> object with the C<KEYWORD> type and |
155
|
|
|
|
|
|
|
C<$kw> value. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $class = shift; |
160
|
|
|
|
|
|
|
my $kw = shift; |
161
|
|
|
|
|
|
|
return $class->fast_constructor(KEYWORD, -1, -1, -1, -1, [uc($kw)]); |
162
|
|
|
|
|
|
|
} |
163
|
224
|
|
|
224
|
1
|
363
|
|
164
|
224
|
|
|
|
|
362
|
=item C<< integer( $value ) >> |
165
|
224
|
|
|
|
|
888
|
|
166
|
|
|
|
|
|
|
Returns a new L<AtteanX::SPARQL::Token> object with the C<INTEGER> type and |
167
|
|
|
|
|
|
|
the given C<$value>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $class = shift; |
172
|
|
|
|
|
|
|
my $value = shift; |
173
|
|
|
|
|
|
|
return $class->fast_constructor(INTEGER, -1, -1, -1, -1, [+$value] ); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
10
|
|
|
10
|
1
|
15
|
=item C<< as_string >> |
177
|
10
|
|
|
|
|
12
|
|
178
|
10
|
|
|
|
|
26
|
Returns a string description of the token including the token type and any |
179
|
|
|
|
|
|
|
associated values. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $self = shift; |
184
|
|
|
|
|
|
|
my $type = decrypt_constant($self->type); |
185
|
|
|
|
|
|
|
my @args = @{ $self->args }; |
186
|
|
|
|
|
|
|
if (scalar(@args)) { |
187
|
|
|
|
|
|
|
return "$type(" . join(', ', @args) . ")"; |
188
|
|
|
|
|
|
|
} else { |
189
|
1
|
|
|
1
|
1
|
75
|
return $type; |
190
|
1
|
|
|
|
|
6
|
} |
191
|
1
|
|
|
|
|
1
|
} |
|
1
|
|
|
|
|
5
|
|
192
|
1
|
50
|
|
|
|
2
|
|
193
|
1
|
|
|
|
|
7
|
__PACKAGE__->meta->make_immutable; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
1; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 BUGS |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
202
|
|
|
|
|
|
|
at L<https://github.com/kasei/attean/issues>. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 SEE ALSO |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. |
215
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
216
|
|
|
|
|
|
|
the same terms as Perl itself. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |