-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
38 lines (30 loc) · 1.04 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
import Parser from './frontend/parser.ts'
import {evaluate} from './runtime/interpreter.ts'
import Environment from "./runtime/environments.ts"
import { createGlobalEnv } from './runtime/environments.ts';
// repl()
run("./test.txt")
async function run(filename: string){
const parser = new Parser()
const env = createGlobalEnv()
const input = await Deno.readTextFile(filename)
const program = parser.produceAST(input)
const result = evaluate(program, env)
// console.log(result)
}
// async function repl() {
// const parser = new Parser()
// const env = createGlobalEnv()
// console.log("\nRepl v0.1");
// while (true) {
// const input = prompt(">> ")
// //check for no user input or exit keyword
// if (!input || input.includes("exit")) {
// Deno.exit(1);
// }
// //produce AST from the source code
// const program = parser.produceAST(input)
// const result = evaluate(program, env)
// // console.log(result)
// }
// }