1.0.3 • Published 6 years ago

simp.compiler v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Simp

Simp is a JavaScript compiler that aims to simplify the language and add a few utilities.

Installation

npm install simp.compiler

Compiling Simp code

const simp = require('simp');

// To compile Simp code, use the compile() function.
console.log(simp.compile(`
let test = 0

func increment(int) {
    def int: 0
    ret int++;
}

test = increment(test);
`));

Compiled output:

var test = 0

function increment(int) {
    if (!int) int = 0
    return int++;
}

test = increment(test);

Features

Those are the features of the Simp compiler.

Aliases

Simp adds a few aliases to your usual JS code, to make coding faster.

BeforeAfterDescription
letvarbackported from ES6
funcfunction-
retreturnfor non-void returns
ret.returnfor void returns

Loop shortcuts

If you want to quickly create a loop without all of those pesky semicolons, Simp is gonna help you out.

BeforeAfterDescription
index: min..maxvar index = min; index < max; index++Forward loop
index: min..<maxvar index = max - 1; index >= min; index--Backwards loop

Arrow functions

A backport of the ES6 feature, but with a Java style arrow.

BeforeAfter
(args) -> { /* function */ }function(args) { /* function */ }

Random shorthands

When you want to generate a random number, or execute something with a specific chance, Simp has shorthands that can help out.

BeforeAfter
? min-maxmin + Math.random() * (max - min)
? chance%Math.random() * 100 < chance

Function utilities

Just some function utilities, to make your code more beautiful.

BeforeAfterDescription
def var: valif (!var) var = valDefault value, a less complex backport of an ES6 feature
object::getterobject.get('getter')Useful when embedding JS into apps
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago