26 lines
723 B
Rust
26 lines
723 B
Rust
use crate::{errors::RunError, stack::Instruction};
|
|
|
|
pub fn insert(program: &mut Vec<Instruction>, arg: &String, data: &u16) {
|
|
let args: Vec<char> = arg.chars().collect();
|
|
|
|
if args[0] == '#' || args[0] == '$' {
|
|
eprintln!("{}", RunError::AttemptToInsertHashOrStringInst);
|
|
std::process::exit(2);
|
|
}
|
|
|
|
if args[0] == '\n' {
|
|
eprintln!("{}", RunError::AttemptToInsertEmptyConst);
|
|
std::process::exit(2);
|
|
}
|
|
|
|
if args[0] == '@' || args[1] == ' ' {
|
|
eprintln!("{}", RunError::AttemptToInsertALabel);
|
|
std::process::exit(2);
|
|
}
|
|
|
|
program.push(Instruction {
|
|
name: arg.to_string(),
|
|
arg: "\n".to_string(),
|
|
data: *data
|
|
});
|
|
} |