public function addToken($name, $position) {
        $token = new Token($name, $position);
        $this->tokens[] = $token;

        // Autoclose opened tokens
        switch (substr($name, -4)) {
            case AbstractBlockRule::OPEN:
                $this->openedTokens[] = substr($name, 0, -5);
                break;
            case AbstractBlockRule::CLOSE:
                while (count($this->openedTokens) > 0) {
                    $lastOpenToken = array_pop($this->openedTokens);
                    $this->tokens[] = new Token($lastOpenToken . AbstractBlockRule::CLOSE, $position);
                    if ($lastOpenToken == substr($name, 0, -5)) {
                        break;
                    }
                }
                break;
        }

        return $token;
    }