summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kdx@42l.fr>2023-03-13 23:39:52 +0100
committerkdx <kdx@42l.fr>2023-03-13 23:39:52 +0100
commit3c2abb64ad8a43e453a3388cec18728d1dd36254 (patch)
treec6188a0550ed59fa0b6a451c530d5af565483def
parentf9970f97f46314440c6bf2e705ac09c018b1df4a (diff)
downloadgolem-3c2abb64ad8a43e453a3388cec18728d1dd36254.tar.gz
create mvp.golem
-rw-r--r--mvp.golem56
1 files changed, 56 insertions, 0 deletions
diff --git a/mvp.golem b/mvp.golem
new file mode 100644
index 0000000..90e1b15
--- /dev/null
+++ b/mvp.golem
@@ -0,0 +1,56 @@
+// Focus is on having a simple toolchain to build onto.
+// For this reason, MVP syntax should stay as simple as possible.
+// The weird mixture of C and Lisp is a feature, I swear.
+
+// Global scope is initialized to zero.
+global g_heap;
+
+main(argc argv) {
+ local hello;
+ local world;
+
+ g_heap = 8000;
+ hello = (strdup "bonjour");
+ world = (strdup "monde");
+ (print hello);
+ (print " ");
+ (print world);
+
+ return 0;
+}
+
+alloc(size) {
+ local ptr;
+
+ ptr = g_heap;
+ g_heap = (+ g_heap size);
+
+ return heap;
+}
+
+strdup(str) {
+ local dest;
+ local i;
+
+ dest = (alloc (+ [str 0] 1));
+
+ i = 0;
+ while (<= i [str 0]) {
+ [dest i] = [str i];
+ i = (+ i 1);
+ }
+
+ return dest;
+}
+
+print(str) {
+ local i;
+
+ i = 1;
+ while (<= i [str 0]) {
+ (putchar [str i]);
+ i = i + 1;
+ }
+
+ return 0;
+}