blob: 0bdc74b181133b34b8ecd7097f16e513290d482b (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import std.stdio;
import std.string;
import parser;
import dbg;
import chunk;
import compiler;
import vm;
/*
import compiler;
import obj;
import dbg;
import chunk;
import vm;
*/
void repl() {
while(true) {
write("> ");
string input = strip(stdin.readln());
if (input.length == 0) {
continue;
}
Parser parser = new Parser(input);
/*
Chunk chunk = new Chunk();
Form f;
while (true) {
f = parser.parseForm();
printForm(f, "");
f.compile(chunk);
if (f.type == FormType.EOF) {
break;
}
}
*/
Compiler compiler = new Compiler(FunctionType.SCRIPT, &parser);
Function func = compiler.compile();
VM vm = new VM(func);
vm.run();
/*
writeln("== disassembling chunk ==");
int off = 0;
while (off < func.chunk.code.length) {
off = disassemble(func.chunk, off);
}
*/
/*
Compiler compiler = new Compiler(lex);
ObjFunction func = compiler.compile();
VM vm = new VM(func);
vm.run();
*/
}
}
void main() {
repl();
}
|