1
0
Fork 0

Fix parser #lol

This commit is contained in:
Gregory Eremin 2015-02-11 01:41:28 +07:00
parent e6acf6c41c
commit 1a33eb5adf
1 changed files with 8 additions and 7 deletions

View File

@ -25,11 +25,11 @@ func buildChain(conf interface{}) *Chain {
Links: []Caller{},
}
for flow, links := range conf.(map[string]interface{}) {
if f, ok := FlowMap[flow]; ok {
c.Flow = f
for f, links := range conf.(map[string]interface{}) {
if flow := FlowOf(f); flow != UnknownFlow {
c.Flow = flow
} else {
panic("Unknown chain flow: " + flow)
panic("Unknown chain flow: " + f)
}
for _, link := range links.([]interface{}) {
@ -42,11 +42,12 @@ func buildChain(conf interface{}) *Chain {
c.Links = append(c.Links, Caller(subchain))
}
case reflect.String:
unit, ok := Units[link.(string)]
name := link.(string)
caller, ok := Units[name]
if !ok {
fmt.Println("Unknown unit `" + link.(string) + "`")
fmt.Println("Unknown unit:", name)
} else {
c.Links = append(c.Links, unit)
c.Links = append(c.Links, caller)
}
default:
panic("Unexpected chain element: " + val.Kind().String())