-
Notifications
You must be signed in to change notification settings - Fork 6
/
infix.go
66 lines (54 loc) · 1.31 KB
/
infix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2020 Salif Mehmed
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package ast
import "strings"
type Infix struct {
line uint32
left Node
operator string
right Node
}
func (this Infix) GetType() string {
return INFIX
}
func (this Infix) Debug() string {
var result strings.Builder
result.WriteString("(")
result.WriteString(this.left.Debug())
result.WriteString(" ")
result.WriteString(this.operator)
result.WriteString(" ")
result.WriteString(this.right.Debug())
result.WriteString(")")
return result.String()
}
func (this Infix) GetLine() uint32 {
return this.line
}
func (this Infix) GetLeft() Node {
return this.left
}
func (this Infix) GetRight() Node {
return this.right
}
func (this Infix) GetOperator() string {
return this.operator
}
func (this Infix) Init(line uint32, operator string, left Node) Infix {
this.line = line
this.operator = operator
this.left = left
return this
}
func (this Infix) Set(line uint32, left Node, operator string, right Node) Infix {
this.line = line
this.left = left
this.operator = operator
this.right = right
return this
}
func (this *Infix) SetRight(right Node) {
this.right = right
}