Skip to content
← Back

src/syntax/trees/expressions/string_interpolation.ghul

1
namespace Syntax.Trees.Expressions is
2
use IO.Std;
3
use Source;
4
5
class STRING_INTERPOLATION: Expression is
6
_values: Collections.LIST[INTERPOLATION_FRAGMENT];
7
values: Collections.List[INTERPOLATION_FRAGMENT] => _values;
8
literal_length: int;
9
expression_count: int;
10
11
init(
12
location: LOCATION,
13
values: Collections.LIST[INTERPOLATION_FRAGMENT],
14
literal_length: int,
15
expression_count: int
16
) is
17
super.init(location);
18
19
self._values = values;
20
self.literal_length = literal_length;
21
self.expression_count = expression_count;
22
si
23
24
accept(visitor: Visitor) is
25
visitor.visit(self);
26
si
27
28
walk(visitor: Visitor) is
29
if !visitor.pre(self) then
30
for v in _values do
31
v.expression.walk(visitor);
32
33
if let v.alignment? then
34
alignment.walk(visitor);
35
fi
36
od
37
fi
38
39
accept(visitor);
40
si
41
si
42
43
struct INTERPOLATION_FRAGMENT is
44
is_expression: bool;
45
expression: Expression;
46
// Null when the interpolation has no `,alignment` clause.
47
alignment: Expression?;
48
// Null when the interpolation has no `:format` clause.
49
format: string?;
50
51
init(
52
is_expression: bool,
53
expression: Expression,
54
alignment: Expression?,
55
format: string?
56
) is
57
self.is_expression = is_expression;
58
self.expression = expression;
59
self.alignment = alignment;
60
self.format = format;
61
si
62
si
63
si