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 } subv =@{ "subv" ~ spacing+ ~ variable }
copy =@{ "copy" ~ spacing+ ~ variable } copy =@{ "copy" ~ spacing+ ~ variable }
setz =@{ "setz" }
getchr =@{ "getchr" }
print =@{ "print" }
instruction =_{ var instruction =_{ var
| delvar | delvar
@ -40,6 +44,10 @@ instruction =_{ var
| subv | subv
| copy | copy
| setz
| getchr
| print
| operator ~ (spacing+ ~ operand)? | operator ~ (spacing+ ~ operand)?
} }

@ -118,6 +118,18 @@ fn instruct(statement: Pair<Rule>, out: &mut Builder) {
println!("Copy to variable '{}'", variable_name); println!("Copy to variable '{}'", variable_name);
out.append("copy\n"); 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 => { Rule::instruction => {
out.append("\n"); out.append("\n");
} }

Loading…
Cancel
Save