Algorithm 1: Parsel program synthesis - corresponds to short Parsel pseudocode.
Input: A string program specifying a Parse program and a target language   
Output: Synthesized program   
Function Parsel(program, target_language): function_graph  $\leftarrow$  ParseProgram(program) dependency_graph  $\leftarrow$  GetDependencyGraph(function_graph,target_language) sccs, scc_graph  $\leftarrow$  IdentifySCCs dependency_graph) implementation  $\leftarrow$  "" foreach scc  $\in$  PostOrderTraversal(sccs) do implementation  $\leftarrow$  implementation + SynthesizeSCC(scc, scc_graph) return implementation   
Function ParseProgram(program): root  $\leftarrow$  CreateRootNode() current_node  $\leftarrow$  root current_indentation  $\leftarrow 0$  foreach line  $\in$  program do line_indentation  $\leftarrow$  IndentationOf(line) while line_indentation  $<  <$  current_indentation do current_node  $\leftarrow$  current_node.parent current_indentation  $= = 1$  current_node  $\leftarrow$  ParseLine(line, current_node) return root   
Function ParseLine(line, current_node): if IsDefinition(line) then current_node(children  $\stackrel{+}{\leftarrow}$  ParseDefinition(line); //Creates a new function node else if lsReference(line) then |current_node(children  $\stackrel{+}{\leftarrow}$  ParseReference(line); //Adds reference to current node else |current_nodeConstraints  $\stackrel{+}{\leftarrow}$  ParseConstraint(line); //Adds constraint to current node   
Function GetDependencyGraph(function_graph,target_language): //Converts function call graph into dependency graph. dependency_graph  $\leftarrow$  CopyOf(function_graph); foreach node  $\in$  dependency_graph do foreach child  $\in$  node.children do if child成败s  $= \emptyset$  then AddDependency(child, node); //Child without asserts depends on parent return dependency_graph   
Function SynthesizeSCC(scc, scc_graph): implementation_str  $\leftarrow$  SynthesizeChildren(scc, scc_graph) fn implementations  $\leftarrow$  GenerateImplementations(scc, n, implementation_str) implementation  $\leftarrow$  SolveConstraints(scc, fn_implementationss) if implementation is valid then return implementation   
Function SynthesizeChildren(scc, scc_graph): child implementations  $\leftarrow$  "" foreach child_scc  $\in$  scc_graph.GetChildren(scc) do child implementations  $\leftarrow$  child_implementationss + SynthesizeSCC(child_scc, scc_graph) return child_implementationss   
Function GenerateImplementations(scc, n, implementation_str): implementations  $\leftarrow$  [] foreach fn  $\in$  scc do fn_implementationss  $\leftarrow$  GenerateNImplementations(fn, n, implementation_str) implementations.append(fn_implementationss) return implementations   
Function SolveConstraints(scc, fn_implementationss): combinations  $\leftarrow$  DirectProductImplementations(fn_implementationss) constraints  $\leftarrow$  GenerateConstraints(scc); //Translate each of the constraints into an evaluation string foreach implementation_str  $\in$  combinations do if EvalStr(implementation_str, constraints) then return implementation_str; //Return if implementation passes constraints OnFail(scc, scc_graph); //If none are found, raise error   
Function GenerateConstraints(scc): constraints  $\leftarrow$  [] foreach fn  $\in$  scc do fn Constraints  $\leftarrow$  GetConstraints(fn) constraints extend(fnConstraints) return constraints