private function parseRoute(Input $definition, TypeCollection $types, array $attributes): RoutePath
    {
        $char = $definition->peek();

        if ($char === "{") {
            return $this->parseAttribute($definition, $types, $attributes);
        }

        if ($char === "[") {
            return $this->parseOptional($definition, $types, $attributes);
        }

        if ($char === "}") {
            throw InvalidRoute::unexpectedCharacter($definition, $attributes);
        }

        if ($char === "]" || $char === Input::END) {
            return new EmptyPath();
        }

        return $this->parseStatic($definition, $types, $attributes);
    }