You are here

protected function EasyRdf_Parser_Turtle::parsePrefixID 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::parsePrefixID()

Parse a prefixID [4] @ignore

1 call to EasyRdf_Parser_Turtle::parsePrefixID()
EasyRdf_Parser_Turtle::parseDirective in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a directive [3] @ignore

File

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

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parsePrefixID() {
  $this
    ->skipWSC();

  // Read prefix ID (e.g. "rdf:" or ":")
  $prefixID = '';
  while (true) {
    $c = $this
      ->read();
    if ($c == ':') {
      $this
        ->unread($c);
      break;
    }
    elseif (self::isWhitespace($c)) {
      break;
    }
    elseif ($c == -1) {
      throw new EasyRdf_Parser_Exception("Turtle Parse Error: unexpected end of file while reading prefix id", $this->line, $this->column);
    }
    $prefixID .= $c;
  }
  $this
    ->skipWSC();
  $this
    ->verifyCharacterOrFail($this
    ->read(), ":");
  $this
    ->skipWSC();

  // Read the namespace URI
  $namespace = $this
    ->parseURI();

  // Store local namespace mapping
  $this->namespaces[$prefixID] = $namespace['value'];
}