Implement map value
This commit is contained in:
parent
327a2d044b
commit
f596c6b581
@ -133,7 +133,31 @@ impl Value {
|
|||||||
|
|
||||||
Ok(Value::Table(table))
|
Ok(Value::Table(table))
|
||||||
}
|
}
|
||||||
"map" => todo!(),
|
"map" => {
|
||||||
|
let child_count = node.child_count();
|
||||||
|
let mut map = VariableMap::new();
|
||||||
|
let mut key = String::new();
|
||||||
|
|
||||||
|
for index in 0..child_count {
|
||||||
|
let child = node.child(index).unwrap();
|
||||||
|
|
||||||
|
if child.kind() == "identifier" {
|
||||||
|
let child_identifier = Expression::new(child, source)?;
|
||||||
|
|
||||||
|
if let Expression::Identifier(identifier) = child_identifier {
|
||||||
|
key = identifier
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if child.kind() == "value" {
|
||||||
|
let value = Value::new(child, source)?;
|
||||||
|
|
||||||
|
map.set_value(key.as_str(), value)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Value::Map(map))
|
||||||
|
}
|
||||||
"function" => {
|
"function" => {
|
||||||
let child_count = node.child_count();
|
let child_count = node.child_count();
|
||||||
let mut identifiers = Vec::new();
|
let mut identifiers = Vec::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user