1 parsel(program, target_language, allow_autofill=False, allow_autodecomp=False): compile a program from a string specifying a  $\leftrightarrow$  Parsel program.   
2 parse-program(program): parse the Parsel program string to a call graph create_root_node(): create a root node as the current function node, without any constraints   
3 parse_line(line, current_node, current_indent) -> function_graph: for each step up in indentation, set the current node  $\leftrightarrow$  to its parents. then, parse the definition, reference, or constraint.   
5 parse_definedline): create a new function node, make it a child of the current node's parent, then assign it as  $\leftrightarrow$  current node.   
6 parse_line_to_fn(line) -> name, args, rets, description: extract the function name, arguments, optionally returned  $\leftrightarrow$  variables, and description of the form "name(args) -> rets: description" if return variables are present else "  $\leftrightarrow$  name(args): description".   
7 populate_fn_node(name, args, rets, description): populate the new node's name, arguments, description, and optionally  $\leftrightarrow$  a list of returned variables.   
8 parse_reference(line): add reference as a child of current node if reference is an ancestor or a direct child of an  $\leftrightarrow$  ancestor   
9 parse_constrained(line): add the constraint to the current node's constraints.   
10 get Dependency_graph(function_graph) -> dependency_graph: taking the function graph, create a copy where all nodes without  $\leftrightarrow$  constraints also depend on their parents unless the target language implicitly tests all functions.   
11 identify_strongly-connected_components(dependency_graph): return SCCs of the dependency graph and the edges between the  $\leftrightarrow$  SCCs.   
12 compile_scc(scc, scc_graph, allow_autofill, allow_autodecomp): accumulate a implementation string which solves the current  $\leftrightarrow$  function   
13 compilechildren(scc, scc_graph, allow_autofill, allow_autodecomp): compile any SCCs this SCC depends on and add them to  $\leftrightarrow$  the implementation string.   
14 compile_scc   
15 direct_product_implementationsin(fn_implementation): return the direct product of the list of lists of  $\leftrightarrow$  fn_implementation   
16 generate implementations(scc, n, children_implementation_str): for each function in the SCC, generate n implementations  $\leftrightarrow$  of each function starting with the implementation string of the SCC's children.   
17 fn_implementation   
18 fn_implementation(fn_node, n): prompt the language model to generate n implementations of a function   
19 generate_prompt(fn_node): first prepend a string with all descriptions, names, arguments, and returns of fn_node's  $\leftrightarrow$  direct children, in a style idiomatic for the target language. then, add fn_node's description and function  $\leftrightarrow$  signature.   
20 solve CONSTRAINTs(scc, fn_implementationns, n, allow_autofill, allow_autodecomp): taking the provided constraints of each  $\leftrightarrow$  function in the scc, evaluate a shuffled list of the direct product of implementations with the constraints until  $\leftrightarrow$  one passes all of them   
21 generate CONSTRAINTs(fn_node): translate each of the constraints into an evaluation string idiomatic to the target  $\leftrightarrow$  language   
22 eval_str(scc, implementation_str, allow_autofil): evaluate an implementation including constraints by running it in a  $\leftrightarrow$  target-language executor. if allow_autofil and the execution fails due to an undefined reference, attempt  $\leftrightarrow$  retrofit   
23 exec实施tion(implementation_str): run the implementation, including constraints/tests, in a target-language-  $\leftrightarrow$  specific executor, returning whether it was successful   
24 attempt_autofil(scc, implementation_str, undefined_fn_use_example): create a new function node for the referenced  $\leftrightarrow$  function, then re-attempt to execute retrofit   
25 add Undefined_fn(scc, implementation_str, undefined_fn_caller, undefined_fn_use_example): create a new function  $\leftrightarrow$  node for the undefined function as a child of the function which calls it and add it to the scc and  $\leftrightarrow$  implementation string. prompt the language model with the usage example as the description to generate a set  $\leftrightarrow$  of implementations.   
26 fn_implementation   
27 eval_str   
28 on_fail(scc, scc_graph, allow_autofil, allow_autodecomp): if allowing autodecomposition, attempt to decompose.  $\leftrightarrow$  otherwise, raise an error highlighting the scc which could not be compiled   
29 attempt_autodecomp(scc, scc_graph, allow_autofil, allow_autodecomp): prompt the language model to decompose each  $\leftrightarrow$  unimplemented function node.   
30 prompt_model(fn_node): prompt the language model, asking it to generate a "fn_name(arg): desc" for each subfunction  $\leftrightarrow$  necessary to implement the function node. add those functions to the scc, including a set of possible  $\leftrightarrow$  implementations for each.   
31 fn_implementation   
32 compile_scc   
33 raise_error(scc): raise an error that Parsel could compile the scc