You are here

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

Parses a URI / IRI @ignore

3 calls to EasyRdf_Parser_Turtle::parseURI()
EasyRdf_Parser_Turtle::parseBase in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse base [5] @ignore
EasyRdf_Parser_Turtle::parsePrefixID in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parse a prefixID [4] @ignore
EasyRdf_Parser_Turtle::parseValue in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parses an RDF value. This method parses uriref, qname, node ID, quoted literal, integer, double and boolean. @ignore

File

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

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parseURI() {
  $uri = '';

  // First character should be '<'
  $this
    ->verifyCharacterOrFail($this
    ->read(), "<");

  // Read up to the next '>' character
  while (true) {
    $c = $this
      ->read();
    if ($c == '>') {
      break;
    }
    elseif ($c == -1) {
      throw new EasyRdf_Parser_Exception("Turtle Parse Error: unexpected end of file while reading URI", $this->line, $this->column);
    }
    $uri .= $c;
    if ($c == '\\') {

      // This escapes the next character, which might be a '>'
      $c = $this
        ->read();
      if ($c == -1) {
        throw new EasyRdf_Parser_Exception("Turtle Parse Error: unexpected end of file while reading URI", $this->line, $this->column);
      }
      $uri .= $c;
    }
  }

  // Unescape any escape sequences
  $uri = $this
    ->unescapeString($uri);
  return array(
    'type' => 'uri',
    'value' => $this
      ->resolve($uri),
  );
}