diff options
author | Minteck <contact@minteck.org> | 2022-12-04 12:04:51 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-12-04 12:04:51 +0100 |
commit | fb9d431c9d082f02d3d1344f0ef6576513cae807 (patch) | |
tree | 894f5134a9bfeac37e090a656124e123e93cc8d2 | |
parent | 4f2021c1597e82c24df51ea756e81fa62f9993eb (diff) | |
download | wing-fb9d431c9d082f02d3d1344f0ef6576513cae807.tar.gz wing-fb9d431c9d082f02d3d1344f0ef6576513cae807.tar.bz2 wing-fb9d431c9d082f02d3d1344f0ef6576513cae807.zip |
Remove old JS code
-rw-r--r-- | index-old.js | 741 |
1 files changed, 0 insertions, 741 deletions
diff --git a/index-old.js b/index-old.js deleted file mode 100644 index 5ccad7c..0000000 --- a/index-old.js +++ /dev/null @@ -1,741 +0,0 @@ -const fs = require('fs'); -const chalk = require('chalk'); -const path = require('path'); -global._debug = false; -global.version = "next"; - -global.linterOutput = { - problems: [], - variables: [], - constants: [], - functions: [], - operations: [], - conditions: [] -} - -let params = process.argv.filter(i => i.startsWith("--")).map(i => i.substring(2)); -process.argv = process.argv.filter(i => !i.startsWith("--")); - -global.linter = params.includes("lint"); -global.wingRoot = __dirname; - -let file, filename; - -if (params.includes("version")) { - process.stdout.write(version); - process.exit(); -} - -if (params.includes("path")) { - process.stdout.write(__dirname); - process.exit(); -} - -if (params.includes("debug")) { - global._debug = true; -} - -if (params.includes("base64")) { - if (!process.argv[2]) { - console.error("No code specified"); - return; - } - - filename = "_internal"; - file = Buffer.from(process.argv[2], "base64").toString(); -} else { - if (!process.argv[2]) { - console.error("Usage: " + process.argv.join(" ") + " <file>"); - process.exit(2); - } - - if (!fs.existsSync(process.argv[2])) { - console.error(process.argv[2] + ": no such file or directory"); - process.exit(2); - } - - filename = path.resolve(process.argv[2]); - - try { - file = fs.readFileSync(process.argv[2]).toString(); - } catch (e) { - console.error(process.argv[2] + ": read error: " + e.message); - process.exit(2); - } -} - -global.variables = {}; -global.functions = {}; -global.conditions = {}; -global.operators = {}; -global.constants = []; -global.modules = {}; - -global.WingAPI = { - createFunction: (name, parameter, runtime) => { - functions[name] = { - parameter, - runtime - } - }, - createCondition: (name, parameters, runtime) => { - conditions[name] = { - parameters, - runtime - } - }, - createOperator: (name, parameters, runtime) => { - operators[name] = { - parameters, - runtime - } - } -} - -require("./sources.js"); - -let lines = file.replaceAll("\r\n", "\n").split("\n"); - -let contexts = []; - -interpret(lines, undefined, null, filename); - -function evaluateCondition(condition, variables, functions, contexts, index, globalLines, currentFunction, lines, file) { - let argv = condition.split(" "); - let name = argv[0]; - argv.shift(); let params = argv; - - let line = index; - - if (conditions[name]) { - for (let index in conditions[name]["parameters"]) { - let parameter = conditions[name]["parameters"][index]; - let local = params[index]; - - if (params[index]) { - switch (parameter.type) { - case "variable": - if (local.match(/^\$([a-zA-Z0-9-_]+)$/gm)) { - params[index] = params[index].substring(1); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_CONDITION_SYNTAX"); - return false; - } - - break; - - case "variables": - let vars = params; - - for (let i; i < index; i++) { - vars.shift(); - } - - for (let i in vars) { - let v = vars[i]; - - if (v.match(/^\$([a-zA-Z0-9-_]+)$/gm)) { - params[index + i] = params[index + i].substring(1); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_CONDITION_SYNTAX"); - return false; - } - } - - break; - - case "number": - if (!isNaN(parseFloat(local)) && isFinite(local)) { - params[index] = parseFloat(local); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_CONDITION_SYNTAX"); - return false; - } - - break; - - case "values": - if (parameter.values.includes(local)) { - params[index] = local; - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_CONDITION_SYNTAX"); - return false; - } - - break; - - default: - throw new Error("Invalid condition parameter type"); - } - } else { - error("Missing parameter for condition " + name, line, globalLines, currentFunction, lines, file, "ERR_MISSING_CONDITION_PARAM"); - return false; - } - } - - if (linter) { - return true; - } else { - return conditions[name]["runtime"](params); - } - } else { - error("Unresolved reference (condition " + name + ")", line, globalLines, currentFunction, lines, file, "ERR_CONDITION_NOENT"); - return false; - } -} - -global.strictMode = false; - -function error(text, line, globalLine, currentFunction, lines, filename, code) { - if (global.strictMode) { - message("red", true, text, line, globalLine, currentFunction, lines, filename, code); - process.exit(2); - } else { - message("yellow", true, text, line, globalLine, currentFunction, lines, filename, code); - } -} - -function crash(text, line, globalLine, currentFunction, lines, filename, code) { - message("red", true, text, line, globalLine, currentFunction, lines, filename, code); - if (!linter) process.exit(2); -} - -function deprecation(text, line, globalLine, currentFunction, lines, filename, code) { - message("cyan", false, text, line, globalLine, currentFunction, lines, filename, code); -} - -function message(color, showTrace, text, line, globalLine, currentFunction, lines, filename, code) { - if (linter) { - let type = "unknown"; - - switch (color) { - case "red": - type = "error"; - break; - - case "yellow": - type = "warning"; - break; - - case "cyan": - type = "deprecation"; - break; - } - - let actualLine = 1; - - if (line === globalLine) { - actualLine = line; - } else { - actualLine = globalLine + 1; - } - - let source = { - uri: "_self", - name: "_main", - line: actualLine - } - - if (currentFunction) { - source.name = currentFunction; - } - - linterOutput.problems.push({ - type, - message: text, - code, - line: actualLine, - source - }); - } else { - if (showTrace) console.log(chalk.gray("------------------------------------------------------------------------")); - - let type = chalk.white.bgWhiteBright.inverse("Message:"); - - switch (color) { - case "red": - type = chalk.redBright.bgWhiteBright.inverse("Error:"); - break; - - case "yellow": - type = chalk.yellowBright.bgWhiteBright.inverse("Warning:"); - break; - - case "cyan": - type = chalk.cyanBright.bgWhiteBright.inverse("Deprecation:"); - break; - } - - if (line === globalLine) { - if (showTrace) { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + "\n * at line " + chalk.magenta(line) + "\n * in file " + chalk.magenta(filename))); - } else { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + " (line " + chalk.magenta(line) + " in " + chalk.magenta(filename) + ")")); - } - } else { - if (currentFunction) { - if (showTrace) { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + "\n * at local line " + chalk.magenta(line) + ", global line " + chalk.magenta(globalLine + 1) + "\n * in function " + chalk.magenta(currentFunction) + "\n * in file " + chalk.magenta(filename))); - } else { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + " (line " + chalk.magenta(globalLine + 1) + " in " + chalk.magenta(filename) + ")")); - } - } else { - if (showTrace) { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + "\n * at local line " + chalk.magenta(line) + ", global line " + chalk.magenta(globalLine + 1) + "\n * in file " + chalk.magenta(filename))); - } else { - console.error(chalk.blueBright.bgWhiteBright.inverse("Wing:") + " " + type + " " + chalk[color]("[" + code + "] " + text + " (line " + chalk.magenta(globalLine + 1) + " in " + chalk.magenta(filename) + ")")); - } - } - - if (currentFunction) { - globalLine++; - } - } - - if (showTrace) { - let lns = [(globalLine - 1).toString().length, globalLine.toString().length, (globalLine + 1).toString().length].reduce((a, b) => a.length > b.length ? a : b, '').length; - - console.log(""); - - if (lines[line - 2] || typeof lines[line - 2] === "string") { - let lnp = " ".repeat(lns - (globalLine - 1).toString().length) + (globalLine - 1).toString(); - console.log(" " + chalk.gray(lnp + " ") + chalk.gray(lines[line - 2])); - } - - console.log(chalk.blueBright.bold(">") + " " + chalk.gray(globalLine + " ") + lines[line - 1]); - - if (lines[line] || typeof lines[line] === "string") { - let lnn = " ".repeat(lns - (globalLine + 1).toString().length) + (globalLine + 1).toString(); - console.log(" " + chalk.gray(lnn + " ") + chalk.gray(lines[line])); - } - - console.log(chalk.gray("------------------------------------------------------------------------")); - } - } -} - -function evaluateOperation(variable, operation, variables, functions, contexts, index, globalLines, currentFunction, lines, file) { - let argv = operation.split(" "); - let name = argv[0]; - argv.shift(); let params = argv; - - let line = index; - - if (operators[name]) { - for (let index in operators[name]["parameters"]) { - index = parseInt(index); - let parameter = operators[name]["parameters"][index]; - let local = params[index]; - - if (params[index]) { - switch (parameter.type) { - case "variable": - if (local.match(/^\$([a-zA-Z0-9-_]+)$/gm)) { - params[index] = params[index].substring(1); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_OPERATOR_SYNTAX"); - return false; - } - - break; - - case "variables": - let vars = params; - - for (let i; i < index; i++) { - vars.shift(); - } - - for (let i in vars) { - i = parseInt(i); - let v = vars[i]; - - if (v.match(/^\$([a-zA-Z0-9-_]+)$/gm)) { - params[index + i] = params[index + i].substring(1); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_OPERATOR_SYNTAX"); - return false; - } - } - - break; - - case "number": - if (!isNaN(parseFloat(local)) && isFinite(local)) { - params[index] = parseFloat(local); - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_OPERATOR_SYNTAX"); - return false; - } - - break; - - case "values": - if (parameter.values.includes(local)) { - params[index] = local; - } else { - error("Syntax error", line, globalLines, currentFunction, lines, file, "ERR_OPERATOR_SYNTAX"); - return false; - } - - break; - - default: - throw new Error("Invalid operator parameter type"); - } - } else { - error("Missing parameter for operator " + name, line, globalLines, currentFunction, lines, file, "ERR_MISSING_OPERATOR_PARAM"); - return false; - } - } - - if (!linter) { - variables[variable] = operators[name]["runtime"](params); - } else { - variables[variable] = "-"; - } - } else { - error("Unresolved reference (operator " + name + ")", line, globalLines, currentFunction, lines, file, "ERR_OPERATOR_NOENT"); - return false; - } -} - -function interpret(lines, globalLines, currentFunction, file) { - let count = lines.length; - lines = lines.map(i => i.trim()); - let stripped = count - lines.length; - - let index = 1; - - if (!globalLines) { - globalLines = stripped + 1; - index = globalLines; - } - - for (let line of lines) { - try { - let currentContext = contexts[contexts.length - 1]; - - line = !line.trim().startsWith("--") ? line.split("--")[0] : line; - if (_debug) console.log("--> " + index + "; " + globalLines); - if (_debug) console.log("--> " + line); - if (_debug) console.log("--> " + JSON.stringify(variables)); - if (_debug) console.log("-->", contexts); - - if (line.match(/^if (.+) do$/m)) { - if (currentContext && currentContext.type === "function") { - functions[currentContext.target] += line + "\n"; - contexts.push(currentContext); - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else { - let condition = /^if (.+) do$/m.exec(line)[1]; - - if (!evaluateCondition(condition, variables, functions, contexts, index, globalLines, currentFunction, lines, file)) { - contexts.push({ - type: "unmatched", - target: null - }); - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else { - contexts.push({ - type: "condition", - target: null - }); - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } - } - } else if (line === "else do") { - if (currentContext && currentContext.type === "function") { - functions[currentContext.target] += line + "\n"; - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else { - if (currentContext && currentContext.type === "condition") { - contexts.pop(); - contexts.push({ - type: "unmatched", - target: null - }); - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else if ((currentContext && currentContext.type === "unmatched") || linter) { - contexts.pop(); - contexts.push({ - type: "condition", - target: null - }); - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else { - error("Attempted to use 'else' while not in a condition context", index, globalLines, currentFunction, lines, file, "ERR_ELSE_NOTIF"); - } - } - } - - if (line === "end") { - if (contexts.length > 0) { - if (currentContext && currentContext.type === "function") { - if (contexts.length > 1) functions[currentContext.target] += line + "\n"; - } - - contexts.pop(); - } else { - error("Attempted to leave primary context", index, globalLines, currentFunction, lines, file, "ERR_END_PRIMARY"); - } - - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } - - if (currentContext && currentContext.type === "function") { - functions[currentContext.target] += line + "\n"; - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } - - if (currentContext && currentContext.type === "unmatched") { - index++; globalLines++; - if (_debug) console.log("-------------------"); - continue; - } - - if (line.trim() === "" || line.trim().startsWith("--") || line.trim().startsWith("#!")) { - index++; - globalLines++; - if (_debug) console.log("-------------------"); - continue; - } else if (line.match(/^\$([a-zA-Z0-9-_]+) *< *(.*)$/gm)) { - let name = /\$([a-zA-Z0-9-_]+) *< *(.*)/gm.exec(line)[1]; - let operation = /\$([a-zA-Z0-9-_]+) *< *(.*)/gm.exec(line)[2]; - if (constants.includes(name)) { - error("Attempted to run operation on constant " + name, index, globalLines, currentFunction, lines, file, "ERR_OPERATOR_CONST"); - } else { - evaluateOperation(name, operation, variables, functions, contexts, index, globalLines, currentFunction, lines, file); - } - } else if (line.match(/^\$([a-zA-Z0-9-_]+)(!|) *= *(.*)$/gm)) { - let name = /\$([a-zA-Z0-9-_]+)(!|) *= *(.*)/gm.exec(line)[1]; - - if (constants.includes(name)) { - error("Attempted to reassign constant " + name, index, globalLines, currentFunction, lines, file, "ERR_CONST_ASSIGN"); - } else { - if (line.match(/^\$([a-zA-Z0-9-_]+)! *= *(.*)$/gm)) constants.push(name); - - let assignment = /\$([a-zA-Z0-9-_]+)(!|) *= *(.*)/gm.exec(line)[3]; - let execute = true; - - while (assignment.match(/\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m)) { - let vars = /\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m.exec(assignment); - let name = vars[1]; - - if (!Object.keys(variables).includes(name)) { - error("Unresolved reference ($" + name + ")", index, globalLines, currentFunction, lines, file, "ERR_VARIABLE_NOENT"); - execute = false; - break; - } - - assignment = assignment.replace(/\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m, variables[name]); - } - - if (execute) variables[name] = assignment; - } - } else if (line.match(/^function ([a-zA-Z0-9-_]+)( (\$([a-zA-Z0-9-_]+))*)?$/m)) { - let match = /^function ([a-zA-Z0-9-_]+)( (\$([a-zA-Z0-9-_]+))*)?$/m.exec(line); - let name = match[1]; - let parameter = match[4]; - contexts.push({ - type: "function", - target: name - }); - - if (parameter) { - functions[name] = "@@$" + parameter + "\n@@" + index + "\n"; - } else { - functions[name] = "@@\n@@" + index + "\n"; - } - } else if (line.match(/^([a-zA-Z0-9-_]+)( (.*)|)$/gm)) { - let execute = true; - let func = /([a-zA-Z0-9-_]+)( (.*)|)/gm.exec(line)[1]; - let parameters = /([a-zA-Z0-9-_]+)( (.*)|)/gm.exec(line)[3]; - - if (!Object.keys(functions).includes(func)) { - error("Unresolved reference (function " + func + ")", index, globalLines, currentFunction, lines, file, "ERR_FUNCTION_NOENT"); - } - - if (parameters) { - while (parameters.match(/\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m)) { - let vars = /\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m.exec(parameters); - let name = vars[1]; - - if (!Object.keys(variables).includes(name)) { - error("Unresolved reference ($" + name + ")", index, globalLines, currentFunction, lines, file, "ERR_VARIABLE_NOENT"); - execute = false; - break; - } - - parameters = parameters.replace(/\w*(?<!\\)\$([a-zA-Z0-9-_]+)/m, variables[name]); - } - - parameters = parameters.replaceAll("\\$", "$"); - } - - if (execute) { - if (typeof functions[func] === "object") { - if (functions[func]["parameter"] && !parameters) { - error("Missing parameter for function " + func, index, globalLines, currentFunction, lines, file, "ERR_MISSING_FUNCTION_PARAM"); - } else if (!functions[func]["parameter"] && parameters) { - error("Function " + func + " does not admit a parameter", index, globalLines, currentFunction, lines, file, "ERR_FUNCTION_PARAM"); - } - - if (!linter) { - functions[func]["runtime"](parameters, variables, functions, contexts, index, globalLines, currentFunction, lines, file); - } - } else if (typeof functions[func] === "string") { - let lines = functions[func].split("\n"); - let initialIndex = parseInt(lines[1].substring(2)); - - if (parameters && lines[0].startsWith("@@$")) { - let parameter = lines[0].substring(3); - variables[parameter] = parameters; - - lines.shift(); - lines.shift(); - interpret(lines, initialIndex, func, file); - } else if (parameters) { - error("Function " + func + " does not admit a parameter", index, globalLines, currentFunction, lines, file, "ERR_FUNCTION_PARAM"); - } else if (lines[0].startsWith("@@$")) { - error("Missing parameter for function " + func, index, globalLines, currentFunction, lines, file, "ERR_MISSING_FUNCTION_PARAM"); - } else { - lines.shift(); - lines.shift(); - interpret(lines, initialIndex, func, file); - } - } - } - } else if (line.startsWith("#include ") || line.startsWith("#require ")) { - let fatal = line.startsWith("#require "); - process.chdir(path.dirname(file)); - - if (currentFunction) { - if (fatal) { - crash("Attempted to require from a function context", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_FUNCTION"); - } else { - error("Attempted to include from a function context", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_FUNCTION"); - } - - index++; - globalLines++; - continue; - } - - let importFile = line.substring(9); - - if (line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm)) { - importFile = wingRoot + "/modules/" + /^#(include|require) <([a-zA-Z0-9-_]+)>$/gm.exec(line)[2] + ".wjs"; - } else if (line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm)) { - importFile = wingRoot + "/modules/" + /^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm.exec(line)[2] + ".wjs"; - } - - if (!fs.existsSync(importFile) && !line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm) && !line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm)) { - if (fatal) { - crash("Required file " + importFile + " not found", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_NOENT"); - } else { - error("Included file " + importFile + " not found", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_NOENT"); - } - - index++; globalLines++; continue; - } else if (line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm)) { - if (!Object.keys(modules).includes(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm.exec(line)[2])) { - if (fatal) { - crash("Required internal module " + /^#(include|require) <([a-zA-Z0-9-_]+)>$/gm.exec(line)[2] + " not found", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_NOENT"); - } else { - error("Included internal module " + /^#(include|require) <([a-zA-Z0-9-_]+)>$/gm.exec(line)[2] + " not found", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_NOENT"); - } - } - } else if (line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm)) { - if (!Object.keys(modules).includes(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm.exec(line)[2])) { - if (fatal) { - crash("Required internal module " + /^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm.exec(line)[2] + " not found", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_NOENT"); - } else { - error("Included internal module " + /^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm.exec(line)[2] + " not found", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_NOENT"); - } - } - } - - if (!line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm) && !line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm)) { - try { - let _text = fs.readFileSync(importFile).toString(); - } catch (e) { - if (fatal) { - crash("Required file " + importFile + " is unreadable", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_READ"); - } else { - error("Included file " + importFile + " is unreadable", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_READ"); - } - - index++; - globalLines++; - continue; - } - } - - let ext = path.extname(importFile); - - if (ext === ".wjs") { - if (!linter || line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm) || line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm)) { - if (line.match(/^#(include|require) <([a-zA-Z0-9-_]+)>$/gm) || line.match(/^#(include|require) wing:([a-zA-Z0-9-_]+)$/gm)) { - eval(modules[importFile]); - } else { - eval(fs.readFileSync(importFile).toString()); - } - } - } else if (ext === ".wing") { - interpret(fs.readFileSync(importFile).toString().replaceAll("\r\n", "\n").split("\n"), undefined, null, importFile); - } else { - if (fatal) { - crash("Required file " + importFile + " is neither of Wing JS Binding file (.wjs) or Wing Source file (.wing)", index, globalLines, currentFunction, lines, file, "ERR_REQUIRE_INVALID"); - } else { - error("Included file " + importFile + " is neither of Wing JS Binding file (.wjs) or Wing Source file (.wing)", index, globalLines, currentFunction, lines, file, "ERR_INCLUDE_INVALID"); - } - } - } else if (line === "#strict") { - global.strictMode = true; - } else if (line.startsWith("?!")) { - deprecation(line.substring(2).trim(), index, globalLines, currentFunction, lines, file, "ERR_CUSTOM_DEPRECATION"); - } else if (line.startsWith("??")) { - crash(line.substring(2).trim(), index, globalLines, currentFunction, lines, file, "ERR_CUSTOM_ERROR"); - } else if (line.startsWith("?")) { - error(line.substring(1).trim(), index, globalLines, currentFunction, lines, file, "ERR_CUSTOM_WANING"); - } else { - error("Syntax error", index, globalLines, currentFunction, lines, file, "ERR_SYNTAX_GENERAL"); - } - - index++; globalLines++; - if (_debug) console.log("-------------------"); - } catch (e) { - if (_debug) console.error(e); - crash("Internal system error: " + e.message, index, globalLines, currentFunction, lines, file, "ERR_INTERNAL"); - index++; globalLines++; - if (_debug) console.log("-------------------"); - } - } -} - -if (linter) { - linterOutput["variables"] = Object.keys(variables).filter(i => !constants.includes(i)); - linterOutput["constants"] = constants; - linterOutput["functions"] = Object.keys(functions); - linterOutput["operations"] = Object.keys(operators); - linterOutput["conditions"] = Object.keys(conditions); - - process.stdout.write(JSON.stringify(linterOutput)); -}
\ No newline at end of file |