Compare commits
5 commits
f75cabab83
...
4826485417
Author | SHA1 | Date | |
---|---|---|---|
4826485417 | |||
a529be1e1f | |||
42bd852117 | |||
f8beef16a5 | |||
f4c497e8a4 |
5 changed files with 83 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -120,7 +120,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lintc"
|
name = "lintc"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"built",
|
"built",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lintc"
|
name = "lintc"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
|
|
4
README
4
README
|
@ -14,10 +14,10 @@ Latest release and setup
|
||||||
----------------------------
|
----------------------------
|
||||||
Clone this repository to get the latest development version.
|
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:
|
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
|
cargo build --release
|
||||||
|
|
||||||
If you want the latest development release, run these commands:
|
If you want the latest development release, run these commands:
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
<h2>Latest release and setup</h2>
|
<h2>Latest release and setup</h2>
|
||||||
<p>Clone this repository to get the latest development version.</p>
|
<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>
|
<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>
|
cargo build --release</pre>
|
||||||
|
|
||||||
|
|
81
src/main.rs
81
src/main.rs
|
@ -97,7 +97,6 @@ fn load_macro(set: String, mac: String, inputs: String, vars: Vec<String>) -> St
|
||||||
}
|
}
|
||||||
|
|
||||||
if inputs.contains(")/") {
|
if inputs.contains(")/") {
|
||||||
println!("e");
|
|
||||||
let coolbeans: Vec<&str> = inputs.split(")/").collect();
|
let coolbeans: Vec<&str> = inputs.split(")/").collect();
|
||||||
let mut isin = false;
|
let mut isin = false;
|
||||||
let mut i: u8 = 0;
|
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();
|
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();
|
return contents.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn determine_device(line: String) -> String {
|
fn determine_device(line: String) -> String {
|
||||||
let mut device = "";
|
let mut device = "";
|
||||||
if line.contains("console") { device = "|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ]\n"; }
|
if line.contains("system") { device = "|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]\n"; }
|
||||||
else 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("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("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"; }
|
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]);
|
println!("ERROR: Macro set {} not initalised in code.", tmac[0]);
|
||||||
process::exit(1);
|
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() {
|
fn main() {
|
||||||
|
|
Reference in a new issue