import { AST, Binary, Child } from "../ast" import { ASTVisitor } from "../visitors" import { Eta } from "../reductions/eta" export class EtaConverter extends ASTVisitor { private parent : Binary | null private treeSide : Child | null private target : AST constructor ( { parent, treeSide, target } : Eta, public tree : AST, ) { super() this.parent = parent this.treeSide = treeSide this.target = target this.tree = tree } perform () : void { if (this.parent === null) { this.tree = this.target } else { this.parent[ this.treeSide] = this.target } } }