|
|
@ -56,12 +56,19 @@ private: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Value eval_if(const Ast& ast, Env& env) { |
|
|
|
static Value eval_if(const Ast& ast, Env& env) { |
|
|
|
auto cond = eval(*ast.nodes[0], env); |
|
|
|
const auto& nodes = ast.nodes; |
|
|
|
if (cond.to_bool()) { |
|
|
|
|
|
|
|
return eval(*ast.nodes[1], env); |
|
|
|
for (auto i = 0u; i < nodes.size(); i += 2) { |
|
|
|
} else if (ast.nodes.size() > 2) { |
|
|
|
if (i + 1 == nodes.size()) { |
|
|
|
return eval(*ast.nodes[2], env); |
|
|
|
return eval(*nodes[i], env); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
auto cond = eval(*nodes[i], env); |
|
|
|
|
|
|
|
if (cond.to_bool()) { |
|
|
|
|
|
|
|
return eval(*nodes[i + 1], env); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Value(); |
|
|
|
return Value(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|