Diff
Not logged in

Differences From Artifact [636370f08c051cf2]:

To Artifact [e659b2cb410288fd]:


6 6 */ 7 7 module main; 8 8 import std.stdio; 9 9 import std.algorithm; 10 10 import std.array; 11 11 import polemy.value; 12 12 import polemy.failure; 13 +import polemy.layer; 13 14 import polemy.parse; 14 15 import polemy.ast; 15 16 import polemy.eval; 16 -import polemy.layer; 17 17 18 18 enum VersionNoMajor = 0; 19 19 enum VersionNoMinor = 1; 20 20 enum VersionNoRev = 0; 21 21 22 22 /// Read-Eval-Print-Loop 23 23 24 24 class REPL 25 25 { 26 +Evaluator ev; 26 27 /// Load the prelude environment 27 28 this() 28 29 { 29 - ctx = createGlobalContext(); 30 + ev = new Evaluator; 30 31 } 31 32 32 33 /// Print the version number etc. 33 34 void greet() 34 35 { 35 36 writefln("Welcome to Polemy %d.%d.%d", VersionNoMajor, VersionNoMinor, VersionNoRev); 36 37 } 37 38 38 39 /// Run one file on the global scope 39 40 void runFile(string filename) 40 41 { 41 - eval(parseFile(filename), ctx, false, ValueLayer); 42 + ev.evalFile(filename); 42 43 } 43 44 44 45 /// Repeat the singleInteraction 45 46 void replLoop() 46 47 { 47 48 while( singleInteraction() ) {} 48 49 } ................................................................................ 74 75 { 75 76 scope(failure) 76 77 { buf = ""; lineno = nextlineno; } 77 78 78 79 buf ~= s; 79 80 nextlineno ++; 80 81 try 81 - { lastVal = eval(parseString(buf, "<REPL>", lineno), ctx, false, ValueLayer); } 82 + { lastVal = ev.evalString(buf, "<REPL>", lineno); } 82 83 catch( UnexpectedEOF ) 83 84 { return false; } // wait 84 85 buf = ""; 85 86 lineno = nextlineno; 86 87 return true; 87 88 } 88 89 }