0.4.0: Add loops

This is possible by adding begin <loop name> after a macro, doing loop code and ending it with end!<loop name>. If you add loops you will need to add break! at the end of your code.
This commit is contained in:
abbie 2022-02-15 17:20:21 +00:00
parent a529be1e1f
commit 4826485417
No known key found for this signature in database
GPG key ID: 04DDE463F9200F87
4 changed files with 12 additions and 15 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "lintc"
version = "0.3.1"
version = "0.4.0"
edition = "2021"
build = "build.rs"

4
README
View file

@ -14,10 +14,10 @@ Latest release and setup
----------------------------
Clone this repository to get the latest development version.
Currently we are at version 0.3.1 of the software.
Currently we are at version 0.4.0 of the software.
If you'd like the point release (stable) version, run these commands below:
git reset --hard 0.3.1
git reset --hard 0.4.0
cargo build --release
If you want the latest development release, run these commands:

View file

@ -11,10 +11,10 @@
<h2>Latest release and setup</h2>
<p>Clone this repository to get the latest development version.</p>
<p>Currently we are at version 0.3.1 of the software.</p>
<p>Currently we are at version 0.4.0 of the software.</p>
<p>If you'd like the point release (stable) version, run these commands below:</p>
<pre>git reset --hard 0.3.1
<pre>git reset --hard 0.4.0
cargo build --release</pre>

View file

@ -183,9 +183,9 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec<String>) -> St
let coolbeans: Vec<&str> = inputs.split(") begin ").collect();
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
let mut loop_contents = format!("&{}\n{}", loop_name, contents); // Apply loop label and place macro
loop_contents = format!("{}\nJCN ,&execy\nJMP ,&end", loop_contents); // Place conditional jumping
loop_contents = format!("{}\n,&{}end JCN\n,&{}exec JMP\n&{}exec\n", loop_contents, loop_name, loop_name, loop_name); // Place conditional jumping
contents = loop_contents.to_string();
@ -195,8 +195,8 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec<String>) -> St
fn determine_device(line: String) -> String {
let mut device = "";
if line.contains("console") { device = "|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]\n"; }
else if line.contains("system") { device = "|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]\n"; }
if line.contains("system") { device = "|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]\n"; }
else if line.contains("console") { device = "|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]\n"; }
else if line.contains("screen") { device = "|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]\n"; }
else if line.contains("controller") { device = "|80 @Controller [ &vector $2 &button $1 &key $1 ]\n"; }
else if line.contains("mouse") { device = "|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 ]\n"; }
@ -264,13 +264,10 @@ fn parse(code: String) -> String {
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");
let tmac: Vec<&str> = line.split("end!").collect();
blocks[3].push_str(&format!("\n,&{} JMP\n&{}end\n#010f DEO\n", tmac[1], tmac[1]));
} else if line.contains("break!") {
blocks[3].push_str("BRK");
blocks[3].push_str("\nBRK\n");
}
}