parser = $parser; $this->pos = $pos; $this->length = $length; $this->end = $pos + $length; } /** * @param string $message * * @throws Error * @return never */ public function error( $message ) { $text = $this->getText(); throw new Error( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" ); } /** * @return string */ public function getText() { return substr( $this->parser->rule, $this->pos, $this->length ); } }