This is the custom programming language JsonScript, which is designed with a syntax specified in JSON format. The compiler compiles JsonScript code into WebAssembly for efficient execution.
To experiment with JsonScript there is a small online Editor, try it out here
Examples can be found in the src/LngFiles
Folder.
JsonScript code is structured like a JSON array, where each element represents a language construct. The current syntax supports the following elements:
-
Function Definition:
{ "function<int>": { "functionName": "must be a string, give the Function a name", "parameters": { "parameter1": "<int>", "parameter2": "<float>", "Define as many parameters as you want." }, "code": [ "CodeBlock" ] } }
-
Comments:
{ "comment": "Must be a string. This Code wont be compiled, its just a comment" }
-
Variable Declaration:
{ "declare": { "type": "can be <int> | <float> | <char> | <string>", "scope": "can be public | private", "name": "must be a string", "value": "can be a Literal | CodeBlock | Variable" } }
-
Math Operations:
{ "math": { "left": "can be a Literal | CodeBlock | Variable", "op": " `+` | `-` | `*` | `/` | `==` | `<` | `>` | `&&` ", "right": "can be a Literal | CodeBlock | Variable" } }
-
Assignment:
{ "assign": { "to": "Variable you want to Assign to.", "value": "can be a Literal | CodeBlock | Variable" }
-
While-Loop:
{ "while": { "condition": { "In here you have to provide a `math:` expression (4)"}, "loop": ["Loop requires a Code Block, so here you can use any CodeBlock from above."] } }
-
If-Statements:
{ "Comming Soon :)" }
-
Console Logging:
{ "console" : "can be a Literal | CodeBlock | Variable" }
The compiler takes a valid JsonScript input and generates WebAssembly code for fast execution.
To compile a JsonScript file named example.lng
:
$ jsonscript-compiler example.lng -o output.wasm
This will produce a WebAssembly binary file named output.wasm that can be executed in a compatible runtime.
Nothing, you can just start with the online version, or download the compiler and write some code... happy Coding :)