public static function parse(string $input, bool $resultAsObject = false)
    {
        try {
            $data = self::doParse($input, $resultAsObject);
        } catch (SyntaxErrorException $e) {
            $exception = new ParseException($e->getMessage(), -1, null, null, $e);

            if ($token = $e->getToken()) {
                $exception->setParsedLine($token->getLine());
            }

            throw $exception;
        }

        return $data;
    }