public function format( $sparql ) {
		$this->formattedParts = array();
		$this->indentationLevel = 0;
		$this->replacements = array();

		$regexHelper = new RegexHelper();
		$sparql = $regexHelper->escapeSequences( $sparql, $this->replacements );

		foreach ( $this->split( $sparql ) as $part ) {
			if ( !empty( $this->formattedParts ) ) {
				$this->before( $part );
			}

			$this->indentation( $part );
			$this->append( $part );
			$this->after( $part );
		}

		$this->trimEnd();
		$this->formattedParts[] = "\n";

		return strtr( implode( $this->formattedParts ), $this->replacements );
	}