use crate::errors::RunError; pub fn expr(memory: &mut Vec, arg: &String) { for code in arg.chars() { match code { '>' => memory.push(0), '$' => { memory.pop(); }, ':' => memory.push(*memory.last().expect(&format!("{}", RunError::MemoryEmpty))), '\\' => { let ax = memory.pop().expect(&format!("{}", RunError::MemoryEmpty)); let ax2 = memory.pop().expect(&format!("{}", RunError::MemoryEmpty)); memory.push(ax); memory.push(ax2); } '+' => { let ax = memory.pop().expect(&format!("{}", RunError::MemoryEmpty)); memory.push(ax + 1); } '-' => { let ax = memory.pop().expect(&format!("{}", RunError::MemoryEmpty)); memory.push(ax - 1); } _ => { eprintln!("{}", RunError::InvalidExpressionUnknownOperator(code.to_string())); std::process::exit(2); } } } }