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