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/src/main.js

64 lines
1.2 KiB
JavaScript
Raw Normal View History

class Juicescript {
2022-09-06 14:43:48 +02:00
// TOKEN TYPES //
static token_type = new Enum(
// keywords
"FUN", "GLOBAL",
// literals
"IDENTIFIER", "VARIABLE", "STRING", "NUMBER",
// language constants
"TRUE", "FALSE",
"NULL",
// operators
"NOT",
"EQUAL", "NOT_EQUAL",
"STRICT_EQUAL", "STRICT_NOT_EQUAL",
"GREATER", "GREATER_EQUAL",
"LESS", "LESS_EQUAL"
// meta stuff
"EOF"
);
/*
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";
}
// GET IO ADAPTER //
this.io = new Juicescript_io(this.callback);
}
/*
Parse given PROGRAM-STRING and store syntax tree
*/
parse(program_string){
2022-09-06 13:58:00 +02:00
// DO SCANNING //
// get lexer
var lexer = new Juicescript_lexer(program_string, {
io: this.io
});
2022-09-06 13:58:00 +02:00
// run lexical analysis
var token_list = lexer.scan();
/**/console.log(token_list);
}
}