public static function setKeywordFormattingOptions(array $keywords)
    {
        $keyword_map = array(
            self::KEYWORD_NEWLINE => &self::$reserved_newline,
            self::KEYWORD_TOPLEVEL => &self::$reserved_toplevel
        );

        foreach ($keywords as $keyword => $type) {
            if (!array_key_exists($type, $keyword_map)) {
                throw new \InvalidArgumentException(
                    "Unexpected type '{$type}' : type must be a KEYWORD_* class constant"
                );
            }

            foreach ($keyword_map as $keyword_type => $registered_keywords) {
                if (in_array($keyword, $registered_keywords)) {
                    if ($type === $keyword_type) {
                        continue(2); // the keyword is already of the specified type
                    }

                    // remove the keyword from its current type collection
                    $keyword_map[$keyword_type] = array_diff($keyword_map[$keyword_type], array($keyword));
                }
            }

            // add the keyword to the specified type collection
            $keyword_map[$type][] = $keyword;
        }
    }