Parses a numeric value, either of type integer, decimal or double @ignore
protected function parseNumber() {
$value = '';
$datatype = EasyRdf_Namespace::get('xsd') . 'integer';
$c = $this
->read();
// read optional sign character
if ($c == '+' || $c == '-') {
$value .= $c;
$c = $this
->read();
}
while (ctype_digit($c)) {
$value .= $c;
$c = $this
->read();
}
if ($c == '.' || $c == 'e' || $c == 'E') {
// We're parsing a decimal or a double
$datatype = EasyRdf_Namespace::get('xsd') . 'decimal';
// read optional fractional digits
if ($c == '.') {
$value .= $c;
$c = $this
->read();
while (ctype_digit($c)) {
$value .= $c;
$c = $this
->read();
}
if (strlen($value) == 1) {
// We've only parsed a '.'
throw new EasyRdf_Exception("Turtle Parse Error: object for statement missing");
}
}
else {
if (strlen($value) == 0) {
// We've only parsed an 'e' or 'E'
throw new EasyRdf_Exception("Turtle Parse Error: object for statement missing");
}
}
// read optional exponent
if ($c == 'e' || $c == 'E') {
$datatype = EasyRdf_Namespace::get('xsd') . 'double';
$value .= $c;
$c = $this
->read();
if ($c == '+' || $c == '-') {
$value .= $c;
$c = $this
->read();
}
if (!ctype_digit($c)) {
throw new EasyRdf_Exception("Turtle Parse Error: Exponent value missing");
}
$value .= $c;
$c = $this
->read();
while (ctype_digit($c)) {
$value .= $c;
$c = $this
->read();
}
}
}
// Unread last character, it isn't part of the number
$this
->unread($c);
// Return result as a typed literal
return array(
'type' => 'literal',
'value' => $value,
'datatype' => $datatype,
);
}