Fix parser #lol

This commit is contained in:
Gregory Eremin 2015-02-11 01:41:28 +07:00
parent e6acf6c41c
commit 1a33eb5adf

View File

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