private function parseAttribute(Input $definition, TypeCollection $types, array $attributes): AttributePath
    {
        $definition->expect("{");

        $name = $this->parseAttributeName($definition);
        $type = $this->parseAttributeType($definition) ?? "";

        $definition->expect("}");

        if (in_array($name, $attributes)) {
            throw InvalidRoute::ambiguousAttribute($definition, $name);
        }

        if (!$types->hasNamed($type)) {
            throw InvalidRoute::unknownAttributeType($definition, $name, $type);
        }

        $type = $types->getNamed($type);

        $attributes[] = $name;

        $next = $this->parseRoute($definition, $types, $attributes);

        return new AttributePath($name, $type, $next);
    }