From 511be2db4e1bbed3845e7a7e6d58cf2779e96eec Mon Sep 17 00:00:00 2001 From: able Date: Thu, 21 Sep 2023 12:42:13 -0500 Subject: [PATCH] meowch --- assets/examples/array.rhea | 7 +++++-- assets/examples/func.rhea | 1 + assets/examples/inline.rhea | 14 +++++++++++--- assets/examples/library.rhea | 3 +++ assets/examples/loops.rhea | 4 ++++ assets/examples/match.rhea | 1 + assets/examples/string.rhea | 10 ++++++++++ assets/libraries/rand/rand.rhea | 3 ++- assets/libraries/std/io.rhea | 2 ++ 9 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 assets/examples/string.rhea diff --git a/assets/examples/array.rhea b/assets/examples/array.rhea index 27dea36..d8b082e 100644 --- a/assets/examples/array.rhea +++ b/assets/examples/array.rhea @@ -2,6 +2,9 @@ var std = include "std"; var print = std.print; func main(){ - var arr = [123, 456, 789]; - print(arr[1]); + // Arrays do exist only tuples packed into a single var + // zero indexed + var arr = (123, 456, 789); + // Print 456 + print(arr.1); } \ No newline at end of file diff --git a/assets/examples/func.rhea b/assets/examples/func.rhea index f183b86..3fa5b7e 100644 --- a/assets/examples/func.rhea +++ b/assets/examples/func.rhea @@ -1 +1,2 @@ +// there must only be one main and it ***MUST*** exist func main(){} \ No newline at end of file diff --git a/assets/examples/inline.rhea b/assets/examples/inline.rhea index d8584ba..84db7c3 100644 --- a/assets/examples/inline.rhea +++ b/assets/examples/inline.rhea @@ -1,10 +1,18 @@ func main() { + var abc = 0; + // an asm block may use variables outside of the asm scope asm { - jmp r0, start - start: - jmp r0, start + li r1, abc } + // This is not really a requirement opcode { 01 } + + // Exit + var exit_status = 0; + asm { + li r255, exit_status + tx + } } \ No newline at end of file diff --git a/assets/examples/library.rhea b/assets/examples/library.rhea index 7786e46..69f7bb1 100644 --- a/assets/examples/library.rhea +++ b/assets/examples/library.rhea @@ -1,3 +1,6 @@ + +// The only thing included here is the ability to pull in other functions +// This is not a * include var std = include "std"; func main(){} \ No newline at end of file diff --git a/assets/examples/loops.rhea b/assets/examples/loops.rhea index ca2167f..54d8bec 100644 --- a/assets/examples/loops.rhea +++ b/assets/examples/loops.rhea @@ -1,11 +1,15 @@ func main(){ var i = 0; + // The only loop is `loop` and it does not do any form of count up and break loop { match i { + // break will break out of `one` loop 10 -> break; } + // Increment by one i = i + 1; } + // This is functionally identical to a HCF loop {} } diff --git a/assets/examples/match.rhea b/assets/examples/match.rhea index 1062754..ec3cca1 100644 --- a/assets/examples/match.rhea +++ b/assets/examples/match.rhea @@ -5,5 +5,6 @@ func main() { match 2 { 1 -> { print("One") } 2 -> { print("Two") } + // If there is not a matching case continue } } \ No newline at end of file diff --git a/assets/examples/string.rhea b/assets/examples/string.rhea new file mode 100644 index 0000000..d9974aa --- /dev/null +++ b/assets/examples/string.rhea @@ -0,0 +1,10 @@ +// This string ***MUST*** never be edited +const b_string = "XYZ"; + +func main() { + var a_string = "ABC"; + // strings may be added together + var fmt = a_string + " length " + a_string.len; + // print may only take one argument + print(fmt); +} \ No newline at end of file diff --git a/assets/libraries/rand/rand.rhea b/assets/libraries/rand/rand.rhea index a516db1..cd1ead7 100644 --- a/assets/libraries/rand/rand.rhea +++ b/assets/libraries/rand/rand.rhea @@ -1,4 +1,5 @@ func random_u64(){ // TODO: randomness - return 3; + var value = 0; + return value; } \ No newline at end of file diff --git a/assets/libraries/std/io.rhea b/assets/libraries/std/io.rhea index 3dc74b6..c47a8c0 100644 --- a/assets/libraries/std/io.rhea +++ b/assets/libraries/std/io.rhea @@ -1,5 +1,7 @@ var log = include "log"; + +// print accepts all types in value func print(value) { // TODO: define an api for output }