FoldedSequenceExpr
public indirect enum FoldedSequenceExpr : Hashable, Sendable
extension FoldedSequenceExpr: Monotonic
A sequence of binary operations stored as a tree whose structure encodes the evaluation order.
Instances of this type are created during type checking for each SequenceExpr in the program
once the precedence groups of its operators have been determined. A tree is created by calling
append(operator:right:) to append an operator and its right operand to the sub-sequence
represented by self.
-
The expression of an operator in the AST together with its precedence.
See moreDeclaration
Swift
public struct Operator : Hashable, Sendable -
The application of an infix operator to its
leftandrightoperands.Declaration
Swift
case infix(Operator, left: FoldedSequenceExpr, right: FoldedSequenceExpr) -
A leaf node representing some expression.
Declaration
Swift
case leaf(AnyExprID) -
Mutates
selfso that it represents the expression evaluated by appendingoperator.exprandrighttoself.This method uses
operator.precedenceto determine whether the whole expression represented byselfshould become the LHS of the new operation, or if the operator must apply to a sub-expression ofself.Roughly, assuming
selfrepresentsa + band+has a lower precedence than*:self.append(+, c)results in a tree representing(a + b) + cself.append(*, c)results in a tree representinga + (b * c)
View on GitHub