diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-09-25 00:04:18 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2022-09-25 00:04:18 +0200 |
commit | 7b76c697bd9f733aa242e12a01df4dc3a065a9e0 (patch) | |
tree | 3392f82f7a338dd0b8a447428b7a0bb00cee6a75 /ks | |
parent | da91cbbd5bb8cb925dee4a5c6ab6d66588cb2c8f (diff) | |
download | llvm-kaleidoscope-rs-7b76c697bd9f733aa242e12a01df4dc3a065a9e0.tar.gz llvm-kaleidoscope-rs-7b76c697bd9f733aa242e12a01df4dc3a065a9e0.zip |
allow to run program from file, add ch5 example programs
Diffstat (limited to 'ks')
-rw-r--r-- | ks/forloop.ks | 7 | ||||
-rw-r--r-- | ks/ifelse.ks | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ks/forloop.ks b/ks/forloop.ks new file mode 100644 index 0000000..0efa5c3 --- /dev/null +++ b/ks/forloop.ks @@ -0,0 +1,7 @@ +extern putchard(char); +def printstar(n) + for i = 1, i < n, 1.0 in + putchard(42); # ascii 42 = '*' + +# print 100 '*' characters +printstar(100); diff --git a/ks/ifelse.ks b/ks/ifelse.ks new file mode 100644 index 0000000..3aa4778 --- /dev/null +++ b/ks/ifelse.ks @@ -0,0 +1,7 @@ +def fib(x) + if x < 3 then + 1 + else + fib(x-1)+fib(x-2); + +fib(10); |