From 1a33eb5adfa18c73a605c82c7766924939719ed5 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 11 Feb 2015 01:41:28 +0700 Subject: [PATCH] Fix parser #lol --- core/parser.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/parser.go b/core/parser.go index 1b8e27d..0efc794 100644 --- a/core/parser.go +++ b/core/parser.go @@ -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())