-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
32 lines (27 loc) · 953 Bytes
/
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
import Parser from "./frontend/parser.ts";
import { evaluate } from "./runtime/interpreter.ts";
import Environment from './runtime/environment.ts';
import { NumberValue, RuntimeValue } from './runtime/values.ts';
axle();
function axle() {
console.clear();
const parser = new Parser();
const environment = globalEnvironment();
console.log("Axle v0.1")
while (true) {
const input = prompt("> ");
if (!input || input.includes("exit")) break;
const program = parser.produceAST(input);
const result = evaluate(program, environment);
console.dir(result);
}
}
/**
* Sets up the global environment with some default values
* @returns The global environment
*/
function globalEnvironment(): Environment {
const environment = new Environment();
environment.define("test", { type: "number", value: 5 } as NumberValue);
return environment;
};