line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
50
|
|
|
50
|
|
22755
|
use v5.14; |
|
50
|
|
|
|
|
164
|
|
2
|
50
|
|
|
50
|
|
240
|
use warnings; |
|
50
|
|
|
|
|
89
|
|
|
50
|
|
|
|
|
1995
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
AtteanX::Parser::Turtle::Token - Token objects used for parsing of Turtle |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes AtteanX::Parser::Turtle::Token version 0.033 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use v5.14; |
15
|
|
|
|
|
|
|
use Attean; |
16
|
|
|
|
|
|
|
my $term = Attean::Blank->new('b1'); |
17
|
|
|
|
|
|
|
$term->ntriples_string; # _:b1 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
The AtteanX::Parser::Turtle::Token class represents tokens produced and used |
22
|
|
|
|
|
|
|
during parsing of Turtle. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item C<< type >> |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
An integer indicating the token type, defined in L<AtteanX::Parser::Turtle::Constants> |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item C<< start_line >> |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The line number in the source text that this token begins on. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item C<< start_column >> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The column number in the source text that this token begins on. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item C<< line >> |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The line number in the source text that this token ends on. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item C<< column >> |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The column number in the source text that this token ends on. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C<< args >> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
An array of values associated with the token (e.g. the integer value of an INT token). |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=over 4 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use Moo; |
62
|
50
|
|
|
50
|
|
271
|
use Types::Standard qw(ArrayRef Str); |
|
50
|
|
|
|
|
120
|
|
|
50
|
|
|
|
|
235
|
|
63
|
50
|
|
|
50
|
|
15213
|
use List::MoreUtils qw(zip); |
|
50
|
|
|
|
|
109
|
|
|
50
|
|
|
|
|
404
|
|
64
|
50
|
|
|
50
|
|
29539
|
use Sub::Util qw(set_subname); |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
309
|
|
65
|
50
|
|
|
50
|
|
43131
|
use AtteanX::Parser::Turtle::Constants; |
|
50
|
|
|
|
|
106
|
|
|
50
|
|
|
|
|
2188
|
|
66
|
50
|
|
|
50
|
|
270
|
use Sub::Install; |
|
50
|
|
|
|
|
96
|
|
|
50
|
|
|
|
|
4970
|
|
67
|
50
|
|
|
50
|
|
327
|
use namespace::clean; |
|
50
|
|
|
|
|
117
|
|
|
50
|
|
|
|
|
337
|
|
68
|
50
|
|
|
50
|
|
1849
|
|
|
50
|
|
|
|
|
98
|
|
|
50
|
|
|
|
|
324
|
|
69
|
|
|
|
|
|
|
our $VERSION = 0.033; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has type => ( is => 'ro', ); |
72
|
|
|
|
|
|
|
has start_line => ( is => 'ro', ); |
73
|
|
|
|
|
|
|
has start_column => ( is => 'ro', ); |
74
|
|
|
|
|
|
|
has line => ( is => 'ro', ); |
75
|
|
|
|
|
|
|
has column => ( is => 'ro', ); |
76
|
|
|
|
|
|
|
has args => ( is => 'ro', isa => ArrayRef[Str]); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C<< value >> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns the token value. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
my $args = $self->args; |
86
|
269
|
|
|
269
|
1
|
667
|
return $args->[0]; |
87
|
269
|
|
|
|
|
544
|
} |
88
|
269
|
|
|
|
|
1463
|
|
89
|
|
|
|
|
|
|
=item C<< fast_constructor ( $type, $start_line, $start_col, $line, $col, \@args ) >> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns a new token object. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my @KEYS = qw(type start_line start_column line column args); |
96
|
|
|
|
|
|
|
my $class = shift; |
97
|
|
|
|
|
|
|
return $class->new( |
98
|
|
|
|
|
|
|
zip @KEYS, @_ |
99
|
539
|
|
|
539
|
1
|
1166
|
); |
100
|
539
|
|
|
|
|
9687
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
{ |
103
|
|
|
|
|
|
|
my %tokens = ( |
104
|
|
|
|
|
|
|
a => [A, 'a'], |
105
|
|
|
|
|
|
|
prefix => [PREFIX, '@prefix'], |
106
|
|
|
|
|
|
|
base => [BASE, '@base'], |
107
|
|
|
|
|
|
|
lparen => [LPAREN, '('], |
108
|
|
|
|
|
|
|
rparen => [RPAREN, ')'], |
109
|
|
|
|
|
|
|
lbracket => [LBRACKET, '['], |
110
|
|
|
|
|
|
|
rbracket => [RBRACKET, ']'], |
111
|
|
|
|
|
|
|
dot => [DOT, '.'], |
112
|
|
|
|
|
|
|
comma => [COMMA, ','], |
113
|
|
|
|
|
|
|
semicolon => [SEMICOLON, ';'], |
114
|
|
|
|
|
|
|
hathat => [HATHAT, '^^'], |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
for my $name (keys %tokens) { |
117
|
|
|
|
|
|
|
my ($type, $value) = @{ $tokens{ $name } }; |
118
|
|
|
|
|
|
|
my $code = sub { |
119
|
|
|
|
|
|
|
my $class = shift; |
120
|
|
|
|
|
|
|
my $sl = shift // -1; |
121
|
|
|
|
|
|
|
my $sc = shift // -1; |
122
|
37
|
|
|
37
|
|
53
|
my $l = shift // $sl; |
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
37
|
|
|
|
123
|
37
|
|
50
|
|
|
95
|
my $c = shift // $sc; |
124
|
37
|
|
50
|
|
|
73
|
if ($sl > $l) { die '$start_line cannot be greater than $line in AtteanX::Parser::Turtle::Token constructor' } |
125
|
37
|
|
33
|
|
|
73
|
if ($sc > $c) { die '$start_line cannot be greater than $line in AtteanX::Parser::Turtle::Token constructor' } |
126
|
37
|
|
33
|
|
|
68
|
return $class->fast_constructor($type, $sl, $sc, $l, $c, [$value]); |
127
|
37
|
50
|
|
|
|
65
|
}; |
|
0
|
|
|
|
|
0
|
|
128
|
37
|
50
|
|
|
|
56
|
Sub::Install::install_sub({ |
|
0
|
|
|
|
|
0
|
|
129
|
37
|
|
|
|
|
87
|
code => set_subname($name, $code), |
130
|
|
|
|
|
|
|
as => $name |
131
|
|
|
|
|
|
|
}); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item C<< as_string >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns a string description of the token including the token type and any |
138
|
|
|
|
|
|
|
associated values. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
my $self = shift; |
143
|
|
|
|
|
|
|
my $type = decrypt_constant($self->type); |
144
|
|
|
|
|
|
|
my @args = @{ $self->args }; |
145
|
|
|
|
|
|
|
if (scalar(@args)) { |
146
|
0
|
|
|
0
|
1
|
|
return "$type(" . join(', ', @args) . ")"; |
147
|
0
|
|
|
|
|
|
} else { |
148
|
0
|
|
|
|
|
|
return $type; |
|
0
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
} |
150
|
0
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=back |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 BUGS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
161
|
|
|
|
|
|
|
at L<https://github.com/kasei/attean/issues>. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SEE ALSO |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. |
174
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
175
|
|
|
|
|
|
|
the same terms as Perl itself. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |