import std.stdio; import std.string; import std.file; import std.conv; import std.getopt; /* import parser; import dbg; import chunk; import compiler; */ import vm; import dbg; /* import compiler; import obj; import dbg; import chunk; import vm; */ void repl(bool noCore) { REPL = true; VM vm = new VM(); interpret(getCore(noCore), vm); while(true) { write("> "); string input = strip(stdin.readln()); if (input.length == 0) { continue; } interpret(input, vm); } } string readFile(string fname) { File f = File(fname, "r"); char[] ret = []; while (!f.eof()) { ret = ret ~ f.readln(); } f.close(); return to!string(ret); } string getCore(bool noCore) { if (noCore) { return ""; } else { return readFile("core.neb"); } } int main(string[] args) { bool noCore = false; getopt(args, "no-core", &noCore, "d", &DEBUG); if (args.length <= 1) { repl(noCore); } else { string fname = args[1]; if (!exists(fname)) { writeln("file doesn't exist: ", fname); return 1; } VM vm = new VM(); interpret(getCore(noCore), vm); string data = readFile(fname); interpret(data, vm); } return 0; }