aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/test.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-04 10:07:13 +0200
committerlemon <lsof@mailbox.org>2022-08-04 10:07:13 +0200
commitc5d837d2cd9a57e453da9eaab0e41e0c185e084e (patch)
tree60539ae58df6738772f1e63e2aa58dd8002803e4 /bootstrap/test.cff
parentbb1d4b4a3e51a06fb0530dfc271a97a6cd88cc73 (diff)
fold & more
Diffstat (limited to 'bootstrap/test.cff')
-rw-r--r--bootstrap/test.cff73
1 files changed, 2 insertions, 71 deletions
diff --git a/bootstrap/test.cff b/bootstrap/test.cff
index 61fcbf3..1f426b8 100644
--- a/bootstrap/test.cff
+++ b/bootstrap/test.cff
@@ -1,76 +1,7 @@
-
-defmacro MAX(x, y) [ ((x) < (y) ? (y) : (x)) ]
-
-defmacro fmt(fmt, ...args) [ printf(fmt, args) ]
-defmacro add {
-(x) [ (x) ],
-(x, y, ...rest) [ (x) + add(y, rest) ]
-}
-
-defmacro swap(x, y) [
- (do
- let $x = &(x);
- let $y = &(y);
- let $z = *$x;
- *$x = *$y;
- *$y = $z;)
-]
-
-defmacro map {
-(f, x) [ f(x) ],
-(f, x, ...rest) [ f(x) map(f, rest) ]
-}
-
-defmacro printints_s(x) [ "%d " ## ]
-defmacro printints(...rest) [ printf(map(printints_s, rest) "\n", rest) ]
-
-
-fn fact(x usize) usize {
- fn f(acc usize, n usize) usize {
- return n == 0 ? acc : f(acc * n, n - 1);
- }
- return f(1, x);
-}
-
-defmacro lambda(tys, body) [
- (do
- fn $lam tys body
- &$lam;)
-]
-
-fn counter() int {
- static xs int = 0;
- extern static glob int;
- glob;
- return xs++;
-}
-
-extern static glob int = 42;
+typedef v3f [-(-1 * 2) + -(-8/~~5)]f32;
extern fn main (argc int, argv **u8) void {
extern fn printf(fmt *const u8, ...) int;
- fmt("%d\n", add(1, 2, 3, 4));
-
- let x = 0;
- let y = 7;
- switch y {
- case 0, 1 do
- printf("wow\n");
- case else
- printf("p\n");
- }
- printf("x: %d; y: %d\n", x, y);
- swap(x, y);
- printf("x: %d; y: %d\n", x, y);
- printf("fact(6) = %zu\n", fact(6));
-
- printints(1, 7, 8 + 9, x, x / (++y ^ 2));
- let z = (do
- printf("hi");
- x + 1;);
-
- let fo = lambda((x int) void, {});
-
- return (*fo)(0);
+ return;
}