forked from AssembleProgramming/AssembleScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
44 lines (37 loc) · 1.15 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { evaluate } from "./BackEnd/Interpreter/interpreter.ts";
import { setupGlobalScope } from "./BackEnd/Scope/globalScope.ts";
import Parser from "./FrontEnd/Parser.ts";
/**
* @param inputFile : User program
*/
async function __run(inputFile: string) {
const parser = new Parser();
const env = setupGlobalScope();
const input = await Deno.readTextFile(inputFile);
const program = parser.produceAST(input);
evaluate(program, env);
}
__run("./feat.avenger");
/**
* Initializes the script execution.
*/
function __interpret() {
const parser = new Parser();
const env = setupGlobalScope();
// Start the interactive loop
console.log("\n\n$ RunningV0.1");
while (true) {
const input = prompt("🛡️ avengeScript>>> :");
// Check for no user input or exit keyword
if (!input || input.includes("exit")) {
Deno.exit(1);
}
// Parse the input to produce the Abstract Syntax Tree (AST)
const program = parser.produceAST(input);
// console.log(program);
// Evaluate the AST and get the result
evaluate(program, env);
}
}
// Call the initialization function to start the script execution
// __interpret();