Skip to content
← Back

src/syntax/trees/expressions/binary.ghul

1
namespace Syntax.Trees.Expressions is
2
use IO.Std;
3
4
use Source;
5
6
class BINARY(
7
location: LOCATION,
8
operation: Identifiers.Identifier,
9
actual_operation: string?,
10
left: Expression,
11
right: Expression
12
): Expression is
13
super(location);
14
15
accept(visitor: Visitor) is
16
visitor.visit(self);
17
si
18
19
walk(visitor: Visitor) is
20
// enter/leave_node wrap the whole visit so the ambient
21
// location covers Values built by `pre()` overrides that
22
// take control of the walk — `pre_binary` for `/\`/`\/`
23
// does its own narrowing-aware walk and returns true,
24
// skipping the default recursion below.
25
visitor.enter_node(self);
26
try
27
if !visitor.pre(self) then
28
left.walk(visitor);
29
right.walk(visitor);
30
fi
31
accept(visitor);
32
finally
33
visitor.leave_node(self);
34
yrt
35
si
36
37
replace_child(old: Expression, replacement: Expression) is
38
if left == old then
39
left = replacement;
40
elif right == old then
41
right = replacement;
42
fi
43
si
44
si
45
si