You are here

protected function EasyRdf_Parser_Turtle::parseValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php \EasyRdf_Parser_Turtle::parseValue()

Parses an RDF value. This method parses uriref, qname, node ID, quoted literal, integer, double and boolean. @ignore

4 calls to EasyRdf_Parser_Turtle::parseValue()
EasyRdf_Parser_Turtle::parseObject in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a object [12] @ignore
EasyRdf_Parser_Turtle::parsePredicate in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a predicate [11] @ignore
EasyRdf_Parser_Turtle::parseQuotedLiteral in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parses a quoted string, optionally followed by a language tag or datatype. @ignore
EasyRdf_Parser_Turtle::parseSubject in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a subject [10] @ignore

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php, line 519

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parseValue() {
  $c = $this
    ->peek();
  if ($c == '<') {

    // uriref, e.g. <foo://bar>
    return $this
      ->parseURI();
  }
  elseif ($c == ':' || self::isPrefixStartChar($c)) {

    // qname or boolean
    return $this
      ->parseQNameOrBoolean();
  }
  elseif ($c == '_') {

    // node ID, e.g. _:n1
    return $this
      ->parseNodeID();
  }
  elseif ($c == '"' || $c == "'") {

    // quoted literal, e.g. "foo" or """foo""" or 'foo' or '''foo'''
    return $this
      ->parseQuotedLiteral();
  }
  elseif (ctype_digit($c) || $c == '.' || $c == '+' || $c == '-') {

    // integer or double, e.g. 123 or 1.2e3
    return $this
      ->parseNumber();
  }
  elseif ($c == -1) {
    throw new EasyRdf_Parser_Exception("Turtle Parse Error: unexpected end of file while reading value", $this->line, $this->column);
  }
  else {
    throw new EasyRdf_Parser_Exception("Turtle Parse Error: expected an RDF value here, found '{$c}'", $this->line, $this->column);
  }
}