Parses qnames and boolean values, which have equivalent starting characters. @ignore
protected function parseQNameOrBoolean() {
// First character should be a ':' or a letter
$c = $this
->read();
if ($c == -1) {
throw new EasyRdf_Exception("Turtle Parse Error: unexpected end of file while readying value");
}
if ($c != ':' && !self::isPrefixStartChar($c)) {
throw new EasyRdf_Exception("Turtle Parse Error: expected a ':' or a letter, found '{$c}'");
}
$namespace = null;
if ($c == ':') {
// qname using default namespace
$namespace = $this->namespaces[""];
if ($namespace == null) {
throw new EasyRdf_Exception("Turtle Parse Error: default namespace used but not defined");
}
}
else {
// $c is the first letter of the prefix
$prefix = $c;
$c = $this
->read();
while (self::isPrefixChar($c)) {
$prefix .= $c;
$c = $this
->read();
}
if ($c != ':') {
// prefix may actually be a boolean value
$value = $prefix;
if ($value == "true" || $value == "false") {
return array(
'type' => 'literal',
'value' => $value,
'datatype' => EasyRdf_Namespace::get('xsd') . 'boolean',
);
}
}
$this
->verifyCharacter($c, ":");
if (isset($this->namespaces[$prefix])) {
$namespace = $this->namespaces[$prefix];
}
else {
throw new EasyRdf_Exception("Turtle Parse Error: namespace prefix '{$prefix}' used but not defined");
}
}
// $c == ':', read optional local name
$localName = '';
$c = $this
->read();
if (self::isNameStartChar($c)) {
$localName .= $c;
$c = $this
->read();
while (self::isNameChar($c)) {
$localName .= $c;
$c = $this
->read();
}
}
// Unread last character
$this
->unread($c);
// Note: namespace has already been resolved
return array(
'type' => 'uri',
'value' => $namespace . $localName,
);
}