diff --git a/.github/workflows/deploy-website.yaml b/.github/workflows/deploy-website.yaml index fac490b..8c200e7 100644 --- a/.github/workflows/deploy-website.yaml +++ b/.github/workflows/deploy-website.yaml @@ -34,7 +34,7 @@ jobs: - uses: actions/upload-artifact@v3 with: name: doc-output - path: doc + path: . retention-days: 1 build-main-doc: needs: build-apidoc-and-demo @@ -46,12 +46,13 @@ jobs: with: name: doc-output - run: ls -al + - run: cd doc && ls -al - run: asciidoctor -r asciidoctor-diagram -D "output" usermanual/index.adoc - - run: cp -R usermanual/img output/img + - run: cp -R usermanual/media output/media - uses: actions/upload-artifact@v3 with: name: doc-output2 - path: . + path: doc retention-days: 1 deploy: needs: build-main-doc diff --git a/README.md b/README.md index 5c0619d..ac0cde7 100644 --- a/README.md +++ b/README.md @@ -58,12 +58,17 @@ val a = (symbolTable.findPropertyByDeclaredName("a") as LongValue).value // 4181 The interpreter is well tested. -![Well tested](./doc/usermanual/img/tests.png) +![Well tested](./doc/usermanual/media/tests.png) ## Demo [Web - Kotlite Interpreter in browser](https://sunny-chung.github.io/kotlite/demo/) +| Android | iOS | +|-----------------------------------------------------|---------------------------------------------| +| ![Android Demo](./doc/usermanual/media/Android.mp4) | ![iOS Demo](./doc/usermanual/media/iOS.mp4) | + + ## Documentation [Documentation site](https://sunny-chung.github.io/kotlite/) diff --git a/doc/generate.sh b/doc/generate.sh index 6b89971..cb9a1c6 100755 --- a/doc/generate.sh +++ b/doc/generate.sh @@ -14,4 +14,4 @@ docker run --rm -it -v "$(pwd)/..:/wd" uwebarthel/asciidoctor asciidoctor \ -r asciidoctor-diagram \ -D "/wd/doc/output" \ /wd/doc/usermanual/index.adoc -cp -R usermanual/img output/img +cp -R usermanual/media output/media diff --git a/doc/usermanual/Demo.adoc b/doc/usermanual/Demo.adoc index 42b33b3..b09d9d6 100644 --- a/doc/usermanual/Demo.adoc +++ b/doc/usermanual/Demo.adoc @@ -1,3 +1,17 @@ = Demo +Their source codes are under https://github.com/sunny-chung/kotlite/tree/main/demo[the demo folder] of the GitHub repository. + +== Web + link:./demo/[JS - An online Kotlite interpreter that runs within your browser] + +video::media/Web.mp4[width=1024] + +== Android + +video::media/Android.mp4[width=480] + +== iOS + +video::media/iOS.mp4[width=480] diff --git a/doc/usermanual/Introduction.adoc b/doc/usermanual/Introduction.adoc index 7488606..3b0ca45 100644 --- a/doc/usermanual/Introduction.adoc +++ b/doc/usermanual/Introduction.adoc @@ -31,7 +31,7 @@ https://github.com/sunny-chung/kotlite/[icon:github[] The Kotlite GitHub Reposit * Well tested -- there are more than a thousand of hand-written unit tests per platform * Can be written in any IDE supporting Kotlin 1.9 -- Kotlite does not create new syntax -image::img/tests.png[] +image::media/tests.png[] CAUTION: To be honest, the standard library is not well tested. Only the language itself is well tested. Please kindly help to report if any issue is found. diff --git a/doc/usermanual/media/Android.mp4 b/doc/usermanual/media/Android.mp4 new file mode 100644 index 0000000..9cc002d Binary files /dev/null and b/doc/usermanual/media/Android.mp4 differ diff --git a/doc/usermanual/media/Web.mp4 b/doc/usermanual/media/Web.mp4 new file mode 100644 index 0000000..bac8283 Binary files /dev/null and b/doc/usermanual/media/Web.mp4 differ diff --git a/doc/usermanual/media/iOS.mp4 b/doc/usermanual/media/iOS.mp4 new file mode 100644 index 0000000..c3aef1c Binary files /dev/null and b/doc/usermanual/media/iOS.mp4 differ diff --git a/doc/usermanual/img/tests.png b/doc/usermanual/media/tests.png similarity index 100% rename from doc/usermanual/img/tests.png rename to doc/usermanual/media/tests.png diff --git a/interpreter/src/commonMain/kotlin/com/sunnychung/lib/multiplatform/kotlite/CodeGenerator.kt b/interpreter/src/commonMain/kotlin/com/sunnychung/lib/multiplatform/kotlite/CodeGenerator.kt index ffa8d70..ae80a89 100644 --- a/interpreter/src/commonMain/kotlin/com/sunnychung/lib/multiplatform/kotlite/CodeGenerator.kt +++ b/interpreter/src/commonMain/kotlin/com/sunnychung/lib/multiplatform/kotlite/CodeGenerator.kt @@ -213,7 +213,7 @@ open class CodeGenerator(protected val node: ASTNode, val isPrintDebugInfo: Bool = nodes.joinToString("") { "${it.generate()}\n" } protected fun FunctionTypeNode.generate(): String - = "(${parameterTypes!!.joinToString(", ") {(it as ASTNode).generate()}}) -> ${(returnType as ASTNode).generate()}" + = "${receiverType?.let { "${(it as ASTNode).generate()}." } ?: ""}(${parameterTypes!!.joinToString(", ") {(it as ASTNode).generate()}}) -> ${(returnType as ASTNode).generate()}" protected fun TypeNode.generate(): String = "$name${arguments?.let { "<${it.joinToString(", ") { (it as ASTNode).generate() }}>" } ?: ""}${if (isNullable) "?" else ""}" diff --git a/stdlib/src/commonTest/kotlin/AllStdLibTest.kt b/stdlib/src/commonTest/kotlin/AllStdLibTest.kt index 1753f72..51a3977 100644 --- a/stdlib/src/commonTest/kotlin/AllStdLibTest.kt +++ b/stdlib/src/commonTest/kotlin/AllStdLibTest.kt @@ -1,6 +1,7 @@ import com.sunnychung.lib.multiplatform.kotlite.KotliteInterpreter import com.sunnychung.lib.multiplatform.kotlite.MermaidFlowchartDirection import com.sunnychung.lib.multiplatform.kotlite.error.SemanticException +import com.sunnychung.lib.multiplatform.kotlite.evalKotliteExpression import com.sunnychung.lib.multiplatform.kotlite.kotliteAstNodeMermaidDiagram import com.sunnychung.lib.multiplatform.kotlite.model.ExecutionEnvironment import com.sunnychung.lib.multiplatform.kotlite.model.IntValue @@ -35,6 +36,19 @@ class AllStdLibTest { assertEquals("Hello world!\n", console.toString()) } + @Test + fun expression() { + val env = ExecutionEnvironment().apply { + install(AllStdLibModules()) + } + val result: IntValue = evalKotliteExpression( + filename = "Calculate", + code = "(1..10).fold(0) { acc, it -> acc + it }", + executionEnvironment = env, + ) as IntValue + assertEquals(55, result.value) + } + @Test fun noMutableListSuccess() { val env = ExecutionEnvironment(