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);
    }
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);
    }
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 ) ; }
Parse the main part of the route definition.

@param Input $definition
@param TypeCollection $types
@param string[] $attributes
@return RoutePath
@throws InvalidRoute
@throws UnexpectedChar
Parse the main part of the route definition .