GithubHelp home page GithubHelp logo

0x6563 / moderate-code-interpreter Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 215 KB

Moderate Code Interpreter is a basic interpreter that can run in the browser. It input is designed to be easily comprehensible for end-users, allowing them to understand the intended functionality of the code.

TypeScript 46.45% JavaScript 53.55%
business-logic interpreted-programming-language typescript

moderate-code-interpreter's Introduction

Moderate Code Interpreter

Moderate Code Interpreter is a basic interpreter that can run in the browser. It input is designed to be easily comprehensible for end-users, allowing them to understand the intended functionality of the code. Moreover, it is crafted to be straightforward enough for developer-adjacent roles, such as spreadsheet wizards, to swiftly create their own scripts. The grammar is designed with extensibility in mind, by priortizing essential functionality and having a rudimentary aesthetic to writing statements and expressions. Ideally domain-specific syntax could be layered atop of this core language.

Samples

Array Concat

return Merge(["abc"],["def"]);

function Merge(a, b){
    return [123] .. a .. b;
}

Array Push

var a = [];
a += 1 + 2;
a += 3;

Complex Query

var a = query o in orders 
filter all { 
    o.status == "paid"; 
    o.items[?].id == "0120120";
} or all {
    o.status == "pending";
}
list {
    orderId: o.id,
    status: o.status,
    user: query u in users filter o.userId == u.id and u.id within 2 to 3 first u ,
    itemIds: query i in o.items list i.id,
    sum: query o in o.items aggregate (p, c) => p + c.cost,
    ... query o in o.items
        aggregate { 
            stats: {
                sum: (p = 0, c) => p + c.cost,
                qty: (p, c) => p + c.qty,

                a: match {
                    a < 3: "some";
                    b < 3: "else";
                    default: a;
                }
            },
            sum: (p, c) => p + c.cost,
            qty: (p, c) => p + c.qty
        }
}
cluster (orderId, status, user)
sort o.id
segment 0 to 100;

Filter Array Objects

var items = [
   {k: {i: 1}},
   {k: {i: 2}},
   {k: {i: 3}},
   {k: {i: 4}},
   {k: {i: 5}},
   {k: {i: 6}},
   {k: {i: 7}}
];

return query o in items
filter all { 
    o.k.i > 2;
    o.k.i < 5;
}
list o;

Loop Statement

var i = 100000;
while( i > 0 ){
    i -= 1;
}

Multiple Condition Expression

all {
 1 < 2;
 3 /2 < 3;
 4 + 2 > 5;
}

Reference Assignment

var a ={
    b: 2,
    c: {
        d: 3
    }
};

a.c.d = 7;

Simple Math

var a = 3;
var b = 4; 
return a + b;

Variable Declaration

var a = 2;

moderate-code-interpreter's People

Contributors

0x6563 avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.