-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.go
65 lines (50 loc) · 921 Bytes
/
ast.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
package main
type NodeType byte
const (
NodeTypeNumber NodeType = iota
NodeTypeBoolean
NodeTypeString
NodeTypeArray
NodeTypeProperty
NodeTypeObject
)
type NumberNode struct {
Value float64
}
type BooleanNode struct {
Value bool
}
type StringNode struct {
Value string
}
type ArrayNode struct {
Elements []*Node
}
type PropertyNode struct {
Key string
Value *Node
}
type ObjectNode struct {
Properties []*PropertyNode
}
func (n NumberNode) GetNodeType() NodeType {
return NodeTypeNumber
}
func (n BooleanNode) GetNodeType() NodeType {
return NodeTypeBoolean
}
func (n StringNode) GetNodeType() NodeType {
return NodeTypeString
}
func (n ArrayNode) GetNodeType() NodeType {
return NodeTypeArray
}
func (n PropertyNode) GetNodeType() NodeType {
return NodeTypeProperty
}
func (n ObjectNode) GetNodeType() NodeType {
return NodeTypeObject
}
type Node interface {
GetNodeType() NodeType
}