class Savi::AST::Relate
- Savi::AST::Relate
- Savi::AST::Node
- Reference
- Object
Overview
A Relate node has a left Term and right Term, related by an infix Operator. One common example is assignment (op.value == "="):
example = "string" ^~~~~~~ (lhs) ^ (op) ^~~~~~ (rhs) ^~~~~~~~~~~~~~~~~~ (relate)
Another common example is method calls prior to Sugar pass expansion,
which have (op.value == ".")
, and whose #rhs
may either be
a Qualify (with args) or an Identifier (no args).
Settings.read(content, true) ^~~~~~~~ (lhs) ^ (op) ^~~~~~~~~~~~~~~~~~~ (rhs) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ (relate)
Other examples include binary operators prior to Sugar pass expansion (usually these get converted to method calls in the Sugar pass):
number_1 + number_2 + number_3 ^~~~~~~~ (inner relate lhs) ^ (inner relate op) ^~~~~~~~ (inner relate rhs) ^~~~~~~~~~~~~~~~~~~ (outer relate lhs -> inner relate) ^ (outer relate op) ^~~~~~~~ (outer relate rhs) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (outer relate)
Operator precedence is settled at the parser/builder level, so associativity is decided when first building the AST.
Defined in:
savi/ast.crConstructors
Instance Method Summary
- #children_accept(ctx : Compiler::Context, visitor : Visitor)
- #children_accept(ctx : Compiler::Context, visitor : CopyOnMutateVisitor)
- #is_assign : Bool
- #is_assign=(is_assign : Bool)
- #lhs : Savi::AST::Node
- #lhs=(lhs : Savi::AST::Node)
- #name
- #op : Savi::AST::Operator
- #op=(op : Savi::AST::Operator)
- #rhs : Savi::AST::Node
- #rhs=(rhs : Savi::AST::Node)
- #span_pos(source)
- #to_a : Array(A)
- #with_assign_flag
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