Remove instruction prints
This commit is contained in:
-23
@@ -69,7 +69,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
match rule {
|
||||
Rule::var => {
|
||||
let variable_name = operand;
|
||||
println!("Creation of variable '{}'", variable_name);
|
||||
if let Some(_v) = state.variables.insert(
|
||||
String::from(variable_name),
|
||||
MemCell::allocate(state.alloc_cnt),
|
||||
@@ -80,14 +79,12 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
}
|
||||
Rule::delvar => {
|
||||
let variable_name = operand;
|
||||
println!("Deletion of variable '{}'", variable_name);
|
||||
if let None = state.variables.remove(&String::from(variable_name)) {
|
||||
panic!("Variable '{}' did not exists", variable_name);
|
||||
}
|
||||
}
|
||||
Rule::point => {
|
||||
let variable_name = operand;
|
||||
println!("Pointing to variable '{}'", variable_name);
|
||||
let address = state
|
||||
.variables
|
||||
.get(variable_name)
|
||||
@@ -99,7 +96,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
Rule::pointa => {
|
||||
let address = operand;
|
||||
let address_parsed = parse_constant(address).unwrap();
|
||||
println!("Pointing to address '{}'", address);
|
||||
if address_parsed < state.mem_pointer {
|
||||
out.append("<".repeat((state.mem_pointer - address_parsed) as usize))
|
||||
} else if address_parsed > state.mem_pointer {
|
||||
@@ -109,7 +105,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
}
|
||||
Rule::pointm => {
|
||||
let variable_name = operand;
|
||||
println!("Pointing back to marker variable {}", variable_name);
|
||||
let address = state
|
||||
.variables
|
||||
.get(variable_name)
|
||||
@@ -122,15 +117,10 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
Rule::add => {
|
||||
let constant = operand;
|
||||
let constant_parsed = parse_constant(constant).unwrap();
|
||||
println!(
|
||||
"Addition of '{}', decimal value is {}",
|
||||
constant, constant_parsed
|
||||
);
|
||||
out.append("+".repeat(constant_parsed as usize));
|
||||
}
|
||||
Rule::addv => {
|
||||
let variable_name = operand;
|
||||
println!("Addition to variable '{}'", variable_name);
|
||||
let source_address = state.mem_pointer.to_string();
|
||||
out.append("[");
|
||||
to_bf(Rule::sub, "1", state, out);
|
||||
@@ -142,15 +132,10 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
Rule::sub => {
|
||||
let constant = operand;
|
||||
let constant_parsed = parse_constant(constant).unwrap();
|
||||
println!(
|
||||
"Subtraction of '{}', decimal value is {}",
|
||||
constant, constant_parsed
|
||||
);
|
||||
out.append("-".repeat(constant_parsed as usize));
|
||||
}
|
||||
Rule::subv => {
|
||||
let variable_name = operand;
|
||||
println!("Subtraction from variable '{}'", variable_name);
|
||||
let source_address = state.mem_pointer.to_string();
|
||||
out.append("[");
|
||||
to_bf(Rule::sub, "1", state, out);
|
||||
@@ -161,7 +146,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
}
|
||||
Rule::copy => {
|
||||
let variable_name = operand;
|
||||
println!("Copy to variable '{}'", variable_name);
|
||||
let source_address = state.mem_pointer.to_string();
|
||||
to_bf(Rule::var, "__temp", state, out);
|
||||
out.append("[");
|
||||
@@ -182,27 +166,21 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
|
||||
to_bf(Rule::delvar, "__temp", state, out);
|
||||
}
|
||||
Rule::setz => {
|
||||
println!("Set current variable to zero");
|
||||
out.append("[-]");
|
||||
}
|
||||
Rule::getchr => {
|
||||
println!("Reading char from user input into current variable");
|
||||
out.append(",");
|
||||
}
|
||||
Rule::print => {
|
||||
println!("Printing current variable");
|
||||
out.append(".");
|
||||
}
|
||||
Rule::loopBlockStart => {
|
||||
println!("Start of loopBlock");
|
||||
out.append("[");
|
||||
}
|
||||
Rule::loopBlockEnd => {
|
||||
println!("End of loopBlock");
|
||||
out.append("]");
|
||||
}
|
||||
Rule::EOI => {
|
||||
println!("End of Input");
|
||||
out.append("\n");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
@@ -214,7 +192,6 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
|
||||
Rule::include => {
|
||||
let file_path_raw = extract_operand(statement);
|
||||
let file_path = &file_path_raw[1..file_path_raw.len() - 1];
|
||||
println!("Including {} into this src file", file_path);
|
||||
let content = std::fs::read_to_string(&file_path)
|
||||
.with_context(|| format!("could not read source file {:?}", file_path))
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user