public function parse($templateString)
    {
        if (!is_string($templateString)) {
            throw new Exception('Parse requires a template string as argument, ' . gettype($templateString) . ' given.', 1224237899);
        }

        $this->reset();

        $templateString = $this->extractEscapingModifier($templateString);
        $templateString = $this->extractNamespaceDefinitions($templateString);
        $splitTemplate = $this->splitTemplateAtDynamicTags($templateString);
        $parsingState = $this->buildObjectTree($splitTemplate, self::CONTEXT_OUTSIDE_VIEWHELPER_ARGUMENTS);

        $variableContainer = $parsingState->getVariableContainer();
        if ($variableContainer !== null && $variableContainer->exists('layoutName')) {
            $parsingState->setLayoutNameNode($variableContainer->get('layoutName'));
        }

        return $parsingState;
    }