bds.js
Run and simulate string-based BDScript language in JavaScript
Prerequisites
This project requires a JavaScript runtime which supports ES2020 and ESModules.
Changelog v1.1.0
Added / New
- Rewritten code for easy to use
- Reworked
Context
- Reworked
Lexer
- Reworked
Parser
- Added
Evaluator
- Added
Runtime
- Fixed
operator type breaks punctuations
- Readded some utility calls
- Added
$async, $wait, $safejs, $if
Breaking
- Removed
FNHandler
- Removed
Script
- Removed
Nodes
Table of Contents
Installation
Install bds.js with npm:
$ npm install bds.js
or getting releases from github
API & Usage
Example
const lib = require('bds.js');
const runtime = new lib.Runtime();
const input = '$async[$swait $print[Hello world!]] This bottom text is async output!'
const result = runtime.runInput('helloWorld.bds', input);
result.then(output => console.log(output));
Runtime
v1.1 is using Runtime and Evaluator, different from v1.0
This approach is used for the reason; Runtime error and error tracing within code for easier debugging
const runtime = new lib.Runtime();
const input = "$print[Hello World!]";
runtime.runInput('myInput.js', input);
Evaluator
Currently v1.1 use Interpreter system which can impact the performance for large-scale productions.
Later versions to be improved, can also be a change of system.
const input = "> This is the code$print[> Hello World!]"
const lexer = new lib.Lexer(input);
const parser = new lib.Parser();
const Ast = parser.parseToAst(lexer.main() )
const evaluator = lib.Evaluator.singleton
const result = evaluator.evaluate(Ast)
result.then(output => console.log(output))
Goals
MIT License
License can be found here