<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_glyphs_filter(filter_str, is_pre=False):
 """Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of glyphs app filter Return: A dictionary contains the structured filter. Return None if parse failed. """

    elements = filter_str.split(";")

    if elements[0] == "":
        logger.error(
            "Failed to parse glyphs filter, expecting a filter name: \
             %s",
            filter_str,
        )
        return None

    result = {"name": elements[0]}
    for idx, elem in enumerate(elements[1:]):
        if not elem:
            # skip empty arguments
            continue
        if ":" in elem:
            # Key value pair
            key, value = elem.split(":", 1)
            if key.lower() in ["include", "exclude"]:
                if idx != len(elements[1:]) - 1:
                    logger.error(
                        "{} can only present as the last argument in the filter. "
                        "{} is ignored.".format(key, elem)
                    )
                    continue
                result[key.lower()] = re.split("[ ,]+", value)
            else:
                if "kwargs" not in result:
                    result["kwargs"] = {}
                result["kwargs"][key] = cast_to_number_or_bool(value)
        else:
            if "args" not in result:
                result["args"] = []
            result["args"].append(cast_to_number_or_bool(elem))
    if is_pre:
        result["pre"] = True
    return result