Skip to content

Muvels/JsonScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

43 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

JsonScript

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.

OIG-removebg

Online Editor

To experiment with JsonScript there is a small online Editor, try it out here
Examples can be found in the src/LngFiles Folder.

JsonScript Syntax

JsonScript code is structured like a JSON array, where each element represents a language construct. The current syntax supports the following elements:

  1. 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" ]
        }
    }
  2. Comments:

    {
        "comment": "Must be a string. This Code wont be compiled, its just a comment"
    }
  3. 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"
        }
    }
  4. Math Operations:

    {
        "math": {
            "left": "can be a Literal | CodeBlock | Variable",
            "op": " `+` | `-` | `*` | `/` | `==` | `<` | `>` | `&&` ",
            "right": "can be a Literal | CodeBlock | Variable"
        }
    }
  5. Assignment:

    {
        "assign": {
            "to": "Variable you want to Assign to.",
            "value": "can be a Literal | CodeBlock | Variable"
    }
  6. 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."]
        }
    }
  7. If-Statements:

    {
        "Comming Soon :)"
    }
  8. Console Logging:

    {
        "console" : "can be a Literal | CodeBlock | Variable"
    }

Compilation Process

The compiler takes a valid JsonScript input and generates WebAssembly code for fast execution.

Example Usage

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.

Dependencies

The compiler relies on the following dependencies:

Nothing, you can just start with the online version, or download the compiler and write some code... happy Coding :)

About

๐Ÿ“‹ A JSON like programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published