Get Started
Prerequisite
macOS:
- Install XCode
Linux:
Install
npm install -g lichenscript
Quick Start
Make a new directory, and create a file named main.lc
in it.
Coding in this file:
function main() { print("Hello World"); print("你好世界");}
Execute the command to run:
lsc run ./main.lc
JavaScript
You can use the flag --platform
to tell the compiler
to compile to JavaScript:
lsc run --platform js ./main.lc
WebAssembly
Make sure you have installed Emscripten.
And make sure emcc
is available in your shell.
Execute the command:
lsc run --platform wasm32 ./main.lc
Standalone WebAssembly
By default, the compiler generate the wasm files along with a JavaScript file to load the WebAssembly file.
But if you want to compile LichenScript to a standalone wasm
and load with a runtime, you can use the flag --standalone-wasm
.
For example, if you want use WasmEdge to execute the wasm file, execute the command:
lsc run --platform wasm32 --standalone-wasm wasmedge ./main.lc
A standalone wasm will be generated and the compiler will spawn wasmedge to execute the wasm.
Before you execute this above command, make sure you have install WasmEdge.