protected function EasyRdf_Parser_Turtle::parseLongString

Parses a """long string""". This method assumes that the first three double quotes have already been parsed.

@ignore

Parameters

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

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

File

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

Class

EasyRdf_Parser_Turtle
Class to parse Turtle with no external dependancies.

Code

protected function parseLongString($quote) {
  $str = '';
  $doubleQuoteCount = 0;
  while ($doubleQuoteCount < 3) {
    $c = $this
      ->read();
    if ($c == -1) {
      throw new EasyRdf_Exception("Turtle Parse Error: unexpected end of file while reading long string");
    }
    elseif ($c == $quote) {
      $doubleQuoteCount++;
    }
    else {
      $doubleQuoteCount = 0;
    }
    $str .= $c;
    if ($c == '\\') {

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