0
0
This repository has been archived on 2024-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
legacy-code/juicescript.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-09-01 19:05:37 +02:00
/*! Juicescript.js v1.0.0-a | (c) DrMaxNix 2022 | juice.drmaxnix.de */
2022-09-01 17:45:31 +02:00
class Juicescript {
/*
CONSTRUCTOR: Return new juicescript parser with OPTIONS
*/
constructor(options){
// STORE CALLBACKS //
// save
if(options.callback !== undefined){
this.callback = options.callback;
}
// check if all have been set
if(!(this.callback.stdout instanceof Function)){
throw "invalid stdout callback";
}
if(!(this.callback.stderr instanceof Function)){
throw "invalid stderr callback";
}
}
2022-09-01 19:31:19 +02:00
/*
Parse given PROGRAM-STRING and store syntax tree
*/
parse(program_string){
// DEVIDE INTO LINES //
var line_list = program_string.split("\n");
/**/console.log(line_list);
}
2022-09-01 17:45:31 +02:00
2022-09-01 19:31:19 +02:00
// DEBUG STUFFS //
2022-09-01 17:45:31 +02:00
run(){
2022-09-01 19:31:19 +02:00
//this.io_stdout("stdout text");
//this.io_stderr_debug("This debug is a test");
//this.io_stderr_info("This info is a test");
//this.io_stderr_warning("This warning is a test");
//this.io_stderr_error("This error is a test");
2022-09-01 17:45:31 +02:00
}
io_stdout(text){
this.callback.stdout(text);
}
io_stderr_debug(text){
this.callback.stderr("[DEBUG] " + text, "debug");
}
io_stderr_info(text){
this.callback.stderr("[INFO ] " + text, "info");
}
io_stderr_warning(text){
this.callback.stderr("[WARN ] " + text, "warning");
}
io_stderr_error(text){
this.callback.stderr("[ERROR] " + text, "error");
}
}