Implement var

master
Raymon Zutekouw 3 years ago
parent e1150e2280
commit 92d164dd78
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 6
      src/main.rs

@ -81,7 +81,11 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
Rule::var => { Rule::var => {
let variable_name = extract_operand(statement); let variable_name = extract_operand(statement);
println!("Creation of variable '{}'", variable_name); println!("Creation of variable '{}'", variable_name);
out.append("var\n"); state.variables.insert(
String::from(variable_name),
MemCell::allocate(state.alloc_cnt),
);
state.alloc_cnt += 1;
} }
Rule::delvar => { Rule::delvar => {
let variable_name = extract_operand(statement); let variable_name = extract_operand(statement);

Loading…
Cancel
Save