protected function EasyRdf_Parser_Turtle::parsePredicate

Parse a predicate [11] @ignore

1 call to EasyRdf_Parser_Turtle::parsePredicate()
EasyRdf_Parser_Turtle::parsePredicateObjectList in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a predicateObjectList [7] @ignore

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php, line 289

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parsePredicate() {

  // Check if the short-cut 'a' is used
  $c1 = $this
    ->read();
  if ($c1 == 'a') {
    $c2 = $this
      ->read();
    if (self::isWhitespace($c2)) {

      // Short-cut is used, return the rdf:type URI
      return array(
        'type' => 'uri',
        'value' => EasyRdf_Namespace::get('rdf') . 'type',
      );
    }

    // Short-cut is not used, unread all characters
    $this
      ->unread($c2);
  }
  $this
    ->unread($c1);

  // Predicate is a normal resource
  $predicate = $this
    ->parseValue();
  if ($predicate['type'] == 'uri') {
    return $predicate;
  }
  else {
    throw new EasyRdf_Exception("Turtle Parse Error: Illegal predicate value: " . $predicate);
  }
}