Compare commits

..

5 commits

Author SHA1 Message Date
4826485417
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.
2022-02-15 17:20:21 +00:00
a529be1e1f
shits gonna break 2022-02-13 16:52:17 +00:00
42bd852117
one does not simply eat sweets with wrappers on 2022-02-13 16:10:41 +00:00
f8beef16a5
back at it again with the code bro 2022-02-13 16:08:20 +00:00
f4c497e8a4
0.3.1: )!!/ and )../ are now supported. 2022-01-29 17:41:26 +00:00
5 changed files with 83 additions and 10 deletions

2
Cargo.lock generated
View file

@ -120,7 +120,7 @@ dependencies = [
[[package]]
name = "lintc"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"built",
]

View file

@ -1,6 +1,6 @@
[package]
name = "lintc"
version = "0.3.0"
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.0 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.0
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.0 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.0
<pre>git reset --hard 0.4.0
cargo build --release</pre>

View file

@ -97,7 +97,6 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec<String>) -> St
}
if inputs.contains(")/") {
println!("e");
let coolbeans: Vec<&str> = inputs.split(")/").collect();
let mut isin = false;
let mut i: u8 = 0;
@ -122,13 +121,82 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec<String>) -> St
}
contents = contelt.to_string();
}
if inputs.contains(")!!/") {
let coolbeans: Vec<&str> = inputs.split(")!!/").collect();
let mut isin = false;
let mut i: u8 = 0;
for x in vars.to_vec() {
if x == coolbeans[1].to_string() {
isin = true;
}
if isin != true {
i = i + 1;
}
}
if isin != true {
println!("ERROR: Reference to variable {} not assigned.", coolbeans[1]);
process::exit(1);
}
let contunt: Vec<&str> = contents.split("\n").collect();
let mut contelt = "".to_string();
for x in contunt {
if x.len() > 2 {
contelt = format!("{}\n{} .{} STZ",contelt,x,i.to_string());
}
}
contents = contelt.to_string();
}
if inputs.contains(")../") {
let coolbeans: Vec<&str> = inputs.split(")../").collect();
let mut isin = false;
let mut i: u8 = 0;
for x in vars.to_vec() {
if x == coolbeans[1].to_string() {
isin = true;
}
if isin != true {
i = i + 1;
}
}
if isin != true {
println!("ERROR: Reference to variable {} not assigned.", coolbeans[1]);
process::exit(1);
}
let contunt: Vec<&str> = contents.split("\n").collect();
let mut contelt = "".to_string();
for x in contunt {
if x.len() > 2 {
contelt = format!("{}\n{} .{} STZ",contelt,x,i.to_string());
}
}
contents = contelt.to_string();
}
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();
let loop_name = coolbeans.last().unwrap(); // Get loop name
let mut loop_contents = format!("&{}\n{}", loop_name, contents); // Apply loop label and place macro
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();
}
return contents.to_string();
}
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"; }
@ -195,10 +263,15 @@ fn parse(code: String) -> String {
println!("ERROR: Macro set {} not initalised in code.", tmac[0]);
process::exit(1);
}
} else if line.contains("end!") {
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("\nBRK\n");
}
}
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() {