def parse_functions(<EOL>bels: list, char_locs: CharLocs, parsed: Parsed, errors: Errors<EOL>) -> Tuple[Parsed, Errors]:
parens = char_locs["<STR_LIT>"]<EOL>if not parens:<EOL><INDENT>bels_len = len(bels) - <NUM_LIT:1><EOL>span = (<NUM_LIT:0>, bels_len)<EOL>parsed[span] = {<EOL>"<STR_LIT:name>": "<STR_LIT>".join(bels),<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": span,<EOL>"<STR_LIT>": (span),<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>}<EOL>return parsed, errors<EOL><DEDENT>for sp in sorted(parens):  <EOL><INDENT>ep, function_level = parens[sp]<EOL>if bels[sp - <NUM_LIT:1>] == "<STR_LIT:U+0020>":<EOL><INDENT>continue<EOL><DEDENT>for i in range(sp - <NUM_LIT:1>, <NUM_LIT:0>, -<NUM_LIT:1>):<EOL><INDENT>if bels[i] in ["<STR_LIT:U+0020>", "<STR_LIT:U+002C>", "<STR_LIT:(>"]:  <EOL><INDENT>if i < sp - <NUM_LIT:1>:<EOL><INDENT>if ep == -<NUM_LIT:1>:<EOL><INDENT>span = (i + <NUM_LIT:1>, len(bels) - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>span = (i + <NUM_LIT:1>, ep)<EOL><DEDENT>parsed[span] = {<EOL>"<STR_LIT:name>": "<STR_LIT>".join(bels[i + <NUM_LIT:1> : sp]),<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": span,<EOL>"<STR_LIT>": (i + <NUM_LIT:1>, sp - <NUM_LIT:1>),<EOL>"<STR_LIT>": (sp, ep),<EOL>"<STR_LIT>": function_level,<EOL>}<EOL><DEDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if ep == -<NUM_LIT:1>:<EOL><INDENT>span = (<NUM_LIT:0>, len(bels) - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>span = (<NUM_LIT:0>, ep)<EOL><DEDENT>parsed[span] = {<EOL>"<STR_LIT:name>": "<STR_LIT>".join(bels[<NUM_LIT:0>:sp]),<EOL>"<STR_LIT:type>": "<STR_LIT>",<EOL>"<STR_LIT>": span,<EOL>"<STR_LIT>": (<NUM_LIT:0>, sp - <NUM_LIT:1>),<EOL>"<STR_LIT>": (sp, ep),<EOL>"<STR_LIT>": function_level,<EOL>}<EOL><DEDENT><DEDENT>return parsed, errors<EOL>
Parse functions from BEL using paren, comma, quote character locations

    Args:
        bels: BEL string as list of chars
        char_locs: paren, comma, quote character locations
        errors: Any error messages generated during the parse

    Returns:
        (functions, errors): function names and locations and error messages