• Folds in old functional-fashion over the AST structure.

    Internally implemented as a special case of a two-way fold (with the down part as an essential no-op)

    Type Parameters

    • Info
    • T

    Parameters

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

            • node: RAccess<Info>
            • name: T
            • access: readonly ("<>" | T)[]
            • down: undefined

            Returns T

      • ReadonlyfoldBinaryOp: ((op: RBinaryOp<Info>, lhs: T, rhs: T, down: undefined) => T)
          • (op, lhs, rhs, down): T
          • Parameters

            Returns T

      • ReadonlyfoldExprList: ((exprList: RExpressionList<Info>, grouping: undefined | [start: T, end: T], expressions: T[], down: undefined) => T)
          • (exprList, grouping, expressions, down): T
          • Parameters

            Returns T

      • ReadonlyfoldIfThenElse: ((ifThenExpr: RIfThenElse<Info>, cond: T, then: T, otherwise: undefined | T, down: undefined) => T)

        The otherwise argument is undefined if the else branch is missing

          • (ifThenExpr, cond, then, otherwise, down): T
          • Parameters

            Returns T

      • ReadonlyfoldLogical: ((logical: RLogical<Info>, down: undefined) => T)
          • (logical, down): T
          • Parameters

            Returns T

      • ReadonlyfoldNumber: ((num: RNumber<Info>, down: undefined) => T)
          • (num, down): T
          • Parameters

            Returns T

      • ReadonlyfoldPipe: ((op: RPipe<Info>, lhs: T, rhs: T, down: undefined) => T)
          • (op, lhs, rhs, down): T
          • Parameters

            Returns T

      • ReadonlyfoldString: ((str: RString<Info>, down: undefined) => T)
          • (str, down): T
          • Parameters

            Returns T

      • ReadonlyfoldSymbol: ((symbol: RSymbol<Info, string>, down: undefined) => T)
          • (symbol, down): T
          • Parameters

            Returns T

      • ReadonlyfoldUnaryOp: ((op: RUnaryOp<Info>, operand: T, down: undefined) => T)
          • (op, operand, down): T
          • Parameters

            Returns T

      • Readonlyfunctions: {
            foldArgument: ((argument: RArgument<Info>, name: undefined | T, value: undefined | T, down: undefined) => T);
            foldFunctionCall: ((call: RFunctionCall<Info>, functionNameOrExpression: T, args: ("<>" | T)[], down: undefined) => T);
            foldFunctionDefinition: ((definition: RFunctionDefinition<Info>, params: T[], body: T, down: undefined) => T);
            foldParameter: ((parameter: RParameter<Info>, name: T, defaultValue: undefined | T, down: undefined) => T);
        }
        • ReadonlyfoldArgument: ((argument: RArgument<Info>, name: undefined | T, value: undefined | T, down: undefined) => T)

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

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

              • argument: RArgument<Info>
              • name: undefined | T
              • value: undefined | T
              • down: undefined

              Returns T

        • ReadonlyfoldFunctionCall: ((call: RFunctionCall<Info>, functionNameOrExpression: T, args: ("<>" | T)[], down: undefined) => T)

          folds named and unnamed function calls

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

              Returns T

        • ReadonlyfoldFunctionDefinition: ((definition: RFunctionDefinition<Info>, params: T[], body: T, down: undefined) => T)
        • ReadonlyfoldParameter: ((parameter: RParameter<Info>, name: T, defaultValue: undefined | T, down: undefined) => T)

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

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

              Returns T

      • Readonlyloop: {
            foldBreak: ((next: RBreak<Info>, down: undefined) => T);
            foldFor: ((loop: RForLoop<Info>, variable: T, vector: T, body: T, down: undefined) => T);
            foldNext: ((next: RNext<Info>, down: undefined) => T);
            foldRepeat: ((loop: RRepeatLoop<Info>, body: T, down: undefined) => T);
            foldWhile: ((loop: RWhileLoop<Info>, condition: T, body: T, down: undefined) => T);
        }
        • ReadonlyfoldBreak: ((next: RBreak<Info>, down: undefined) => T)
            • (next, down): T
            • Parameters

              Returns T

        • ReadonlyfoldFor: ((loop: RForLoop<Info>, variable: T, vector: T, body: T, down: undefined) => T)
            • (loop, variable, vector, body, down): T
            • Parameters

              Returns T

        • ReadonlyfoldNext: ((next: RNext<Info>, down: undefined) => T)
            • (next, down): T
            • Parameters

              Returns T

        • ReadonlyfoldRepeat: ((loop: RRepeatLoop<Info>, body: T, down: undefined) => T)
        • ReadonlyfoldWhile: ((loop: RWhileLoop<Info>, condition: T, body: T, down: undefined) => T)
            • (loop, condition, body, down): T
            • Parameters

              Returns T

      • Readonlyother: {
            foldComment: ((comment: RComment<Info>, down: undefined) => T);
            foldLineDirective: ((comment: RLineDirective<Info>, down: undefined) => T);
        }

    Returns T