Differences From Artifact [14a3f0cd527958ce]:
- File
main.d
- 2010-11-09 06:02:32 - part of checkin [7de80acfb8] on branch trunk - Added ultra tenuki REPL (user: kinaba) [annotate]
To Artifact [81cf3e2a44d63239]:
- File
main.d
- 2010-11-09 06:19:11 - part of checkin [d78d700f7a] on branch trunk - tenuki REPL bug-fix (now we can continue using REPL after a syntax error) and file interpreter mode. (user: kinaba) [annotate]
31 31 buf = "";
32 32 lineno = nextlineno;
33 33 lastVal = eval(a, ctx);
34 34 } catch( LexException ) {
35 35 // always EOF exception, so wait next
36 36 return false;
37 37 } catch( ParseException e ) {
38 - if( find(e.msg, "EOF") ) // ultra ad-hoc
38 + if( find(e.msg, "EOF")!="" ) // ultra ad-hoc
39 39 return false;
40 + buf = "";
41 + lineno = nextlineno;
40 42 throw e;
41 43 }
42 44 return true;
43 45 }
44 46
45 47 bool singleInteraction()
46 48 {
................................................................................
53 55 writeln(lastVal);
54 56 } catch(Throwable e) {
55 57 writeln(e);
56 58 }
57 59 return true;
58 60 }
59 61 }
62 +
63 +version(unittest) {
64 + bool success = false;
65 + static ~this(){ if(!success){writeln("(press enter to exit)"); readln();} }
66 +}
60 67
61 68 void main( string[] args )
62 69 {
70 + version(unittest) success=true;
71 +
63 72 if( args.length <= 1 )
64 73 {
65 74 writeln("Welcome to Polemy 0.1.0");
66 75 for(auto r = new REPL; r.singleInteraction();) {}
67 76 }
68 77 else
69 78 {
70 79 evalFile(args[1]);
71 80 }
72 81 }