aboutsummaryrefslogtreecommitdiff
path: root/main.d
diff options
context:
space:
mode:
authorBen Winston2023-05-21 23:50:04 -0400
committerBen Winston2023-05-21 23:50:04 -0400
commit03b4987afc5e32ec560fac6f74c153d592f75259 (patch)
treeca29375c89260d7678e7b173bd663327170533f5 /main.d
parent8e1f84b1369909745859777d07a5e8e74b5df334 (diff)
functionsgit add *.d!
Diffstat (limited to 'main.d')
-rw-r--r--main.d39
1 files changed, 36 insertions, 3 deletions
diff --git a/main.d b/main.d
index c497283..eeff97d 100644
--- a/main.d
+++ b/main.d
@@ -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;
}