class Savi::AST::Choice
- Savi::AST::Choice
- Savi::AST::Node
- Reference
- Object
Overview
A Choice node indicates a branching flow control, with a list of possible condition Terms and corresponding body Terms. During execution, each condition Term is evaluated in order until the first one that returns True, at which point the corresponding body Term is evaluated and its result becomes the result value of the Choice block, and later other branches will not be executed at all. This is roughly an if/else-if/... block.
This is an internal AST type which has no corresponding source code syntax, because such a construct is only created inside macro expansions.
However, the most obvious examples of use are in the if
and case
macros.
Defined in:
savi/ast.crConstructors
Instance Method Summary
- #children_accept(ctx : Compiler::Context, visitor : Visitor)
- #children_accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor)
- #list : Array({Savi::AST::Node, Savi::AST::Node})
- #list=(list : Array(Tuple(Savi::AST::Node, Savi::AST::Node)))
- #name
- #span_pos(source)
- #to_a : Array(A)
Instance methods inherited from class Savi::AST::Node
accept(ctx : Compiler::Context, visitor : Visitor)accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor) accept, annotations : Array(Annotation) | Nil annotations, annotations=(annotations : Array(Annotation) | Nil) annotations=, children_accept(ctx : Compiler::Context, visitor : Visitor)
children_accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor) children_accept, from(other : Node) from, pos pos, pos? : Savi::Source::Pos? pos?, span_pos(source) span_pos, with_pos(pos : Source::Pos) with_pos