All fold functions besides down are called after the down-pass in conventional fold-fashion. The down argument holds information obtained during the down-pass, issued by the down function.

interface StatefulFoldFunctions<Info, Down, Up> {
    down: DownFold<Info, Down>;
    foldAccess: ((node: RAccess<Info>, name: Up, access: readonly ("<>" | Up)[], down: Down) => Up);
    foldBinaryOp: ((op: RBinaryOp<Info>, lhs: Up, rhs: Up, down: Down) => Up);
    foldExprList: ((exprList: RExpressionList<Info>, grouping: undefined | [start: Up, end: Up], expressions: Up[], down: Down) => Up);
    foldIfThenElse: ((ifThenExpr: RIfThenElse<Info>, cond: Up, then: Up, otherwise: undefined | Up, down: Down) => Up);
    foldLogical: ((logical: RLogical<Info>, down: Down) => Up);
    foldNumber: ((num: RNumber<Info>, down: Down) => Up);
    foldPipe: ((op: RPipe<Info>, lhs: Up, rhs: Up, down: Down) => Up);
    foldString: ((str: RString<Info>, down: Down) => Up);
    foldSymbol: ((symbol: RSymbol<Info, string>, down: Down) => Up);
    foldUnaryOp: ((op: RUnaryOp<Info>, operand: Up, down: Down) => Up);
    functions: {
        foldArgument: ((argument: RArgument<Info>, name: undefined | Up, value: undefined | Up, down: Down) => Up);
        foldFunctionCall: ((call: RFunctionCall<Info>, functionNameOrExpression: Up, args: ("<>" | Up)[], down: Down) => Up);
        foldFunctionDefinition: ((definition: RFunctionDefinition<Info>, params: Up[], body: Up, down: Down) => Up);
        foldParameter: ((parameter: RParameter<Info>, name: Up, defaultValue: undefined | Up, down: Down) => Up);
    };
    loop: {
        foldBreak: ((next: RBreak<Info>, down: Down) => Up);
        foldFor: ((loop: RForLoop<Info>, variable: Up, vector: Up, body: Up, down: Down) => Up);
        foldNext: ((next: RNext<Info>, down: Down) => Up);
        foldRepeat: ((loop: RRepeatLoop<Info>, body: Up, down: Down) => Up);
        foldWhile: ((loop: RWhileLoop<Info>, condition: Up, body: Up, down: Down) => Up);
    };
    other: {
        foldComment: ((comment: RComment<Info>, down: Down) => Up);
        foldLineDirective: ((comment: RLineDirective<Info>, down: Down) => Up);
    };
}

Type Parameters

  • Info
  • Down
  • Up

Properties

foldAccess: ((node: RAccess<Info>, name: Up, access: readonly ("<>" | Up)[], down: Down) => Up)
foldBinaryOp: ((op: RBinaryOp<Info>, lhs: Up, rhs: Up, down: Down) => Up)
foldExprList: ((exprList: RExpressionList<Info>, grouping: undefined | [start: Up, end: Up], expressions: Up[], down: Down) => Up)
foldIfThenElse: ((ifThenExpr: RIfThenElse<Info>, cond: Up, then: Up, otherwise: undefined | Up, down: Down) => Up)

The otherwise argument is undefined if the else branch is missing

foldLogical: ((logical: RLogical<Info>, down: Down) => Up)
foldNumber: ((num: RNumber<Info>, down: Down) => Up)
foldPipe: ((op: RPipe<Info>, lhs: Up, rhs: Up, down: Down) => Up)
foldString: ((str: RString<Info>, down: Down) => Up)
foldSymbol: ((symbol: RSymbol<Info, string>, down: Down) => Up)
foldUnaryOp: ((op: RUnaryOp<Info>, operand: Up, down: Down) => Up)
functions: {
    foldArgument: ((argument: RArgument<Info>, name: undefined | Up, value: undefined | Up, down: Down) => Up);
    foldFunctionCall: ((call: RFunctionCall<Info>, functionNameOrExpression: Up, args: ("<>" | Up)[], down: Down) => Up);
    foldFunctionDefinition: ((definition: RFunctionDefinition<Info>, params: Up[], body: Up, down: Down) => Up);
    foldParameter: ((parameter: RParameter<Info>, name: Up, defaultValue: undefined | Up, down: Down) => Up);
}

Type declaration

  • foldArgument: ((argument: RArgument<Info>, name: undefined | Up, value: undefined | Up, down: Down) => Up)

    The name is undefined if the argument is unnamed, the value, if we have something like x=,...

      • (argument, name, value, down): Up
      • Parameters

        Returns Up

  • foldFunctionCall: ((call: RFunctionCall<Info>, functionNameOrExpression: Up, args: ("<>" | Up)[], down: Down) => Up)

    folds named and unnamed function calls

      • (call, functionNameOrExpression, args, down): Up
      • Parameters

        Returns Up

  • foldFunctionDefinition: ((definition: RFunctionDefinition<Info>, params: Up[], body: Up, down: Down) => Up)
  • foldParameter: ((parameter: RParameter<Info>, name: Up, defaultValue: undefined | Up, down: Down) => Up)

    The defaultValue is undefined if the argument was not initialized with a default value

      • (parameter, name, defaultValue, down): Up
      • Parameters

        Returns Up

loop: {
    foldBreak: ((next: RBreak<Info>, down: Down) => Up);
    foldFor: ((loop: RForLoop<Info>, variable: Up, vector: Up, body: Up, down: Down) => Up);
    foldNext: ((next: RNext<Info>, down: Down) => Up);
    foldRepeat: ((loop: RRepeatLoop<Info>, body: Up, down: Down) => Up);
    foldWhile: ((loop: RWhileLoop<Info>, condition: Up, body: Up, down: Down) => Up);
}
other: {
    foldComment: ((comment: RComment<Info>, down: Down) => Up);
    foldLineDirective: ((comment: RLineDirective<Info>, down: Down) => Up);
}