Add support for multi-character vars

This commit is contained in:
~karx 2021-02-07 17:24:53 +00:00
parent 026466efac
commit 1717a2492c
1 changed files with 4 additions and 2 deletions

View File

@ -9,7 +9,7 @@ mod eval;
struct Program {
data: Vec<String>,
pc: usize,
vars: HashMap<char, char>
vars: HashMap<char, String>
}
impl Program {
@ -64,8 +64,10 @@ impl Program {
fn add_var(&mut self, arguments: &str) {
let argument_vec: Vec<char> = arguments.chars().collect();
let name = argument_vec[0];
let value = argument_vec[1..].into_iter().collect::<String>();
self.vars.insert(argument_vec[0], argument_vec[1]);
self.vars.insert(name, value);
}
fn parse(&mut self, instruction: &String) {