private function read(array $types, Stack $tokens)
    {
        $token = $tokens->shift();

        if (!in_array($token->type, $types, true)) {
            $names = array();
            foreach ($types as $type) {
                $names[] = $this->tokenizer->getTokenName($type);
            }

            throw new \RuntimeException(
                "Expected one of: " . implode(', ', $names) . ", found " .
                $this->tokenizer->getTokenName($token->type) .
                ". in line {$token->line} at position {$token->position}."
            );
        }

        return $token;
    }