okay shift some shit around this is now the actual 1.0.0 :3

This commit is contained in:
abbie 2024-08-14 12:54:52 +01:00
parent ae9634fee6
commit a8dc83924b
Signed by: threeoh6000
GPG key ID: 801FE4AD456E922C
3 changed files with 9 additions and 6 deletions

2
Cargo.lock generated
View file

@ -99,7 +99,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
[[package]]
name = "granite"
version = "1.2.0"
version = "1.0.0"
dependencies = [
"clap",
]

View file

@ -1,6 +1,6 @@
[package]
name = "granite"
version = "1.2.0"
version = "1.0.0"
edition = "2021"
[dependencies]

View file

@ -50,6 +50,7 @@ fn execute(program: Program) {
let statements = program.statements;
let mut vars: HashMap<String, String> = HashMap::new();
let mut current_statement: usize = 0;
let mut stack: Vec<usize> = vec![];
loop {
if current_statement >= statements.len() { break; }
@ -183,12 +184,8 @@ fn execute(program: Program) {
let label_loc = labels.get(&statement.arguments[0]).unwrap();
current_statement = label_loc.clone();
} else {
let binding = statement.arguments[0].clone().parse::<usize>();
if binding.is_ok() { current_statement = binding.unwrap(); }
else {
println!("Numerical type issues.");
exit(1);
}
}
} else if statement.operator == "a" {
if vars.contains_key(&statement.arguments[0]) && vars.contains_key(&statement.arguments[1]) {
@ -294,6 +291,10 @@ fn execute(program: Program) {
}
} else if statement.operator == "$" {
vars.remove(&statement.arguments[0]);
} else if statement.operator == "#" {
stack.push(current_statement);
} else if statement.operator == "|" {
current_statement = stack.pop().expect("Stack underflow.");
}
@ -405,6 +406,8 @@ fn operator_to_arglength(operator: char) -> Option<i32> {
'&' => Some(2),
'$' => Some(1),
'%' => Some(2),
'#' => Some(0),
'|' => Some(0),
_ => None,
}
}