assignment nodes eval their values

master
Jordan Orelli 10 years ago
parent 5313fe431c
commit 89b5bbcb6f

@ -192,7 +192,11 @@ func (n *assignmentNode) eval(ctx map[string]interface{}) (interface{}, error) {
if _, ok := ctx[n.name]; ok {
return nil, fmt.Errorf("invalid re-declaration: %s", n.name)
}
ctx[n.name] = n.value
v, err := n.value.eval(ctx)
if err != nil {
return nil, err
}
ctx[n.name] = v
return nil, nil
}

@ -1,3 +1,9 @@
root_int: 1
root_float: 1.2
root_exp: 1e9
root_hex: 0xabcde
root_oct: 0777
an_object: {
item_one: 1
item_two: "two"

@ -1,4 +1,34 @@
root:
assign:
name:
root_int
value:
number:
1
assign:
name:
root_float
value:
number:
1.2
assign:
name:
root_exp
value:
number:
1e+09
assign:
name:
root_hex
value:
number:
703710
assign:
name:
root_oct
value:
number:
511
assign:
name:
an_object

Loading…
Cancel
Save