-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig_array_parser.go
More file actions
58 lines (48 loc) · 1.48 KB
/
config_array_parser.go
File metadata and controls
58 lines (48 loc) · 1.48 KB
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
package hocon
import (
"github.com/jdevelop/go-hocon/parser"
)
func (hc *hocon) ExitArray_data(ctx *parser.Array_dataContext) {
current, _ := hc.stack.Pop()
parent, _ := hc.stack.Peek()
parent.setArray(ctx.Key().GetText(), current.(*ConfigArray))
}
func (hc *hocon) EnterArray_data(ctx *parser.Array_dataContext) {
hc.stack.Push(NewConfigArray(hc))
}
func (hc *hocon) EnterArray_array(ctx *parser.Array_arrayContext) {
hc.stack.Push(NewConfigArray(hc))
}
func (hc *hocon) ExitArray_array(ctx *parser.Array_arrayContext) {
obj, _ := hc.stack.Pop()
p, _ := hc.stack.Peek()
p.setArray("", obj.(*ConfigArray))
}
func (hc *hocon) EnterArray_string(ctx *parser.Array_stringContext) {
hc.compoundRef = new(CompoundString)
hc.compoundRef.Value = make([]*Value, 0)
}
func (hc *hocon) ExitArray_string(ctx *parser.Array_stringContext) {
if hc.compoundRef != nil {
if v, err := hc.stack.Peek(); err == nil {
v.setCompoundString("", hc.compoundRef)
}
hc.compoundRef = nil // cleanup
} else {
if v, err := hc.stack.Peek(); err == nil {
v.setString("", stripStringQuotas(ctx.String_value().GetText()))
}
}
}
func (hc *hocon) ExitArray_number(ctx *parser.Array_numberContext) {
res, _ := hc.stack.Peek()
res.setInt("", ctx.GetText())
}
func (hc *hocon) EnterArray_obj(ctx *parser.Array_objContext) {
hc.stack.Push(NewConfigObject())
}
func (hc *hocon) ExitArray_obj(ctx *parser.Array_objContext) {
obj, _ := hc.stack.Pop()
p, _ := hc.stack.Peek()
p.setObject("", obj.(*ConfigObject))
}