// compileDo compiles the map value with key "do".
// Compiles by special-casing the "on" key as the trigger
// and delegating to compileMap for the remaining.
compileDo compiles the map value with key "do".
Compiles by special-casing the "on" key as the trigger
and delegating to compileMap for the remaining.
// compileDo compiles the map value with key " do " . // Compiles by special - casing the " on " key as the trigger // and delegating to compileMap for the remaining .
func compileDo(yml interface{}) (Expr, string) {
	var m map[interface{}]interface{}
	switch yml := yml.(type) {
	case map[interface{}]interface{}:
		m = yml
	case []interface{}:
		return compileSlice(yml)
	default:
		return nil, "value must be a mapping or sequence"
	}
	var onExpr Expr
	remaining := make(map[interface{}]interface{})
	for k, v := range m {
		var kstr string
		switch k.(type) {
		case string:
			kstr = k.(string)
		case bool:
			if k.(bool) == true {
				kstr = "on"
			} else {
				return nil, "key must be a string"
			}
		default:
			return nil, "key must be a string"
		}
		switch kstr {
		case "on":
			expr, err := compile(v)
			if err != "" {
				return nil, addErrorTrace(err, kstr)
			}
			onExpr = expr
		default:
			remaining[k] = v
		}
	}
	actionExpr, err := compileMap(remaining)
	if err != "" {
		return nil, err
	}
	de, err := newDoExpr(onExpr, actionExpr)
	if err != "" {
		return nil, addErrorTrace(err, "on")
	}
	return de, ""
}
func compileDo ( yml interface { } ) ( Expr , string ) { var m map [ interface { } ] interface { } switch yml := yml . ( type ) { case map [ interface { } ] interface { } : m = yml case [ ] interface { } : return compileSlice ( yml ) default : return nil , " " } var onExpr Expr remaining := make ( map [ interface { } ] interface { } ) for k , v := range m { var kstr string switch k . ( type ) { case string : kstr = k . ( string ) case bool : if k . ( bool ) == true { kstr = " " } else { return nil , " " } default : return nil , " " } switch kstr { case " " : expr , err := compile ( v ) if err != " " { return nil , addErrorTrace ( err , kstr ) } onExpr = expr default : remaining [ k ] = v } } actionExpr , err := compileMap ( remaining ) if err != " " { return nil , err } de , err := newDoExpr ( onExpr , actionExpr ) if err != " " { return nil , addErrorTrace ( err , " " ) } return de , " " }
compileDo compiles the map value with key "do".
compileDo compiles the map value with key " do " .
// on gets parsed to true, we pretend that doesn't happen