add variable cloning
This commit is contained in:
parent
1f020ecdb2
commit
e258f6208d
3 changed files with 11 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -99,7 +99,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
|||
|
||||
[[package]]
|
||||
name = "granite"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "granite"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -280,6 +280,14 @@ fn execute(program: Program) {
|
|||
println!("Missing variable on int check.");
|
||||
exit(1);
|
||||
}
|
||||
} else if statement.operator == "%" {
|
||||
if vars.contains_key(&statement.arguments[0]) {
|
||||
let value = vars.get(&statement.arguments[0]).unwrap();
|
||||
vars.insert(statement.arguments[1].clone(), value.clone());
|
||||
} else {
|
||||
println!("Missing variable on clone.");
|
||||
exit(1);
|
||||
}
|
||||
} else if statement.operator == "$" {
|
||||
vars.remove(&statement.arguments[0]);
|
||||
}
|
||||
|
@ -392,6 +400,7 @@ fn operator_to_arglength(operator: char) -> Option<i32> {
|
|||
'0' => Some(1),
|
||||
'&' => Some(2),
|
||||
'$' => Some(1),
|
||||
'%' => Some(2),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue