From 97f9a364f3c6e4044f97ed08103e657c9873e17e Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Thu, 19 May 2022 00:05:22 +0530 Subject: [PATCH] try online page added to docs --- docs/README.md | 2 +- docs/tryonline.html | 247 ++++++++++++++++++++++++++++++++++++++++++++ docs/wasm/main.c | 10 +- 3 files changed, 252 insertions(+), 7 deletions(-) create mode 100644 docs/tryonline.html diff --git a/docs/README.md b/docs/README.md index c38385a..3b8fccd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,7 +11,7 @@ which is less than 300KB and the language itself can be compile

- Try Online + Try Online GitHub
diff --git a/docs/tryonline.html b/docs/tryonline.html new file mode 100644 index 0000000..930a1dd --- /dev/null +++ b/docs/tryonline.html @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + Try Online + + + +
+

+

POCKETLANG PLAYGROUND

+
+
+
+
+
+
Run
+
+
+
+
+# Python like import statement. +from lang import clock as now + +# A recursive fibonacci function. +def fib(n) + if n < 2 then return n end + return fib(n-1) + fib(n-2) +end + +# Prints all fibonacci from 0 to 10 exclusive. +for i in 0..10 + print("fib($i) = ${fib(i)}") +end + +
+
+
+
+
...
+
+
+ + + + + + diff --git a/docs/wasm/main.c b/docs/wasm/main.c index b10d0f2..7c43175 100644 --- a/docs/wasm/main.c +++ b/docs/wasm/main.c @@ -11,13 +11,11 @@ extern void js_errorPrint(const char* message); extern void js_writeFunction(const char* message); -void errorPrint(PKVM* vm, const char* message) { - // No need to pass the file (since there is only script that'll ever run on - // the browser. +void stdoutWrite(PKVM* vm, const char* message) { js_errorPrint(message); } -void writeFunction(PKVM* vm, const char* text) { +void stderrWrite(PKVM* vm, const char* text) { js_writeFunction(text); } @@ -25,8 +23,8 @@ EMSCRIPTEN_KEEPALIVE int runSource(const char* source) { PkConfiguration config = pkNewConfiguration(); - config.stderr_write = errorPrint; - config.stdout_write = writeFunction; + config.stderr_write = stderrWrite; + config.stdout_write = stdoutWrite; config.load_script_fn = NULL; config.resolve_path_fn = NULL;