Match all instructions without arguments

rewrite/grammar-implicit-whitespace
Raymon Zutekouw 3 years ago
parent 3023872053
commit eb61fa5cef
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 8
      src/grammars/mblf.pest
  2. 12
      src/main.rs

@ -24,6 +24,10 @@ subb =@{ "subb" ~ spacing+ ~ num }
subv =@{ "subv" ~ spacing+ ~ variable }
copy =@{ "copy" ~ spacing+ ~ variable }
setz =@{ "setz" }
getchr =@{ "getchr" }
print =@{ "print" }
instruction =_{ var
| delvar
@ -40,6 +44,10 @@ instruction =_{ var
| subv
| copy
| setz
| getchr
| print
| operator ~ (spacing+ ~ operand)?
}

@ -118,6 +118,18 @@ fn instruct(statement: Pair<Rule>, out: &mut Builder) {
println!("Copy to variable '{}'", variable_name);
out.append("copy\n");
}
Rule::setz => {
println!("Set current variable to zero");
out.append("setz\n");
}
Rule::getchr => {
println!("Reading char from user input into current variable");
out.append("getchr\n");
}
Rule::print => {
println!("Printing current variable");
out.append("print\n");
}
Rule::instruction => {
out.append("\n");
}

Loading…
Cancel
Save