|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
use debug_cell::RefCell;
|
|
|
|
|
use core::panic;
|
|
|
|
|
use std::{collections::HashMap, rc::Rc};
|
|
|
|
|
|
|
|
|
|
use super::{
|
|
|
|
@ -71,7 +72,27 @@ impl CommandContext {
|
|
|
|
|
if let Token::Keyword(_) = value {
|
|
|
|
|
todo!("assignment variable interpolation isn't implemented");
|
|
|
|
|
}
|
|
|
|
|
todo!("local variable assignment isn't implemented")
|
|
|
|
|
let mut block_option = Some(self.context.clone());
|
|
|
|
|
let mut modified = false;
|
|
|
|
|
while let Some(block) = block_option {
|
|
|
|
|
let block = block.borrow();
|
|
|
|
|
block
|
|
|
|
|
.variables
|
|
|
|
|
.borrow_mut()
|
|
|
|
|
.entry(variable.clone())
|
|
|
|
|
.and_modify(|e| {
|
|
|
|
|
*e = value.clone();
|
|
|
|
|
modified = true;
|
|
|
|
|
});
|
|
|
|
|
if modified {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
block_option = block.parent.clone();
|
|
|
|
|
}
|
|
|
|
|
if !modified {
|
|
|
|
|
panic!("undefined variable `{variable}`");
|
|
|
|
|
}
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Eat { .. } => return None,
|
|
|
|
|