@@ -21,8 +21,12 @@ Value lastVal; int lineno = 1; int nextlineno = 1; this() { ctx = createGlobalContext(); } + this(string filename) { + ctx = createGlobalContext(); + eval(parseFile(filename), ctx, false, "@v"); + } bool tryRun( string s ) { scope(failure) @@ -55,8 +59,9 @@ } } /// Entry point. If args.length==1, invoke REPL. +/// If args.length==3 && args[1]=="-l" read args[2] and invoke REPL. /// Otherwise interpret the argument as a filename. void main( string[] args ) { if( args.length <= 1 ) @@ -63,9 +68,14 @@ { writeln("Welcome to Polemy 0.1.0"); for(auto r = new REPL; r.singleInteraction();) {} } + else if( args.length>=3 && args[1]=="-l" ) + { + writeln("Welcome to Polemy 0.1.0"); + for(auto r = new REPL(args[2]); r.singleInteraction();) {} + } else { evalFile(args[1]); } }