5.0.4 • Published 6 years ago

yscript v5.0.4

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
6 years ago

YScript

Simple javascript scripting language

  • Accepts buffer
  • Accepts string
  • Object oriented
  • Safe (neither has it access to actual process nor to commandline/bash)

About

YScript uses regular expressions to search for methods, strings and calculations. Currently it's in development and may have some bugs. If you find one, please open an issue and describe it as good as possible. This “language“ should not be taken serious, it was a fun project and the main reason for doing this, was, to make a language for the tag system in my discord bot Scale.

Usage

To run a YScript using javascript, you create an instance of the module and call load method with either the script buffer or a string with the script as parameter.

const yscript = require("yscript");
const YScript = new yscript.YScript();
YScript.load(`
DEF myVariable = "helloooo"
print(myVariable)
`);
console.log(YScript.run()); // ['"helloooo"']

To run the script, call run method on your YScript instance.

Make sure YScript._buffer is not null, otherwise it'll throw an error. This probably wont be a problem if you call load method before running the script.

Contributing

You want to contribute to this project? Do so, i thank everyone for every single line that has been written. To get a merged pr, follow these guidelines:

  1. Fork
  2. Use good and precise commit names/descriptions (shitty code fix is not really good)
  3. Pull request with an accurate description as well (Changes, Additions, Deletions)
  4. Keep it object-oriented (use ES6' classes)!

Calculations

YScript is able to calculate as well. You can store calculations in either a definition or immediately print it using the print() method.

Definitions

In YScript you mustn't define the datatype, it detects it automatically.

Syntax

DEF name = value

Example

DEF pi = 3.14159265358979

print Method

The print() Method outputs a given string, number, calculation or definition.

Syntax

print(value)

Example

DEF pi = 3.14159265358979
print("Pi is: ")
print(pi)

run() Method of YScript class gives an array of printings. The array has a size of 5 if the script has 5 print() Methods in it.