Attean
view release on metacpan or search on metacpan
lib/AtteanX/SPARQL/Token.pm view on Meta::CPAN
=head1 SYNOPSIS
use v5.14;
use Attean;
=head1 DESCRIPTION
The AtteanX::SPARQL::Token class represents tokens produced and used
during parsing and serializing of SPARQL.
=head1 ATTRIBUTES
=over 4
=item C<< type >>
An integer indicating the token type, defined in L<AtteanX::Parser::Turtle::Constants>
=item C<< start_line >>
The line number in the source text that this token begins on.
=item C<< start_column >>
The column number in the source text that this token begins on.
=item C<< line >>
The line number in the source text that this token ends on.
=item C<< column >>
The column number in the source text that this token ends on.
=item C<< args >>
An array of values associated with the token (e.g. the integer value of an INT token).
=back
=head1 METHODS
=over 4
=cut
package AtteanX::SPARQL::Token 0.038;
use Moo;
use Types::Standard qw(ArrayRef Str);
use List::Util qw(mesh);
use Sub::Util qw(set_subname);
use AtteanX::SPARQL::Constants;
use namespace::clean;
has type => ( is => 'ro', );
has start_line => ( is => 'ro', );
has start_column => ( is => 'ro', );
has line => ( is => 'ro', );
has column => ( is => 'ro', );
has args => ( is => 'ro', isa => ArrayRef[Str]);
extends 'AtteanX::Parser::Turtle::Token';
=item C<< value >>
Returns the token value.
=cut
sub value {
my $self = shift;
my $args = $self->args;
return $args->[0];
}
=item C<< fast_constructor ( $type, $start_line, $start_col, $line, $col, \@args ) >>
Returns a new token object.
=cut
my @KEYS = qw(type start_line start_column line column args);
sub fast_constructor {
my $class = shift;
return $class->new(
mesh \@KEYS, \@_
);
}
{
my %tokens = (
a => [A, 'a'],
prefix => [PREFIX, '@prefix'],
base => [BASE, '@base'],
lparen => [LPAREN, '('],
rparen => [RPAREN, ')'],
lbracket => [LBRACKET, '['],
rbracket => [RBRACKET, ']'],
dot => [DOT, '.'],
comma => [COMMA, ','],
semicolon => [SEMICOLON, ';'],
hathat => [HATHAT, '^^'],
lbrace => [LBRACE, '{'],
rbrace => [RBRACE, '}'],
op_andand => [ANDAND, '&&'],
anon => [ANON, '[]'],
op_bang => [BANG, '!'],
op_ge => [GE, '>='],
op_gt => [GT, '>'],
path_hat => [HAT, '^'],
op_le => [LE, '<='],
op_lt => [LT, '<'],
minus => [MINUS, '-'],
nil => [NIL, '()'],
op_ne => [NOTEQUALS, '!='],
path_or => [OR, '|'],
op_oror => [OROR, '||'],
op_plus => [PLUS, '+'],
question => [QUESTION, '?'],
( run in 0.650 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )