def parse_glyphs_filter(filter_str, is_pre=False):
elements = filter_str.split("<STR_LIT:;>")<EOL>if elements[<NUM_LIT:0>] == "<STR_LIT>":<EOL><INDENT>logger.error(<EOL>"<STR_LIT>",<EOL>filter_str,<EOL>)<EOL>return None<EOL><DEDENT>result = {"<STR_LIT:name>": elements[<NUM_LIT:0>]}<EOL>for idx, elem in enumerate(elements[<NUM_LIT:1>:]):<EOL><INDENT>if not elem:<EOL><INDENT>continue<EOL><DEDENT>if "<STR_LIT::>" in elem:<EOL><INDENT>key, value = elem.split("<STR_LIT::>", <NUM_LIT:1>)<EOL>if key.lower() in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>if idx != len(elements[<NUM_LIT:1>:]) - <NUM_LIT:1>:<EOL><INDENT>logger.error(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(key, elem)<EOL>)<EOL>continue<EOL><DEDENT>result[key.lower()] = re.split("<STR_LIT>", value)<EOL><DEDENT>else:<EOL><INDENT>if "<STR_LIT>" not in result:<EOL><INDENT>result["<STR_LIT>"] = {}<EOL><DEDENT>result["<STR_LIT>"][key] = cast_to_number_or_bool(value)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if "<STR_LIT:args>" not in result:<EOL><INDENT>result["<STR_LIT:args>"] = []<EOL><DEDENT>result["<STR_LIT:args>"].append(cast_to_number_or_bool(elem))<EOL><DEDENT><DEDENT>if is_pre:<EOL><INDENT>result["<STR_LIT>"] = True<EOL><DEDENT>return result<EOL>
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.