You are here

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

Parses a "normal string". This method requires that the opening character has already been parsed.

@ignore

Parameters

string $closingCharacter The type of quote to use (either ' or "):

1 call to EasyRdf_Parser_Turtle::parseString()
EasyRdf_Parser_Turtle::parseQuotedString in vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Turtle.php
Parses a quoted string, which is either a "normal string" or a """long string""". @ignore

File

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

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parseString($closingCharacter) {
  $str = '';
  while (true) {
    $c = $this
      ->read();
    if ($c == $closingCharacter) {
      break;
    }
    elseif ($c == -1) {
      throw new EasyRdf_Parser_Exception("Turtle Parse Error: unexpected end of file while reading string", $this->line, $this->column);
    }
    $str .= $c;
    if ($c == '\\') {

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