Add README.md
This commit is contained in:
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -197,9 +197,9 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.52"
|
version = "4.5.53"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa8120877db0e5c011242f96806ce3c94e0737ab8108532a76a3300a01db2ab8"
|
checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@@ -207,9 +207,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.52"
|
version = "4.5.53"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "02576b399397b659c26064fbc92a75fede9d18ffd5f80ca1cd74ddab167016e1"
|
checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
@@ -334,9 +334,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.16.0"
|
version = "0.16.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d"
|
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -346,12 +346,12 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.12.0"
|
version = "2.12.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
|
checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.16.0",
|
"hashbrown 0.16.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1071,18 +1071,18 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.27"
|
version = "0.8.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
|
checksum = "43fa6694ed34d6e57407afbccdeecfa268c470a7d2a5b0cf49ce9fcc345afb90"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.27"
|
version = "0.8.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
|
checksum = "c640b22cd9817fae95be82f0d2f90b11f7605f6c319d16705c459b27ac2cbc26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|||||||
30
README.md
Normal file
30
README.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Stationeers Language (slang)
|
||||||
|
|
||||||
|
This is an ambitious attempt at creating:
|
||||||
|
|
||||||
|
- A new programming language (slang)
|
||||||
|
- A compiler to translate slang -> IC10
|
||||||
|
- A mod to allow direct input of slang in the in-game script editor to
|
||||||
|
automatically compile to IC10 before running
|
||||||
|
|
||||||
|
This project currently outputs 3 files:
|
||||||
|
|
||||||
|
- A Linux CLI
|
||||||
|
- A Windows CLI
|
||||||
|
- A Windows FFI dll
|
||||||
|
- Contains a single function: `compile_from_string`
|
||||||
|
|
||||||
|
The aim of this project is to lower the amount of time it takes to code simple
|
||||||
|
scripts in Stationeers so you can get back to engineering atmospherics or
|
||||||
|
whatever you are working on. This project is NOT meant to fully replace IC10.
|
||||||
|
Obviously hand-coded assembly written by an experienced programmer is more
|
||||||
|
optimized and smaller than something that a C compiler will spit out. This is
|
||||||
|
the same way. It WILL produce valid IC10, but for large complicated projects it
|
||||||
|
might produce over the allowed limit of lines the in-game editor supports.
|
||||||
|
|
||||||
|
Current Unknowns
|
||||||
|
|
||||||
|
- Should I support a configurable script line length in-game to allow larger
|
||||||
|
scripts to be saved?
|
||||||
|
- Should compilation be "behind the scenes" (in game editor will ALWAYS be what
|
||||||
|
you put in. IC10 will be IC10, slang will be slang)
|
||||||
@@ -88,3 +88,85 @@ fn incorrect_args_count() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn inline_literal_args() -> anyhow::Result<()> {
|
||||||
|
let compiled = compile! {
|
||||||
|
debug
|
||||||
|
"
|
||||||
|
fn doSomething(arg1, arg2) {};
|
||||||
|
let thisVariableShouldStayInPlace = 123;
|
||||||
|
let returnedValue = doSomething(12, 34);
|
||||||
|
"
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
compiled,
|
||||||
|
indoc! {
|
||||||
|
"
|
||||||
|
j main
|
||||||
|
doSomething:
|
||||||
|
pop r8 #arg2
|
||||||
|
pop r9 #arg1
|
||||||
|
push ra
|
||||||
|
sub r0 sp 1
|
||||||
|
get ra db r0
|
||||||
|
sub sp sp 1
|
||||||
|
j ra
|
||||||
|
main:
|
||||||
|
move r8 123 #thisVariableShouldStayInPlace
|
||||||
|
push r8
|
||||||
|
push 12
|
||||||
|
push 34
|
||||||
|
jal doSomething
|
||||||
|
sub r0 sp 1
|
||||||
|
get r8 db r0
|
||||||
|
sub sp sp 1
|
||||||
|
move r9 r15 #returnedValue
|
||||||
|
"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mixed_args() -> anyhow::Result<()> {
|
||||||
|
let compiled = compile! {
|
||||||
|
debug
|
||||||
|
"
|
||||||
|
let arg1 = 123;
|
||||||
|
let returnValue = doSomething(arg1, 456);
|
||||||
|
fn doSomething(arg1, arg2) {};
|
||||||
|
"
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
compiled,
|
||||||
|
indoc! {
|
||||||
|
"
|
||||||
|
j main
|
||||||
|
doSomething:
|
||||||
|
pop r8 #arg2
|
||||||
|
pop r9 #arg1
|
||||||
|
push ra
|
||||||
|
sub r0 sp 1
|
||||||
|
get ra db r0
|
||||||
|
sub sp sp 1
|
||||||
|
j ra
|
||||||
|
main:
|
||||||
|
move r8 123 #arg1
|
||||||
|
push r8
|
||||||
|
push r8
|
||||||
|
push 456
|
||||||
|
jal doSomething
|
||||||
|
sub r0 sp 1
|
||||||
|
get r8 db r0
|
||||||
|
sub sp sp 1
|
||||||
|
move r9 r15 #returnValue
|
||||||
|
"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ fn variable_declaration_numeric_literal() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn variable_declaration_numeric_literal_stack_spillover() -> anyhow::Result<()> {
|
fn variable_declaration_numeric_literal_stack_spillover() -> anyhow::Result<()> {
|
||||||
let compiled = compile! {debug r#"
|
let compiled = compile! {
|
||||||
|
debug
|
||||||
|
r#"
|
||||||
let a = 0;
|
let a = 0;
|
||||||
let b = 1;
|
let b = 1;
|
||||||
let c = 2;
|
let c = 2;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ quick_error! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
#[repr(C)]
|
||||||
pub struct CompilerConfig {
|
pub struct CompilerConfig {
|
||||||
pub debug: bool,
|
pub debug: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user