diff --git a/src/main.rs b/src/main.rs index 86da4fa..64b1afa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -175,8 +175,20 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec) -> St } if inputs.contains(") begin") { + // I really need to stop calling all my vectors coolbeans. + + // Flowchart of this for me to brain + // Place macro <- Apply loop label <- Get loop name + // \-> Place cond. jumping -> Set contents to contelt let coolbeans: Vec<&str> = inputs.split(") begin ").collect(); - println!("{}", coolbeans.last().unwrap()); + let loop_name = coolbeans.last().unwrap(); // Get loop name + + let mut loop_contents = format!("@{}&start\n{}", loop_name, contents); // Apply loop label and place macro + + loop_contents = format!("{}\nJCN ,&execy\nJMP ,&end", loop_contents); // Place conditional jumping + + contents = loop_contents.to_string(); + } return contents.to_string(); } @@ -251,10 +263,18 @@ fn parse(code: String) -> String { println!("ERROR: Macro set {} not initalised in code.", tmac[0]); process::exit(1); } + } else if line.contains("end!") { + blocks[3].push_str(",&end"); + blocks[3].push_str("BRK"); + } else if line.contains("rnd!") { + blocks[3].push_str(",&end"); + blocks[3].push_str("BRK"); + } else if line.contains("break!") { + blocks[3].push_str("BRK"); } } - return format!("{}\n{}\n|0000\n{}\n|0100\n{}", blocks[0], blocks[1], blocks[2], blocks[3]).to_string(); + return format!("( generated by lintc )\n{}\n{}\n|0000\n{}\n|0100\n{}", blocks[0], blocks[1], blocks[2], blocks[3]).to_string(); } fn main() {