| 1 | 13 | ▶ | use v5.14; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | AtteanX::Parser::SPARQLLex - SPARQL Lexer | ||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | This document describes AtteanX::Parser::SPARQLLex version 0.040 | ||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | use Attean; | ||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | ... | ||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | =item C<< canonical_media_type >> | ||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | =item C<< media_types >> | ||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | =item C<< file_extensions >> | ||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | =item C<< handled_type >> | ||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | =item C<< extend >> | ||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | =back | ||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 13 | package AtteanX::Parser::SPARQLLex 0.040 { | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 13 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 13 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 13 | ▶ | use Attean; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 13 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 13 | ▶ | use Encode qw(decode); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | ▶ | use Types::Standard qw(ArrayRef Str); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub canonical_media_type { return "application/x-sparql-query-tokens" } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonical_media_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | # these pass through to the lexer iterator | ||||||||||||||||||||||||||||||||||||||||||||
| 54 | 118 | ▶ | has extend => ( is => 'ro', isa => ArrayRef, default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 13 | has 'version' => (is => 'rw', isa => Str, default => '1.2'); | |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | sub media_types { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
media_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | return [qw(application/x-sparql-query-tokens)]; | |||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | sub handled_type { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handled_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | state $ITEM_TYPE = Type::Tiny::Role->new(role => 'AtteanX::SPARQL::Token'); | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | return $ITEM_TYPE; | |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | =item C<< file_extensions >> | ||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | Returns a list of file extensions that may be parsed with the parser. | ||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | sub file_extensions { return [qw(rq)] } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_extensions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 13 | with 'Attean::API::PullParser', 'Attean::API::Parser'; | |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | =item C<< parse_iter_from_bytes( $data ) >> | ||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | Returns an iterator of SPARQL tokens that result from parsing | ||||||||||||||||||||||||||||||||||||||||||||
| 79 | the SPARQL query/update read from the UTF-8 encoded byte string C<< $data >>. | ||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 57 | ▶ | sub parse_iter_from_bytes { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_iter_from_bytes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 57 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 57 | my $data = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 57 | open(my $fh, '<:encoding(UTF-8)', \$data); | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 57 | return $self->parse_iter_from_io($fh); | |||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | =item C<< parse_iter_from_io( $fh ) >> | ||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | Returns an iterator of SPARQL tokens that result from parsing | ||||||||||||||||||||||||||||||||||||||||||||
| 93 | the SPARQL query/update read from the L<IO::Handle> object C<< $fh >>. | ||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | 67 | ▶ | sub parse_iter_from_io { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_iter_from_io: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||
| 98 | 67 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 67 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 67 | return AtteanX::Parser::SPARQLLex::Iterator->new( | |||||||||||||||||||||||||||||||||||||||||||
| 101 | extend => $self->extend, | ||||||||||||||||||||||||||||||||||||||||||||
| 102 | file => $fh, | ||||||||||||||||||||||||||||||||||||||||||||
| 103 | version => $self->version, | ||||||||||||||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 13 | package AtteanX::Parser::SPARQLLex::Iterator 0.040 { | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 13 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 13 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 13 | ▶ | use Attean; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 13 | ▶ | use Encode; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 113 | 13 | ▶ | use Encode qw(decode); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 13 | ▶ | use AtteanX::SPARQL::Token; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 13 | ▶ | use AtteanX::SPARQL::Constants; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 13 | ▶ | use Types::Standard qw(FileHandle Ref Str Int ArrayRef HashRef ConsumerOf InstanceOf); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 13 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 67 | ▶ | has lookahead_methods => ( is => 'ro', isa => HashRef, default => sub { +{} } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 67 | ▶ | has lookahead_tokens => ( is => 'ro', isa => HashRef, default => sub { +{} } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | has extend => ( is => 'ro', isa => ArrayRef, default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 67 | ▶ | has token_buffer => ( is => 'ro', isa => ArrayRef, default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 13 | has 'version' => (is => 'rw', isa => Str, default => '1.2'); | |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 13 | with 'AtteanX::API::Lexer'; | |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | 13 | my $r_ECHAR = qr/\\([tbnrf\\"'])/o; | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 13 | my $r_STRING_LITERAL1 = qr/'(([^\x{27}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*'/o; | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 13 | my $r_STRING_LITERAL2 = qr/"(([^\x{22}\x{5C}\x{0A}\x{0D}])|${r_ECHAR})*"/o; | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 13 | my $r_STRING_LITERAL_LONG1 = qr/'''(('|'')?([^'\\]|${r_ECHAR}))*'''/o; | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 13 | my $r_STRING_LITERAL_LONG2 = qr/"""(("|"")?([^"\\]|${r_ECHAR}))*"""/o; | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 13 | my $r_LANGTAG = qr/@[a-zA-Z]+(-[a-zA-Z0-9]+)*/o; | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 13 | my $r_LANGTAG_12 = qr/@[a-zA-Z]+(-[a-zA-Z0-9]+)*(--[a-zA-Z]+)?/o; | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 13 | my $r_IRI_REF = qr/<([^<>"{}|^`\\\x{00}-\x{20}])*>/o; | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 13 | my $r_PN_CHARS_BASE = qr/([A-Z]|[a-z]|[\x{00C0}-\x{00D6}]|[\x{00D8}-\x{00F6}]|[\x{00F8}-\x{02FF}]|[\x{0370}-\x{037D}]|[\x{037F}-\x{1FFF}]|[\x{200C}-\x{200D}]|[\x{2070}-\x{218F}]|[\x{2C00}-\x{2FEF}]|[\x{3001}-\x{D7FF}]|[\x{F900}-\x{FDCF}]|[\x{FDF0}-\x{FFFD}]|[\x{10000}-\x{EFFFF}])/o; | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 13 | my $r_PN_CHARS_U = qr/([_]|${r_PN_CHARS_BASE})/o; | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 13 | my $r_VARNAME = qr/((${r_PN_CHARS_U}|[0-9])(${r_PN_CHARS_U}|[0-9]|\x{00B7}|[\x{0300}-\x{036F}]|[\x{203F}-\x{2040}])*)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 13 | my $r_VAR1 = qr/[?]${r_VARNAME}/o; | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 13 | my $r_VAR2 = qr/[\$]${r_VARNAME}/o; | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 13 | my $r_PN_CHARS = qr/${r_PN_CHARS_U}|-|[0-9]|\x{00B7}|[\x{0300}-\x{036F}]|[\x{203F}-\x{2040}]/o; | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | my $r_PN_PREFIX = qr/(${r_PN_CHARS_BASE}((${r_PN_CHARS}|[.])*${r_PN_CHARS})?)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 13 | my $r_PN_LOCAL_ESCAPED = qr{(\\([-~.!&'()*+,;=/?#@%_\$]))|%[0-9A-Fa-f]{2}}o; | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 13 | my $r_PN_LOCAL = qr/((${r_PN_CHARS_U}|[:0-9]|${r_PN_LOCAL_ESCAPED})((${r_PN_CHARS}|${r_PN_LOCAL_ESCAPED}|[:.])*(${r_PN_CHARS}|[:]|${r_PN_LOCAL_ESCAPED}))?)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 13 | my $r_PN_LOCAL_BNODE = qr/((${r_PN_CHARS_U}|[0-9])((${r_PN_CHARS}|[.])*${r_PN_CHARS})?)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 13 | my $r_PNAME_NS = qr/((${r_PN_PREFIX})?:)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 13 | my $r_PNAME_LN = qr/(${r_PNAME_NS}${r_PN_LOCAL})/o; | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 13 | my $r_EXPONENT = qr/[eE][-+]?\d+/o; | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 13 | my $r_DOUBLE = qr/\d+[.]\d*${r_EXPONENT}|[.]\d+${r_EXPONENT}|\d+${r_EXPONENT}/o; | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 13 | my $r_DECIMAL = qr/(\d+[.]\d*)|([.]\d+)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 13 | my $r_INTEGER = qr/\d+/o; | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 13 | my $r_BLANK_NODE_LABEL = qr/_:${r_PN_LOCAL_BNODE}/o; | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | my $r_ANON = qr/\[[\t\r\n ]*\]/o; | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 13 | my $r_NIL = qr/\([\n\r\t ]*\)/o; | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 13 | my $r_KEYWORDS = qr/(ABS|ADD|ALL|ASC|ASK|AS|AVG|BASE|BIND|BNODE|BOUND|BY|CEIL|CLEAR|COALESCE|CONCAT|CONSTRUCT|CONTAINS|COPY|COUNT|CREATE|DATA|DATATYPE|DAY|DEFAULT|DELETE|DELETE WHERE|DESCRIBE|DESC|DISTINCT|DISTINCT|DROP|ENCODE_FOR_URI|EXISTS|FILTER|FLOOR|FOLD|FROM|GRAPH|GROUP_CONCAT|GROUP|HASLANG|HASLANGDIR|HAVING|HINT|HOURS|IF|IN|INSERT|INTO|IRI|ISBLANK|ISIRI|ISLITERAL|ISNUMERIC|ISURI|LANGDIR|LANGMATCHES|LANG|LCASE|LIMIT|LOAD|MAX|MD5|MINUS|MINUTES|MIN|MONTH|MOVE|NAMED|NOT|NOW|OFFSET|OPTIONAL|ORDER|PREFIX|RAND|REDUCED|REGEX|REPLACE|ROUND|SAMETERM|SAMPLE|SECONDS|SELECT|SEPARATOR|SERVICE|SHA1|SHA256|SHA384|SHA512|SILENT|STR|STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANG|STRLEN|STRSTARTS|STRUUID|SUBSTR|SUM|TIMEZONE|TO|TZ|UCASE|UNDEF|UNFOLD|UNION|URI|USING|UUID|VALUES|WHERE|WITH|YEAR)(?!:)\b/io; | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 13 | my $r_KEYWORDS_12 = qr/(VERSION|ABS|ADD|ALL|ASC|ASK|AS|AVG|BASE|BIND|BNODE|BOUND|BY|CEIL|CLEAR|COALESCE|CONCAT|CONSTRUCT|CONTAINS|COPY|COUNT|CREATE|DATA|DATATYPE|DAY|DEFAULT|DELETE|DELETE WHERE|DESCRIBE|DESC|DISTINCT|DISTINCT|DROP|ENCODE_FOR_URI|EXISTS|FILTER|FLOOR|FOLD|FROM|GRAPH|GROUP_CONCAT|GROUP|HASLANG|HASLANGDIR|HAVING|HINT|HOURS|IF|IN|INSERT|INTO|IRI|ISBLANK|ISIRI|ISLITERAL|ISNUMERIC|ISTRIPLE|ISURI|LANGDIR|LANGMATCHES|LANG|LCASE|LIMIT|LOAD|MAX|MD5|MINUS|MINUTES|MIN|MONTH|MOVE|NAMED|NOT|NOW|OBJECT|OFFSET|OPTIONAL|ORDER|PREDICATE|PREFIX|RAND|REDUCED|REGEX|REPLACE|ROUND|SAMETERM|SAMPLE|SECONDS|SELECT|SEPARATOR|SERVICE|SHA1|SHA256|SHA384|SHA512|SILENT|STR|STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANGDIR|STRLANG|STRLEN|STRSTARTS|STRUUID|SUBJECT|SUBSTR|SUM|TIMEZONE|TO|TRIPLE|TZ|UCASE|UNDEF|UNFOLD|UNION|URI|USING|UUID|VALUES|WHERE|WITH|YEAR)(?!:)\b/io; | |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 67 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=8 SCAR=21.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 67 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 159 | my %METHOD_TOKEN = ( | ||||||||||||||||||||||||||||||||||||||||||||
| 160 | # q[#] => '_get_comment', | ||||||||||||||||||||||||||||||||||||||||||||
| 161 | q[@] => '_get_lang', | ||||||||||||||||||||||||||||||||||||||||||||
| 162 | q[<] => '_get_iriref_or_relational', | ||||||||||||||||||||||||||||||||||||||||||||
| 163 | q[{] => '_get_brace_or_annotation_or_or', | ||||||||||||||||||||||||||||||||||||||||||||
| 164 | q[}] => '_get_brace_or_annotation_or_or', | ||||||||||||||||||||||||||||||||||||||||||||
| 165 | q[|] => '_get_brace_or_annotation_or_or', | ||||||||||||||||||||||||||||||||||||||||||||
| 166 | q[_] => '_get_bnode', | ||||||||||||||||||||||||||||||||||||||||||||
| 167 | q['] => '_get_single_literal', | ||||||||||||||||||||||||||||||||||||||||||||
| 168 | q["] => '_get_double_literal', | ||||||||||||||||||||||||||||||||||||||||||||
| 169 | q[:] => '_get_pname', | ||||||||||||||||||||||||||||||||||||||||||||
| 170 | q[?] => '_get_variable', | ||||||||||||||||||||||||||||||||||||||||||||
| 171 | q[$] => '_get_variable', | ||||||||||||||||||||||||||||||||||||||||||||
| 172 | q[!] => '_get_bang', | ||||||||||||||||||||||||||||||||||||||||||||
| 173 | q[>] => '_get_iriref_or_relational', | ||||||||||||||||||||||||||||||||||||||||||||
| 174 | q([) => '_get_lbracket_or_anon', | ||||||||||||||||||||||||||||||||||||||||||||
| 175 | q[(] => '_get_lparen_or_nil', | ||||||||||||||||||||||||||||||||||||||||||||
| 176 | q[)] => '_get_rparen_or_pgtgt', | ||||||||||||||||||||||||||||||||||||||||||||
| 177 | 67 | (map {$_ => '_get_number'} (0 .. 9, '-', '+')) | |||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 179 | 67 | ▶ | while (my ($k,$v) = each(%METHOD_TOKEN)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1876 | ▶ | if (length($k) != 1) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | die "Cannot set a lookahead token handler method with lookahead > 1 char"; | |||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1876 | ▶ | $self->lookahead_methods->{$k} //= $v; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->lookahead_methods->{$k} //= $v
MC/DC0%0/2
$self->lookahead_methods->{$k} //= $v
$self->lookahead_methods->{$k}
$v
Truth table33%1/3
A //= B
A= $self->lookahead_methods->{$k}B= $v
| |||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | 67 | my %CHAR_TOKEN = ( | |||||||||||||||||||||||||||||||||||||||||||
| 187 | ',' => COMMA, | ||||||||||||||||||||||||||||||||||||||||||||
| 188 | '.' => DOT, | ||||||||||||||||||||||||||||||||||||||||||||
| 189 | '=' => EQUALS, | ||||||||||||||||||||||||||||||||||||||||||||
| 190 | ']' => RBRACKET, | ||||||||||||||||||||||||||||||||||||||||||||
| 191 | '-' => MINUS, | ||||||||||||||||||||||||||||||||||||||||||||
| 192 | '+' => PLUS, | ||||||||||||||||||||||||||||||||||||||||||||
| 193 | ';' => SEMICOLON, | ||||||||||||||||||||||||||||||||||||||||||||
| 194 | '/' => SLASH, | ||||||||||||||||||||||||||||||||||||||||||||
| 195 | '*' => STAR, | ||||||||||||||||||||||||||||||||||||||||||||
| 196 | '~' => TILDE, | ||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 198 | 67 | ▶ | while (my ($k,$v) = each(%CHAR_TOKEN)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 670 | ▶ | if (length($k) != 1) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | die "Cannot set a lookahead token with lookahead > 1 char"; | |||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 202 | 670 | ▶ | $self->lookahead_tokens->{$k} //= $v; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->lookahead_tokens->{$k} //= $v
MC/DC0%0/2
$self->lookahead_tokens->{$k} //= $v
$self->lookahead_tokens->{$k}
$v
Truth table33%1/3
A //= B
A= $self->lookahead_tokens->{$k}B= $v
| |||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 67 | ▶ | if ($self->version ge '1.2') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 63 | ▶ | $self->add_regex_rule( $r_KEYWORDS_12, KEYWORD, sub { return uc(shift) } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 207 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | $self->add_regex_rule( $r_KEYWORDS, KEYWORD, sub { return uc(shift) } ); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 349 | ▶ | sub sparql12 { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sparql12: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 349 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 349 | return ($self->version ge '1.2'); | |||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 5848 | ▶ | sub peek { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5848 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 5848 | my $b = $self->token_buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5848 | my $t = $self->next; | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 5847 | ▶ | return unless ($t); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 5568 | push(@$b, $t); | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 5568 | return $t; | |||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | 6649 | ▶ | sub next { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 6649 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 6649 | my $b = $self->token_buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 6649 | ▶ | if (scalar(@$b)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 5567 | return shift(@$b); | |||||||||||||||||||||||||||||||||||||||||||
| 231 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 232 | 1082 | return $self->get_token(); | |||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 4 | ▶ | sub codepoint_unescape { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
codepoint_unescape: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 4 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 13 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 4 | $value =~ s{\\(?:(?:u([0-9A-Fa-f]{4}))|(?:U([0-9A-Fa-f]{8})))}{ | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | my $h = $1 . $2; | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | my $codepoint = hex($h); | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | ▶ | if ($codepoint >= 0xD800 and $codepoint <= 0xDFFF) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$codepoint >= 55296 and $codepoint <= 57343
MC/DC0%0/2
$codepoint >= 55296 and $codepoint <= 57343
$codepoint >= 55296
$codepoint <= 57343
Truth table33%1/3
A and B
A= $codepoint >= 55296B= $codepoint <= 57343
| |||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | die "Unicode surrogate U+$h is illegal in UTF-8"; | |||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | chr($codepoint); | |||||||||||||||||||||||||||||||||||||||||||
| 247 | }ge; | ||||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | return $value; | |||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | 662 | ▶ | sub fill_buffer { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill_buffer: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 252 | 662 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 662 | ▶ | unless (length($self->buffer)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 254 | 662 | AGAIN: | |||||||||||||||||||||||||||||||||||||||||||
| 255 | my $line = $self->file->getline; | ||||||||||||||||||||||||||||||||||||||||||||
| 256 | 662 | ▶ | if (defined($line)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 92 | ▶ | if ($self->version lt '1.2') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 258 | # codepoint escape handling has moved into the literal and IRI handling in SPARQL 1.2+ | ||||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | $line = $self->codepoint_unescape($line); | |||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 261 | 92 | $self->{buffer} .= $line; | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 92 | ▶ | if ($line =~ /[[(]\s*$/) { # might be a NIL or ANON that spans a line | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | goto AGAIN; | |||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 794 | ▶ | sub new_token { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_token: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 270 | 794 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 794 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 794 | my $start_line = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 794 | my $start_col = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 794 | my $line = $self->line; | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 794 | my $col = $self->column; | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 794 | return AtteanX::SPARQL::Token->fast_constructor( $type, $start_line, $start_col, $line, $col, \@_ ); | |||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | 120 | ▶ | sub add_regex_rule { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_regex_rule: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 120 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 120 | my $r = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 120 | my $ttype = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 120 | my $convert = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 120 | my $extend = $self->extend; | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 1357 | ▶ | push(@$extend, sub { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1357 | my $l = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1357 | ▶ | if ($l->buffer =~ /^$r\b/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 183 | my $value = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 183 | ▶ | my $c = $convert ? $convert->($value) : $value; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 183 | return $l->new_token($ttype, $l->start_line, $l->start_column, $c); | |||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 293 | 120 | }); | |||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1082 | ▶ | sub get_token { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_token: called CC=19 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1082 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 1082 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 1756 | ▶ | $self->fill_buffer unless (length($self->buffer)); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | 1756 | ▶ | if ($self->buffer =~ /^[ \r\n\t]+/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 674 | $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 303 | # we're ignoring whitespace tokens, but we could return them here instead of falling through to the 'next': | ||||||||||||||||||||||||||||||||||||||||||||
| 304 | # return $self->new_token(WS); | ||||||||||||||||||||||||||||||||||||||||||||
| 305 | 674 | next; | |||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1082 | my $c = $self->peek_char(); | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 1082 | ▶ | return unless (defined($c)); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | 797 | ▶ | if ($c eq '#') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 312 | # we're ignoring comment tokens, but we could return them here instead of falling through to the 'next': | ||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $self->_get_comment(); | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 797 | my $start_column = $self->column; | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 797 | my $start_line = $self->line; | |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 797 | $self->start_column( $start_column ); | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 797 | $self->start_line( $start_line ); | |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 797 | foreach my $e (@{ $self->extend }) { | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 1357 | ▶ | if (my $t = $e->( $self )) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 325 | 183 | return $t; | |||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||
| 329 | 614 | ▶ | if ($c eq '.' and $self->buffer =~ /^$r_DECIMAL/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$c eq "." and $self->buffer =~ /^$r_DECIMAL/u
MC/DC0%0/2
$c eq "." and $self->buffer =~ /^$r_DECIMAL/u
$c eq "."
$self->buffer =~ /^$r_DECIMAL/u
Truth table66%2/3
A and B
A= $c eq "."B= $self->buffer =~ /^$r_DECIMAL/u
| |||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return $self->_get_number(); | |||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | 614 | ▶ | if (defined(my $name = $self->lookahead_tokens->{$c})) { $self->get_char; return $self->new_token($name, $start_line, $start_column, $c); } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 334 | 486 | elsif (defined(my $method = $self->lookahead_methods->{$c})) { return $self->$method() } | |||||||||||||||||||||||||||||||||||||||||||
| 335 | elsif ($c =~ /[A-Za-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{02FF}\x{0370}-\x{037D}\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 336 | 61 | ▶ | if ($self->buffer =~ /^a(?!:)\s/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 337 | 13 | $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 13 | return $self->new_token(A, $start_line, $start_column, 'a'); | |||||||||||||||||||||||||||||||||||||||||||
| 339 | } elsif ($self->buffer =~ /^(?i:true|false)(?!:)\b/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | my $bool = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | return $self->new_token(BOOLEAN, $start_line, $start_column, lc($bool)); | |||||||||||||||||||||||||||||||||||||||||||
| 342 | # } elsif ($self->buffer =~ /^$r_KEYWORDS/) { | ||||||||||||||||||||||||||||||||||||||||||||
| 343 | # my $bool = $self->read_length($+[0]); | ||||||||||||||||||||||||||||||||||||||||||||
| 344 | # return $self->new_token(KEYWORD, $start_line, $start_column, $bool); | ||||||||||||||||||||||||||||||||||||||||||||
| 345 | } elsif ($self->buffer =~ /^BASE(?!:)\b/oi) { | ||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->read_length(4); | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | return $self->new_token(BASE, $start_line, $start_column, 'BASE'); | |||||||||||||||||||||||||||||||||||||||||||
| 348 | } elsif ($self->buffer =~ /^PREFIX(?!:)\b/io) { | ||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->read_length(6); | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return $self->new_token(PREFIX, $start_line, $start_column, 'PREFIX'); | |||||||||||||||||||||||||||||||||||||||||||
| 351 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 352 | 42 | return $self->_get_pname; | |||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 354 | } elsif ($c eq '^') { | ||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ($self->buffer =~ /^\^\^/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $self->read_word('^^'); | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return $self->new_token(HATHAT, $start_line, $start_column, '^^'); | |||||||||||||||||||||||||||||||||||||||||||
| 358 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $self->read_word('^'); | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | return $self->new_token(HAT, $start_line, $start_column, '^'); | |||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 362 | } elsif ($c eq '&') { | ||||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | $self->read_word('&&'); | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | return $self->new_token(ANDAND, $start_line, $start_column, '&&'); | |||||||||||||||||||||||||||||||||||||||||||
| 365 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 366 | # Carp::cluck sprintf("Unexpected byte '$c' (0x%02x)", ord($c)); | ||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return $self->_throw_error(sprintf("Unexpected byte '%s' (0x%02x)", $c, ord($c))); | |||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | warn sprintf('byte: 0x%x', ord($c)); | |||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 53 | ▶ | sub _get_pname { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_pname: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 53 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 53 | my $prefix = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 53 | ▶ | if ($self->buffer =~ /^$r_PNAME_LN/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 35 | my $ln = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 35 | my ($ns, $local) = ($ln =~ /^([^:]*:)(.*)$/); | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 13 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 381 | 35 | $local =~ s{\\([-~.!&'()*+,;=:/?#@%_\$])}{$1}g; | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 35 | return $self->new_token(PREFIXNAME, $self->start_line, $self->start_column, $ns, $local); | |||||||||||||||||||||||||||||||||||||||||||
| 383 | } elsif ($self->buffer =~ $r_PNAME_NS) { | ||||||||||||||||||||||||||||||||||||||||||||
| 384 | 16 | my $ns = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 16 | return $self->new_token(PREFIXNAME, $self->start_line, $self->start_column, $ns); | |||||||||||||||||||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 387 | 2 | $self->_throw_error("Expected PNAME"); | |||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||
| 391 | 144 | ▶ | sub _get_variable { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_variable: called CC=4 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 144 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 144 | ▶ | if (substr($self->buffer, 0, 1) eq '$') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $self->get_char_safe('$'); | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if ($self->buffer =~ /^$r_VARNAME/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $name = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | return $self->new_token(VAR, $self->start_line, $self->start_column, $name); | |||||||||||||||||||||||||||||||||||||||||||
| 398 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $self->_throw_error("Invalid variable name"); | |||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 401 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 402 | 144 | $self->get_char_safe('?'); | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 144 | ▶ | if ($self->buffer =~ /^$r_VARNAME/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 404 | 144 | my $name = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 144 | return $self->new_token(VAR, $self->start_line, $self->start_column, $name); | |||||||||||||||||||||||||||||||||||||||||||
| 406 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return $self->new_token(QUESTION, $self->start_line, $self->start_column, '?'); | |||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | 99 | ▶ | sub _get_iriref_or_relational { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_iriref_or_relational: called CC=24 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 99 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 99 | my $buffer = $self->buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 99 | ▶ | if ($buffer =~ m/^<([^<>"{}|^`\x00-\x20])*>/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 416 | 87 | $self->get_char_safe(q[<]); | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 87 | ▶ | if ($self->buffer =~ m/^[\x23-\x3d\x3f-\x5a\x5d-\x7e]*>/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 87 | my $iri .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 87 | chop($iri); | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 87 | return $self->new_token(IRI, $self->start_line, $self->start_column, $iri); | |||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $iri = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | if (length($self->buffer) == 0) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | last unless defined($c); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if (substr($self->buffer, 0, 1) eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $self->get_char_safe('\\'); | |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $esc = $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if ($esc eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | $iri .= "\\"; | |||||||||||||||||||||||||||||||||||||||||||
| 434 | } elsif ($esc eq 'U') { | ||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $codepoint = $self->read_length(8); | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | $self->_throw_error("Bad unicode escape codepoint '$codepoint'") unless ($codepoint =~ /^[0-9A-Fa-f]+$/o); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $iri .= chr(hex($codepoint)); | |||||||||||||||||||||||||||||||||||||||||||
| 438 | } elsif ($esc eq 'u') { | ||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $codepoint = $self->read_length(4); | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $self->_throw_error("Bad unicode escape codepoint '$codepoint'") unless ($codepoint =~ /^[0-9A-Fa-f]+$/o); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | my $char = chr(hex($codepoint)); | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if ($char =~ /[<>" {}|\\^`]/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | $self->_throw_error(sprintf("Bad IRI character: '%s' (0x%x)", $char, ord($char))); | |||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $iri .= $char; | |||||||||||||||||||||||||||||||||||||||||||
| 446 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $self->_throw_error("Unrecognized iri escape '$esc'"); | |||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 449 | } elsif ($self->buffer =~ /^[^<>\x00-\x20\\"{}|^`]+/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $iri .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 451 | } elsif (substr($self->buffer, 0, 1) eq '>') { | ||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||
| 453 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $self->_throw_error("Got '$c' while expecting IRI character"); | |||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $self->get_char_safe(q[>]); | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | return $self->new_token(IRI, $self->start_line, $self->start_column, $iri); | |||||||||||||||||||||||||||||||||||||||||||
| 460 | } elsif (substr($buffer, 0, 2) eq '<=') { | ||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | return $self->new_token(LE, $self->start_line, $self->start_column, '<='); | |||||||||||||||||||||||||||||||||||||||||||
| 463 | } elsif (substr($buffer, 0, 2) eq '>=') { | ||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | return $self->new_token(GE, $self->start_line, $self->start_column, '>='); | |||||||||||||||||||||||||||||||||||||||||||
| 466 | ▶ | } elsif ($self->sparql12 and substr($buffer, 0, 3) eq '<<(') { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->sparql12 and substr($buffer, 0, 3) eq "<<("
MC/DC50%1/2
$self->sparql12 and substr($buffer, 0, 3) eq "<<("
$self->sparql12
substr($buffer, 0, 3) eq "<<("
Truth table66%2/3
A and B
A= $self->sparql12B= substr($buffer, 0, 3) eq "<<("
| |||||||||||||||||||||||||||||||||||||||||||||
| 467 | 1 | $self->read_length(3); | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | return $self->new_token(LTLTP, $self->start_line, $self->start_column, '<<('); | |||||||||||||||||||||||||||||||||||||||||||
| 469 | ▶ | } elsif ($self->sparql12 and substr($buffer, 0, 2) eq '<<') { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->sparql12 and substr($buffer, 0, 2) eq "<<"
MC/DC50%1/2
$self->sparql12 and substr($buffer, 0, 2) eq "<<"
$self->sparql12
substr($buffer, 0, 2) eq "<<"
Truth table66%2/3
A and B
A= $self->sparql12B= substr($buffer, 0, 2) eq "<<"
| |||||||||||||||||||||||||||||||||||||||||||||
| 470 | 4 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 4 | return $self->new_token(LTLT, $self->start_line, $self->start_column, '<<'); | |||||||||||||||||||||||||||||||||||||||||||
| 472 | ▶ | } elsif ($self->sparql12 and substr($buffer, 0, 2) eq '>>') { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->sparql12 and substr($buffer, 0, 2) eq ">>"
MC/DC50%1/2
$self->sparql12 and substr($buffer, 0, 2) eq ">>"
$self->sparql12
substr($buffer, 0, 2) eq ">>"
Truth table66%2/3
A and B
A= $self->sparql12B= substr($buffer, 0, 2) eq ">>"
| |||||||||||||||||||||||||||||||||||||||||||||
| 473 | 4 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 4 | return $self->new_token(GTGT, $self->start_line, $self->start_column, '>>'); | |||||||||||||||||||||||||||||||||||||||||||
| 475 | } elsif (substr($buffer, 0, 1) eq '>') { | ||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | return $self->new_token(GT, $self->start_line, $self->start_column, '>'); | |||||||||||||||||||||||||||||||||||||||||||
| 478 | } elsif (substr($buffer, 0, 1) eq '<') { | ||||||||||||||||||||||||||||||||||||||||||||
| 479 | 2 | $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 2 | return $self->new_token(LT, $self->start_line, $self->start_column, '<'); | |||||||||||||||||||||||||||||||||||||||||||
| 481 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | die "Unrecognized relational op near '$buffer'"; | |||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | ▶ | sub _get_bang { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_bang: called CC=2 SCAR=7.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | ▶ | if ($self->buffer =~ /^!=/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return $self->new_token(NOTEQUALS, $self->start_line, $self->start_column, '!='); | |||||||||||||||||||||||||||||||||||||||||||
| 491 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 1 | return $self->new_token(BANG, $self->start_line, $self->start_column, '!'); | |||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | sub _get_bnode { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_bnode: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | unless ($self->buffer =~ /^$r_BLANK_NODE_LABEL/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $self->_throw_error("Expected: name"); | |||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $ln = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $name = substr($ln, 2); | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | return $self->new_token(BNODE, $self->start_line, $self->start_column, $name); | |||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | 18 | ▶ | sub _get_number { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_number: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 508 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 18 | ▶ | if ($self->buffer =~ /^${r_DOUBLE}/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | return $self->new_token(DOUBLE, $self->start_line, $self->start_column, $self->read_length($+[0])); | |||||||||||||||||||||||||||||||||||||||||||
| 511 | } elsif ($self->buffer =~ /^${r_DECIMAL}/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | return $self->new_token(DECIMAL, $self->start_line, $self->start_column, $self->read_length($+[0])); | |||||||||||||||||||||||||||||||||||||||||||
| 513 | } elsif ($self->buffer =~ /^${r_INTEGER}/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 514 | 16 | return $self->new_token(INTEGER, $self->start_line, $self->start_column, $self->read_length($+[0])); | |||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $self->_throw_error("Expected number"); | |||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | 20 | ▶ | sub _get_lparen_or_nil { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_lparen_or_nil: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 520 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 521 | 20 | ▶ | if ($self->buffer =~ /^$r_NIL/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 522 | 1 | $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 1 | return $self->new_token(NIL, $self->start_line, $self->start_column, '()'); | |||||||||||||||||||||||||||||||||||||||||||
| 524 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 525 | 19 | $self->get_char_safe('('); | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 19 | return $self->new_token(LPAREN, $self->start_line, $self->start_column, '('); | |||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | 19 | ▶ | sub _get_rparen_or_pgtgt { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_rparen_or_pgtgt: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 531 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 19 | ▶ | if ($self->sparql12 and substr($self->buffer, 0, 3) eq ')>>') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->sparql12 and substr($self->buffer, 0, 3) eq ")>>"
MC/DC50%1/2
$self->sparql12 and substr($self->buffer, 0, 3) eq ")>>"
$self->sparql12
substr($self->buffer, 0, 3) eq ")>>"
Truth table66%2/3
A and B
A= $self->sparql12B= substr($self->buffer, 0, 3) eq ")>>"
| |||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | $self->read_length(3); | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 1 | return $self->new_token(PGTGT, $self->start_line, $self->start_column, ')>>'); | |||||||||||||||||||||||||||||||||||||||||||
| 535 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 536 | 18 | $self->get_char_safe(')'); | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 18 | return $self->new_token(RPAREN, $self->start_line, $self->start_column, ')'); | |||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||
| 541 | 148 | ▶ | sub _get_brace_or_annotation_or_or { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_brace_or_annotation_or_or: called CC=8 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||
| 542 | 148 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 543 | 148 | ▶ | if ($self->sparql12 and substr($self->buffer, 0, 2) eq '{|') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition100%3/3
$self->sparql12 and substr($self->buffer, 0, 2) eq "{|"
MC/DC100%2/2
$self->sparql12 and substr($self->buffer, 0, 2) eq "{|"
$self->sparql12
substr($self->buffer, 0, 2) eq "{|"
Truth table100%3/3
A and B
A= $self->sparql12B= substr($self->buffer, 0, 2) eq "{|"
| |||||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | return $self->new_token(LANNOT, $self->start_line, $self->start_column, '{|'); | |||||||||||||||||||||||||||||||||||||||||||
| 546 | ▶ | } elsif ($self->sparql12 and substr($self->buffer, 0, 2) eq '|}') { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->sparql12 and substr($self->buffer, 0, 2) eq "|}"
MC/DC100%2/2
$self->sparql12 and substr($self->buffer, 0, 2) eq "|}"
$self->sparql12
substr($self->buffer, 0, 2) eq "|}"
Truth table100%3/3
A and B
A= $self->sparql12B= substr($self->buffer, 0, 2) eq "|}"
| |||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | return $self->new_token(RANNOT, $self->start_line, $self->start_column, '|}'); | |||||||||||||||||||||||||||||||||||||||||||
| 549 | } elsif (substr($self->buffer, 0, 2) eq '||') { | ||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | $self->read_length(2); | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | return $self->new_token(OROR, $self->start_line, $self->start_column, '||'); | |||||||||||||||||||||||||||||||||||||||||||
| 552 | } elsif (substr($self->buffer, 0, 1) eq '{') { | ||||||||||||||||||||||||||||||||||||||||||||
| 553 | 73 | $self->get_char_safe('{'); | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 73 | return $self->new_token(LBRACE, $self->start_line, $self->start_column, '{'); | |||||||||||||||||||||||||||||||||||||||||||
| 555 | } elsif (substr($self->buffer, 0, 1) eq '}') { | ||||||||||||||||||||||||||||||||||||||||||||
| 556 | 71 | $self->get_char_safe('}'); | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 71 | return $self->new_token(RBRACE, $self->start_line, $self->start_column, '}'); | |||||||||||||||||||||||||||||||||||||||||||
| 558 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $self->get_char_safe('|'); | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | return $self->new_token(OR, $self->start_line, $self->start_column, '|'); | |||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | sub _get_lbracket_or_anon { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_lbracket_or_anon: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | if ($self->buffer =~ /^$r_ANON/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return $self->new_token(ANON, $self->start_line, $self->start_column, '[]'); | |||||||||||||||||||||||||||||||||||||||||||
| 569 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $self->get_char_safe('['); | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return $self->new_token(LBRACKET, $self->start_line, $self->start_column, '['); | |||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | sub _get_comment { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_comment: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $self->get_char_safe('#'); | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $comment = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | while (length($c) and $c !~ /[\r\n]/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $c and not $c =~ /[\r\n]/ou
MC/DC0%0/2
length $c and not $c =~ /[\r\n]/ou
length $c
not $c =~ /[\r\n]/ou
Truth table0%0/3
A and not(B)
A= length $cB= not $c =~ /[\r\n]/ou
| |||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $comment .= $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if (length($c) and $c =~ /[\r\n]/o) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $c and $c =~ /[\r\n]/ou
MC/DC0%0/2
length $c and $c =~ /[\r\n]/ou
length $c
$c =~ /[\r\n]/ou
Truth table0%0/3
A and B
A= length $cB= $c =~ /[\r\n]/ou
| |||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | return $self->new_token(COMMENT, $self->start_line, $self->start_column, $comment); | |||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||
| 590 | 2 | ▶ | sub _get_lang { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_lang: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||||
| 591 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 2 | ▶ | my $lang_re = ($self->version ge '1.2') ? $r_LANGTAG_12 : $r_LANGTAG; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 2 | ▶ | if ($self->buffer =~ $lang_re) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 594 | 2 | my $lang = $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | substr($lang, 0, 1, ''); # remove the '@' prefix | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | return $self->new_token(LANG, $self->start_line, $self->start_column, $lang); | |||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $self->_throw_error("Expected keyword or language tag"); | |||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||
| 601 | 16 | ▶ | sub _get_double_literal { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_double_literal: called CC=12 SCAR=26.6
| |||||||||||||||||||||||||||||||||||||||||||||
| 602 | 16 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 603 | # my $c = $self->peek_char(); | ||||||||||||||||||||||||||||||||||||||||||||
| 604 | 16 | $self->get_char_safe(q["]); | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 16 | ▶ | if (substr($self->buffer, 0, 2) eq q[""]) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 606 | # #x22 #x22 #x22 lcharacter* #x22 #x22 #x22 | ||||||||||||||||||||||||||||||||||||||||||||
| 607 | 4 | $self->read_word(q[""]); | |||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | 4 | my $quote_count = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 4 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 611 | 4 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 16 | ▶ | if (length($self->buffer) == 0) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $self->fill_buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | $self->_throw_error("Found EOF in string literal") if (length($self->buffer) == 0); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 616 | 16 | ▶ | if (substr($self->buffer, 0, 1) eq '"') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 617 | 12 | my $c = $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 12 | $quote_count++; | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 12 | ▶ | last if ($quote_count == 3); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 620 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 621 | 4 | ▶ | if ($quote_count) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $string .= '"' foreach (1..$quote_count); | |||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $quote_count = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 625 | 4 | ▶ | if (substr($self->buffer, 0, 1) eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | $string .= $self->read_backslash_escape(); | |||||||||||||||||||||||||||||||||||||||||||
| 627 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 628 | 4 | $self->{buffer} =~ /^[^"\\]+/; | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 4 | $string .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 633 | 4 | return $self->new_token(STRING3D, $self->start_line, $self->start_column, $string); | |||||||||||||||||||||||||||||||||||||||||||
| 634 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 635 | ### #x22 scharacter* #x22 | ||||||||||||||||||||||||||||||||||||||||||||
| 636 | 12 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 12 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 26 | ▶ | if (substr($self->buffer, 0, 1) eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 639 | 5 | $string .= $self->read_backslash_escape(); | |||||||||||||||||||||||||||||||||||||||||||
| 640 | } elsif ($self->buffer =~ /^[^"\\]+/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 641 | 10 | $string .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 642 | } elsif (substr($self->buffer, 0, 1) eq '"') { | ||||||||||||||||||||||||||||||||||||||||||||
| 643 | 11 | last; | |||||||||||||||||||||||||||||||||||||||||||
| 644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | my $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $self->_throw_error("Got '$c' while expecting string character"); | |||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 649 | 11 | $self->get_char_safe(q["]); | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 11 | return $self->new_token(STRING1D, $self->start_line, $self->start_column, $string); | |||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||
| 654 | 8 | ▶ | sub _get_single_literal { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_single_literal: called CC=12 SCAR=26.6
| |||||||||||||||||||||||||||||||||||||||||||||
| 655 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 8 | $self->get_char_safe("'"); | |||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | ▶ | if (substr($self->buffer, 0, 2) eq q['']) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 658 | # #x22 #x22 #x22 lcharacter* #x22 #x22 #x22 | ||||||||||||||||||||||||||||||||||||||||||||
| 659 | 5 | $self->read_word(q['']); | |||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | 5 | my $quote_count = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 662 | 5 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 5 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 20 | ▶ | if (length($self->buffer) == 0) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $self->fill_buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | $self->_throw_error("Found EOF in string literal") if (length($self->buffer) == 0); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 668 | 20 | ▶ | if (substr($self->buffer, 0, 1) eq "'") { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 669 | 15 | my $c = $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 15 | $quote_count++; | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 15 | ▶ | last if ($quote_count == 3); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 672 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 673 | 5 | ▶ | if ($quote_count) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | $string .= "'" foreach (1..$quote_count); | |||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $quote_count = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 677 | 5 | ▶ | if (substr($self->buffer, 0, 1) eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $string .= $self->read_backslash_escape(); | |||||||||||||||||||||||||||||||||||||||||||
| 679 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 680 | 5 | $self->{buffer} =~ /^[^'\\]+/; | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 5 | $string .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 685 | 5 | return $self->new_token(STRING3S, $self->start_line, $self->start_column, $string); | |||||||||||||||||||||||||||||||||||||||||||
| 686 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 687 | ### #x22 scharacter* #x22 | ||||||||||||||||||||||||||||||||||||||||||||
| 688 | 3 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 3 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 6 | ▶ | if (substr($self->buffer, 0, 1) eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 691 | 1 | $string .= $self->read_backslash_escape(); | |||||||||||||||||||||||||||||||||||||||||||
| 692 | } elsif ($self->buffer =~ /^[^'\\]+/o) { | ||||||||||||||||||||||||||||||||||||||||||||
| 693 | 2 | $string .= $self->read_length($+[0]); | |||||||||||||||||||||||||||||||||||||||||||
| 694 | } elsif (substr($self->buffer, 0, 1) eq "'") { | ||||||||||||||||||||||||||||||||||||||||||||
| 695 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||
| 696 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | my $c = $self->peek_char(); | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $self->_throw_error("Got '$c' while expecting string character"); | |||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 701 | 3 | $self->get_char_safe(q[']); | |||||||||||||||||||||||||||||||||||||||||||
| 702 | 3 | return $self->new_token(STRING1S, $self->start_line, $self->start_column, $string); | |||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||
| 706 | 6 | ▶ | sub read_backslash_escape { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_backslash_escape: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 707 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 6 | ▶ | if ($self->sparql12) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 709 | # In SPARQL 1.2 all escape logic happens here, including multi-character | ||||||||||||||||||||||||||||||||||||||||||||
| 710 | # escape sequences such as \uXXXX and \UXXXXXXXX. | ||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | return $self->_get_escaped_char(1); | |||||||||||||||||||||||||||||||||||||||||||
| 712 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 713 | # In SPARQL 1.1, multi-character codepoint escape sequences \uXXXX and \UXXXXXXXX | ||||||||||||||||||||||||||||||||||||||||||||
| 714 | # are handled before parsing begins. What is left should only be single-character | ||||||||||||||||||||||||||||||||||||||||||||
| 715 | # escapes such as \t and \n. | ||||||||||||||||||||||||||||||||||||||||||||
| 716 | 4 | return $self->_get_escaped_char(0); | |||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||
| 720 | 6 | ▶ | sub _get_escaped_char { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_escaped_char: called CC=17 SCAR=38.7
| |||||||||||||||||||||||||||||||||||||||||||||
| 721 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 6 | my $allow_mb = shift; # allow multi-byte escape sequences such as \uXXXX | |||||||||||||||||||||||||||||||||||||||||||
| 723 | 6 | my $c = $self->peek_char; | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 6 | $self->get_char_safe('\\'); | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 6 | my $esc = $self->get_char; | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if ($esc eq '\\') { return "\\" } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 727 | 3 | elsif ($esc =~ /^['">]$/) { return $esc } | |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | elsif ($esc eq 'r') { return "\r" } | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 1 | elsif ($esc eq 't') { return "\t" } | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | elsif ($esc eq 'n') { return "\n" } | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | elsif ($esc eq 'b') { return "\b" } | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | elsif ($esc eq 'f') { return "\f" } | |||||||||||||||||||||||||||||||||||||||||||
| 733 | elsif ($allow_mb) { | ||||||||||||||||||||||||||||||||||||||||||||
| 734 | 2 | ▶ | if ($esc eq 'U') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $h = $self->read_length(8); | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $codepoint = hex($h); | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | $self->_throw_error("Bad unicode escape codepoint '$codepoint'") unless ($h =~ /^[0-9A-Fa-f]+$/o); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if ($codepoint >= 0xD800 and $codepoint <= 0xDFFF) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$codepoint >= 55296 and $codepoint <= 57343
MC/DC0%0/2
$codepoint >= 55296 and $codepoint <= 57343
$codepoint >= 55296
$codepoint <= 57343
Truth table0%0/3
A and B
A= $codepoint >= 55296B= $codepoint <= 57343
| |||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | die "Surrogate U+$h is illegal as a codepoint escape value"; | |||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | return chr($codepoint); | |||||||||||||||||||||||||||||||||||||||||||
| 742 | } elsif ($esc eq 'u'){ | ||||||||||||||||||||||||||||||||||||||||||||
| 743 | 2 | my $h = $self->read_length(4); | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | my $codepoint = hex($h); | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | ▶ | $self->_throw_error("Bad unicode escape codepoint '$codepoint'") unless ($h =~ /^[0-9A-Fa-f]+$/o); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | ▶ | if ($codepoint >= 0xD800 and $codepoint <= 0xDFFF) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$codepoint >= 55296 and $codepoint <= 57343
MC/DC50%1/2
$codepoint >= 55296 and $codepoint <= 57343
$codepoint >= 55296
$codepoint <= 57343
Truth table66%2/3
A and B
A= $codepoint >= 55296B= $codepoint <= 57343
| |||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | die "Surrogate U+$h is illegal as a codepoint escape value"; | |||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | return chr($codepoint); | |||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $self->_throw_error("Unrecognized string escape '$esc'"); | |||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | sub current_location { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_location: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | return ($self->line, $self->column, $self->buffer); | |||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | sub throw_near_error { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw_near_error: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | my $line = shift // $self->line; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() // $self->line
MC/DC0%0/2
shift() // $self->line
shift()
$self->line
Truth table0%0/3
A // B
A= shift()B= $self->line
| |||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | my $col = shift // $self->column; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() // $self->column
MC/DC0%0/2
shift() // $self->column
shift()
$self->column
Truth table0%0/3
A // B
A= shift()B= $self->column
| |||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | my $buffer = shift // $self->buffer; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() // $self->buffer
MC/DC0%0/2
shift() // $self->buffer
shift()
$self->buffer
Truth table0%0/3
A // B
A= shift()B= $self->buffer
| |||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | die "$message near $line:$col: " . $buffer; | |||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | 2 | ▶ | sub _throw_error { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_throw_error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 2 | my $error = shift; | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 2 | my $line = $self->line; | |||||||||||||||||||||||||||||||||||||||||||
| 773 | 2 | my $col = $self->column; | |||||||||||||||||||||||||||||||||||||||||||
| 774 | 13 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 775 | 2 | Carp::confess "$error at $line:$col with buffer: " . Dumper($self->buffer); | |||||||||||||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||
| 779 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||
| 781 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||