okay shift some shit around this is now the actual 1.0.0 :3
This commit is contained in:
parent
ae9634fee6
commit
a8dc83924b
3 changed files with 9 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -99,7 +99,7 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
|||
|
||||
[[package]]
|
||||
name = "granite"
|
||||
version = "1.2.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "granite"
|
||||
version = "1.2.0"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -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,13 +184,9 @@ 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]) {
|
||||
let value = vars.get(&statement.arguments[0]).unwrap();
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue