From 7c5d77e52c5988b7dbd54fdf610006b316ab38e3 Mon Sep 17 00:00:00 2001 From: Johan Sannemo Date: Sun, 20 Sep 2020 12:24:39 +0200 Subject: [PATCH] Spooky readme --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 0ed03be..ed5ab03 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,34 @@ ![Spoooky!](https://github.com/jsannemo/spooky-vm/blob/master/spook.png?raw=true) So spooky. + +## Usage: +``` +java --enable-preview spooky.jar compile source.spooky exec.spook +java --enable-preview spooky.jar run exec.spook +``` + +## Example programs +```scala +extern printInt(i: Int) +extern print(ch: Int) + +func isPrime(n: Int) -> Int { + p: Int = 1; + for (i: Int = 2; i * i <= n; i = i + 1) { + if (n % i == 0) { + return false; + } + } + return true; +} + +func main() { + for (n: Int = 90; n < 100; n = n + 1) { + printInt(n); + print(32); + printInt(isPrime(n)); + print(10); + } +} +```