Remove addb and subb

- add and sub will be optimized based on the operand
master
Raymon Zutekouw 3 years ago
parent 82fcfea43a
commit f2934ace5d
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 4
      src/grammars/mblf.pest
  2. 18
      src/main.rs

@ -20,11 +20,9 @@ point =@{ "point" ~ spacing+ ~ variable }
pointm =@{ "pointm" ~ spacing+ ~ variable } pointm =@{ "pointm" ~ spacing+ ~ variable }
add =@{ "add" ~ spacing+ ~ constant } add =@{ "add" ~ spacing+ ~ constant }
addb =@{ "addb" ~ spacing+ ~ constant }
addv =@{ "addv" ~ spacing+ ~ variable } addv =@{ "addv" ~ spacing+ ~ variable }
sub =@{ "sub" ~ spacing+ ~ constant } sub =@{ "sub" ~ spacing+ ~ constant }
subb =@{ "subb" ~ spacing+ ~ constant }
subv =@{ "subv" ~ spacing+ ~ variable } subv =@{ "subv" ~ spacing+ ~ variable }
copy =@{ "copy" ~ spacing+ ~ variable } copy =@{ "copy" ~ spacing+ ~ variable }
@ -43,11 +41,9 @@ instruction =_{ macaroo
| pointm | pointm
| add | add
| addb
| addv | addv
| sub | sub
| subb
| subv | subv
| copy | copy

@ -122,15 +122,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
); );
out.append("+".repeat(constant_parsed as usize)); out.append("+".repeat(constant_parsed as usize));
} }
Rule::addb => {
let constant = operand;
let constant_parsed = parse_constant(constant).unwrap();
println!(
"Big Addition of '{}', decimal value is {}",
constant, constant_parsed
);
out.append("addb\n");
}
Rule::addv => { Rule::addv => {
let variable_name = operand; let variable_name = operand;
println!("Addition to variable '{}'", variable_name); println!("Addition to variable '{}'", variable_name);
@ -145,15 +136,6 @@ fn to_bf(rule: Rule, operand: &str, state: &mut State, out: &mut Builder) {
); );
out.append("-".repeat(constant_parsed as usize)); out.append("-".repeat(constant_parsed as usize));
} }
Rule::subb => {
let constant = operand;
let constant_parsed = parse_constant(constant).unwrap();
println!(
"Big Subtraction of '{}', decimal value is {}",
constant, constant_parsed
);
out.append("subb\n");
}
Rule::subv => { Rule::subv => {
let variable_name = operand; let variable_name = operand;
println!("Subtraction from variable '{}'", variable_name); println!("Subtraction from variable '{}'", variable_name);

Loading…
Cancel
Save