summaryrefslogtreecommitdiff
path: root/example.us
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-04-06 17:04:05 -0400
committeriamcheeseman <[email protected]>2026-04-06 17:06:53 -0400
commit957c64c7b8b5e98d8a03dd84c7e27e7991fb9dbc (patch)
treef5fc230703791cee8d8e7851fb87eaef07ae63a2 /example.us
Initial commit
Diffstat (limited to 'example.us')
-rw-r--r--example.us52
1 files changed, 52 insertions, 0 deletions
diff --git a/example.us b/example.us
new file mode 100644
index 0000000..16bd603
--- /dev/null
+++ b/example.us
@@ -0,0 +1,52 @@
+mod main
+
+# Variables must be snake_case.
+let hello_world = "Hello, world"
+
+# Define a global variable, accessible anywhere. It is put on its own stack.
+global hello_world = "Poggers"
+
+let num = 5
+
+if num % 2 == 0:
+ log.info("fair")
+else:
+ log.info("strange")
+end
+
+loop:
+ # infinite loop
+ break
+end
+
+loop num > 0:
+ # conditional loop
+ if num == 4:
+ num = 3
+ next # equivalent to continue in other languages
+ end
+ num -= 1
+end
+
+let list = [1, 2, 5, 4]
+loop i in list:
+ # iterator loop
+ log.info(i)
+end
+
+fun main:init()
+end
+
+fun sum(a, b)
+ ret a + b
+
+fun print_sum(a, b)
+ let val = sum(a, b)
+ log.info(val)
+end
+
+do:
+ # Standalone scope
+ let a = 1
+ log.info(a)
+end