Implement function calls

This commit is contained in:
Jeff 2023-10-06 21:00:31 -04:00
parent 31e9cb61bb
commit 90352dd264
3 changed files with 13 additions and 2 deletions

View File

@ -61,6 +61,12 @@ impl AbstractTree for FunctionCall {
results.push(result);
}
for identifier in definition.identifiers() {
let key = identifier.inner();
context.remove(&key);
}
Ok(Value::List(results))
}
}

View File

@ -86,8 +86,6 @@ impl<'context, 'code> Evaluator<'context, 'code> {
let item_count = root_node.child_count();
let mut results = Vec::with_capacity(item_count);
println!("{}", root_node.to_sexp());
for item_node in root_node.children(&mut cursor) {
let item_result = Item::from_syntax_node(item_node, self.source);

View File

@ -108,6 +108,13 @@ impl VariableMap {
}
}
/// Removes and assignmed variable.
///
/// TODO: Support dot notation.
pub fn remove(&mut self, key: &str) -> Option<Value> {
self.variables.remove(key)
}
/// Returns a reference to the inner BTreeMap.
pub fn inner(&self) -> &BTreeMap<String, Value> {
&self.variables