master
ondra05 2023-10-03 00:16:27 +02:00
parent ade16d8097
commit e0bbb270fd
No known key found for this signature in database
GPG Key ID: 0DA6D2BB2285E881
9 changed files with 39 additions and 6 deletions

View File

@ -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);
}

View File

@ -1 +1,2 @@
// there must only be one main and it ***MUST*** exist
func main(){}

View File

@ -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
}
}

View File

@ -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(){}

View File

@ -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 {}
}

View File

@ -5,5 +5,6 @@ func main() {
match 2 {
1 -> { print("One") }
2 -> { print("Two") }
// If there is not a matching case continue
}
}

View File

@ -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);
}

View File

@ -1,4 +1,5 @@
func random_u64(){
// TODO: randomness
return 3;
var value = 0;
return value;
}

View File

@ -1,5 +1,7 @@
var log = include "log";
// print accepts all types in value
func print(value) {
// TODO: define an api for output
}