Match macro #include

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

@ -12,6 +12,9 @@ decNum =_{ ASCII_DIGIT+ }
hexNum =_{ "0x" ~ ASCII_HEX_DIGIT+ }
num =_{ hexNum | decNum }
constant = { char | num }
path = { "\"" ~ (!"\"" ~ ANY)+ ~ "\"" }
include =@{ "#include" ~ spacing+ ~ path }
var =@{ "var" ~ spacing+ ~ variable }
delvar =@{ "delvar" ~ spacing+ ~ variable }
@ -33,7 +36,10 @@ setz =@{ "setz" }
getchr =@{ "getchr" }
print =@{ "print" }
instruction =_{ var
macaroo =_{ include }
instruction =_{ macaroo
| var
| delvar
| point

@ -50,6 +50,11 @@ fn parse_constant(text: &str) -> Result<i32, std::num::ParseIntError> {
fn instruct(statement: Pair<Rule>, out: &mut Builder) {
match statement.as_rule() {
Rule::include => {
let file_path = extract_operand(statement);
println!("Including {} into this src file", file_path);
out.append("#include\n");
}
Rule::var => {
let variable_name = extract_operand(statement);
println!("Creation of variable '{}'", variable_name);

Loading…
Cancel
Save