Parses a quoted string, optionally followed by a language tag or datatype.
@ignore
string $quote The type of quote to use (either ' or "):
protected function parseQuotedLiteral($quote) {
$label = $this
->parseQuotedString($quote);
// Check for presence of a language tag or datatype
$c = $this
->peek();
if ($c == '@') {
$this
->read();
// Read language
$lang = '';
$c = $this
->read();
if ($c == -1) {
throw new EasyRdf_Exception("Turtle Parse Error: unexpected end of file while reading language");
}
elseif (!self::isLanguageStartChar($c)) {
throw new EasyRdf_Exception("Turtle Parse Error: expected a letter, found '{$c}'");
}
$lang .= $c;
$c = $this
->read();
while (self::isLanguageChar($c)) {
$lang .= $c;
$c = $this
->read();
}
$this
->unread($c);
return array(
'type' => 'literal',
'value' => $label,
'lang' => $lang,
);
}
elseif ($c == '^') {
$this
->read();
// next character should be another '^'
$this
->verifyCharacter($this
->read(), "^");
// Read datatype
$datatype = $this
->parseValue();
if ($datatype['type'] == 'uri') {
return array(
'type' => 'literal',
'value' => $label,
'datatype' => $datatype['value'],
);
}
else {
throw new EasyRdf_Exception("Turtle Parse Error: illegal datatype value: {$datatype}");
}
}
else {
return array(
'type' => 'literal',
'value' => $label,
);
}
}