mooncake

MoonCake Script

A Swift like programming language that compiles to Lua

Github   Gitee

About

MoonCake Script, short in moocscript, is a swift like program language that compiles into Lua. For it's a pure Lua transpiler solution, so it support any environment that Lua support.

If you are using from command line, please visit lalawue/mooncake for more information.

Here examples live in browser, depends on Fengari, a Lua VM written in JavaScript. Other Lua VM requires some modification to the loader.


Examples

Try some language highlight?

You can change these examples's content, all running in your browser !


example 1: guard / continue / switch moocscript



example 2: defer moocscript



example 3: class/struct/extension moocscript



Here comes Fengari's examples, but in moocscript language, renders any interaction with JavaScript and the DOM transparent:


example 4: window.alert() moocscript version moocscript



example 5: change html tag innerHTML with document.title moocscript



example 5: coroutine moocscript



Try with REPL!

This REPL is stolen from Fengari's web-cli.lua, then modified to moocscript's web-cli.mooc.



Getting started

1. first download fengari and moocscript-web:

bash
$ curl -L -O https://github.com/fengari-lua/fengari-web/releases/download/v0.1.4/fengari-web.js
$ curl -L -O https://moocscript.fun/js/moocscript-web-20221204.js

2. then you can include in you webpage

javascript
<script src="fengari-web.js"></script>
<script src="moocscript-web.js"></script>

3. now any script of type "application/mooc" will be running by moocscript-web.js

javascript
<script src="/mooc/hello.mooc" type="application/mooc"></script>

<script type="application/mooc">
    import Core from "moocscript.core"
    import Window from "js" { global }
    Window:alert("moocscript version is \(Core.version())")
</script>


Documents




Compiled Lua