summaryrefslogtreecommitdiff
path: root/README.md
blob: 5d0d64aac40aa5e0972362f70cea3a0ee06abcc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# [GOLEM](https://kdx.re/cgit/golem)

Work in progress bytecode language created by and for [kdx](https://kdx.re).

[Follow progress on kdx.re/cgit.](https://kdx.re/cgit/golem)

```golem
// 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.
let g_heap;
let g_another g_one;

main argc argv {
	let hello;
	let world;

	g_heap = 8000;
	hello = (strdup "bonjour");;;
	[hello 6] = 'w';
	world = (strdup "monde");
	(print hello);
	(print " ");
	(print world);

	return 0;
}

alloc size {
	let ptr;

	ptr = g_heap;
	g_heap = (add g_heap size);

	return heap;
}

strdup str {
	let dest;
	let i;

	dest = (alloc (add [str 0] 1));

	i = 0;
	while (lesseq i [str 0]) {
		let smile please;

		[dest i] = [str i];
		i = (add i 1);
	}

	return dest;
}

print str {
	let i;

	i = 1;
	while (lesseq i [str 0]) {
		(putchar [str i]);
		i = (add i 1);
	}

	return 0;
}
```

Copyright (c) 2023 kdx
CC BY-SA 4.0