diff options
| author | Ben Winston | 2023-05-21 23:50:04 -0400 |
|---|---|---|
| committer | Ben Winston | 2023-05-21 23:50:04 -0400 |
| commit | 03b4987afc5e32ec560fac6f74c153d592f75259 (patch) | |
| tree | ca29375c89260d7678e7b173bd663327170533f5 /main.d | |
| parent | 8e1f84b1369909745859777d07a5e8e74b5df334 (diff) | |
functionsgit add *.d!
Diffstat (limited to 'main.d')
| -rw-r--r-- | main.d | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -1,10 +1,14 @@ import std.stdio; import std.string; +import std.file; +import std.conv; +/* import parser; import dbg; import chunk; import compiler; +*/ import vm; /* @@ -26,18 +30,47 @@ void repl() { continue; } + /* Parser parser = new Parser(input); Compiler compiler = new Compiler(ObjType.SCRIPT, &parser); Function func = compiler.compile(); + */ + /* VM vm = new VM(func); vm.run(); - + */ + interpret(input); } } +string readFile(string fname) { + + File f = File(fname, "r"); + + char[] ret = []; + while (!f.eof()) { + ret = ret ~ f.readln(); + } + f.close(); + return to!string(ret); +} + +int main(string[] args) { + if (args.length <= 1) { + repl(); + } else { + string fname = args[1]; + + if (!exists(fname)) { + writeln("file doesn't exist: ", fname); + return 1; + } + + string data = readFile(fname); -void main() { - repl(); + interpret(data); + } + return 0; } |
