Overview
SHA1 Hash: | d78d700f7a688a0e358f77f8dee359ea3e95a7f7 |
---|---|
Date: | 2010-11-09 15:19:11 |
User: | kinaba |
Comment: | tenuki REPL bug-fix (now we can continue using REPL after a syntax error) and file interpreter mode. |
Timelines: | family | ancestors | descendants | both | trunk |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [f65680e1d2]
- sym-trunk inherited from [f65680e1d2]
Changes
Modified build.bat from [4a978e9aa8f5388f] to [b5142898fa4accdf].
1 1 @setlocal ENABLEDELAYEDEXPANSION 2 2 @set ARGS= 3 3 @for %%I in (main.d polemy\*.d tricks\*.d) do @set ARGS=!ARGS! %%I 4 4 @if not exist bin mkdir bin 5 -@echo dmd -ofbin\polemy.exe -O -release -inline %ARGS% 6 -@dmd -ofbin\polemy.exe -O -release -inline %ARGS% 5 +@echo dmd -ofbin\polemy.exe -O -release %ARGS% 6 +@dmd -ofbin\polemy.exe -O -release %ARGS%
Modified main.d from [14a3f0cd527958ce] to [81cf3e2a44d63239].
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 }
Modified polemy/lex.d from [bda39a8af81ee5d9] to [a96449f7398ef311].
11 11 12 12 /// Exception from this module 13 13 14 14 class LexException : Exception 15 15 { 16 16 const LexPosition pos; 17 17 18 - this( const LexPosition pos, string msg, string file="", int line=0, Throwable next=null ) 18 + this( const LexPosition pos, string msg, string file=null, size_t line=0, Throwable next=null ) 19 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos = pos; } 20 20 }; 21 21 22 22 /// Represents a position in a source code 23 23 24 24 class LexPosition 25 25 {
Modified polemy/parse.d from [f48294ade1f2cd3c] to [c3f339e53d35901f].
11 11 12 12 /// Exception from this module 13 13 14 14 class ParseException : Exception 15 15 { 16 16 const LexPosition pos; 17 17 18 - this( const LexPosition pos, string msg, string file="", int line=0, Throwable next=null ) 18 + this( const LexPosition pos, string msg, string file=null, size_t line=0, Throwable next=null ) 19 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos = pos; } 20 20 } 21 21 22 22 private auto createException(Lexer)(Lexer lex, string msg) 23 23 { return new ParseException(lex.empty?null:lex.front.pos, msg); } 24 24 25 25 /// Entry points of this module 26 26 27 27 auto parseString(S, T...)(S str, T fn_ln_cn) 28 28 { return parserFromString(str, fn_ln_cn).parse(); } 29 29 30 30 auto parseFile(S, T...)(S filename, T ln_cn) 31 - { return parserFromString(filename, ln_cn).parse(); } 31 + { return parserFromFile(filename, ln_cn).parse(); } 32 32 33 33 /// Named Constructor of Parser 34 34 35 35 private auto parserFromLexer(Lexer)(Lexer lex) 36 36 { return new Parser!Lexer(lex); } 37 37 38 38 private auto parserFromString(T...)(T params)
Modified tricks/test.d from [bb5afea9b7b1423d] to [de7560f1ecccee67].
6 6 */ 7 7 module tricks.test; 8 8 import std.conv : to; 9 9 import core.exception; 10 10 11 11 /// Unittest helper that asserts an expression must throw something 12 12 13 -void assert_throw(ExceptionType, T, string fn=__FILE__, int ln=__LINE__)(lazy T t, string msg="") 13 +void assert_throw(ExceptionType, T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string msg="") 14 14 { 15 15 try 16 16 { t(); } 17 17 catch(ExceptionType) 18 18 { return; } 19 19 catch(Throwable e) 20 20 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); } 21 21 onAssertErrorMsg(fn, ln, msg.length ? msg : "no execption"); 22 22 } 23 23 24 24 /// Unittest helper that asserts an expression must not throw anything 25 25 26 -auto assert_nothrow(T, string fn=__FILE__, int ln=__LINE__)(lazy T t, string msg="") 26 +auto assert_nothrow(T, string fn=__FILE__, size_t ln=__LINE__)(lazy T t, string msg="") 27 27 { 28 28 try 29 29 { return t(); } 30 30 catch(Throwable e) 31 31 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); } 32 32 assert(false); 33 33 } ................................................................................ 48 48 assert_throw!AssertError( assert_throw!AssertError(error()) ); 49 49 } 50 50 51 51 /// Unittest helpers asserting two values are in some relation ==, !=, <, <=, >, >= 52 52 53 53 template assertOp(string op) 54 54 { 55 - void assertOp(A, B, string fn=__FILE__, int ln=__LINE__)(A a, B b, string msg="") 55 + void assertOp(A, B, string fn=__FILE__, size_t ln=__LINE__)(A a, B b, string msg="") 56 56 { 57 57 try 58 58 { if( mixin("a"~op~"b") ) return; } 59 59 catch(Throwable e) 60 60 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.toString()~"]"); } 61 61 onAssertErrorMsg(fn, ln, msg.length ? msg : to!string(a)~" !"~op~to!string(b)); 62 62 }