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 @setlocal ENABLEDELAYEDEXPANSION 1 @setlocal ENABLEDELAYEDEXPANSION 2 @set ARGS= 2 @set ARGS= 3 @for %%I in (main.d polemy\*.d tricks\*.d) do @set ARGS=!ARGS! %%I 3 @for %%I in (main.d polemy\*.d tricks\*.d) do @set ARGS=!ARGS! %%I 4 @if not exist bin mkdir bin 4 @if not exist bin mkdir bin 5 @echo dmd -ofbin\polemy.exe -O -release -inline %ARGS% | 5 @echo dmd -ofbin\polemy.exe -O -release %ARGS% 6 @dmd -ofbin\polemy.exe -O -release -inline %ARGS% | 6 @dmd -ofbin\polemy.exe -O -release %ARGS%
Modified main.d from [14a3f0cd527958ce] to [81cf3e2a44d63239].
31 buf = ""; 31 buf = ""; 32 lineno = nextlineno; 32 lineno = nextlineno; 33 lastVal = eval(a, ctx); 33 lastVal = eval(a, ctx); 34 } catch( LexException ) { 34 } catch( LexException ) { 35 // always EOF exception, so wait next 35 // always EOF exception, so wait next 36 return false; 36 return false; 37 } catch( ParseException e ) { 37 } catch( ParseException e ) { 38 if( find(e.msg, "EOF") ) // ultra ad-hoc | 38 if( find(e.msg, "EOF")!="" ) // ultra ad-hoc 39 return false; 39 return false; > 40 buf = ""; > 41 lineno = nextlineno; 40 throw e; 42 throw e; 41 } 43 } 42 return true; 44 return true; 43 } 45 } 44 46 45 bool singleInteraction() 47 bool singleInteraction() 46 { 48 { ................................................................................................................................................................................ 53 writeln(lastVal); 55 writeln(lastVal); 54 } catch(Throwable e) { 56 } catch(Throwable e) { 55 writeln(e); 57 writeln(e); 56 } 58 } 57 return true; 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 void main( string[] args ) 68 void main( string[] args ) 62 { 69 { > 70 version(unittest) success=true; > 71 63 if( args.length <= 1 ) 72 if( args.length <= 1 ) 64 { 73 { 65 writeln("Welcome to Polemy 0.1.0"); 74 writeln("Welcome to Polemy 0.1.0"); 66 for(auto r = new REPL; r.singleInteraction();) {} 75 for(auto r = new REPL; r.singleInteraction();) {} 67 } 76 } 68 else 77 else 69 { 78 { 70 evalFile(args[1]); 79 evalFile(args[1]); 71 } 80 } 72 } 81 }
Modified polemy/lex.d from [bda39a8af81ee5d9] to [a96449f7398ef311].
11 11 12 /// Exception from this module 12 /// Exception from this module 13 13 14 class LexException : Exception 14 class LexException : Exception 15 { 15 { 16 const LexPosition pos; 16 const LexPosition pos; 17 17 18 this( const LexPosition pos, string msg, string file="", int line=0, Thr | 18 this( const LexPosition pos, string msg, string file=null, size_t line=0 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos 20 }; 20 }; 21 21 22 /// Represents a position in a source code 22 /// Represents a position in a source code 23 23 24 class LexPosition 24 class LexPosition 25 { 25 {
Modified polemy/parse.d from [f48294ade1f2cd3c] to [c3f339e53d35901f].
11 11 12 /// Exception from this module 12 /// Exception from this module 13 13 14 class ParseException : Exception 14 class ParseException : Exception 15 { 15 { 16 const LexPosition pos; 16 const LexPosition pos; 17 17 18 this( const LexPosition pos, string msg, string file="", int line=0, Thr | 18 this( const LexPosition pos, string msg, string file=null, size_t line=0 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos 19 { super(sprintf!"[%s] %s"(pos, msg), file, line, next); this.pos 20 } 20 } 21 21 22 private auto createException(Lexer)(Lexer lex, string msg) 22 private auto createException(Lexer)(Lexer lex, string msg) 23 { return new ParseException(lex.empty?null:lex.front.pos, msg); } 23 { return new ParseException(lex.empty?null:lex.front.pos, msg); } 24 24 25 /// Entry points of this module 25 /// Entry points of this module 26 26 27 auto parseString(S, T...)(S str, T fn_ln_cn) 27 auto parseString(S, T...)(S str, T fn_ln_cn) 28 { return parserFromString(str, fn_ln_cn).parse(); } 28 { return parserFromString(str, fn_ln_cn).parse(); } 29 29 30 auto parseFile(S, T...)(S filename, T ln_cn) 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 /// Named Constructor of Parser 33 /// Named Constructor of Parser 34 34 35 private auto parserFromLexer(Lexer)(Lexer lex) 35 private auto parserFromLexer(Lexer)(Lexer lex) 36 { return new Parser!Lexer(lex); } 36 { return new Parser!Lexer(lex); } 37 37 38 private auto parserFromString(T...)(T params) 38 private auto parserFromString(T...)(T params)
Modified tricks/test.d from [bb5afea9b7b1423d] to [de7560f1ecccee67].
6 */ 6 */ 7 module tricks.test; 7 module tricks.test; 8 import std.conv : to; 8 import std.conv : to; 9 import core.exception; 9 import core.exception; 10 10 11 /// Unittest helper that asserts an expression must throw something 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 | 13 void assert_throw(ExceptionType, T, string fn=__FILE__, size_t ln=__LINE__)(lazy 14 { 14 { 15 try 15 try 16 { t(); } 16 { t(); } 17 catch(ExceptionType) 17 catch(ExceptionType) 18 { return; } 18 { return; } 19 catch(Throwable e) 19 catch(Throwable e) 20 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to 20 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to 21 onAssertErrorMsg(fn, ln, msg.length ? msg : "no execption"); 21 onAssertErrorMsg(fn, ln, msg.length ? msg : "no execption"); 22 } 22 } 23 23 24 /// Unittest helper that asserts an expression must not throw anything 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 27 { 27 { 28 try 28 try 29 { return t(); } 29 { return t(); } 30 catch(Throwable e) 30 catch(Throwable e) 31 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to 31 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception ["~e.to 32 assert(false); 32 assert(false); 33 } 33 } ................................................................................................................................................................................ 48 assert_throw!AssertError( assert_throw!AssertError(error()) ); 48 assert_throw!AssertError( assert_throw!AssertError(error()) ); 49 } 49 } 50 50 51 /// Unittest helpers asserting two values are in some relation ==, !=, <, <=, >, 51 /// Unittest helpers asserting two values are in some relation ==, !=, <, <=, >, 52 52 53 template assertOp(string op) 53 template assertOp(string op) 54 { 54 { 55 void assertOp(A, B, string fn=__FILE__, int ln=__LINE__)(A a, B b, strin | 55 void assertOp(A, B, string fn=__FILE__, size_t ln=__LINE__)(A a, B b, st 56 { 56 { 57 try 57 try 58 { if( mixin("a"~op~"b") ) return; } 58 { if( mixin("a"~op~"b") ) return; } 59 catch(Throwable e) 59 catch(Throwable e) 60 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception 60 { onAssertErrorMsg(fn, ln, msg.length ? msg : "exception 61 onAssertErrorMsg(fn, ln, msg.length ? msg : to!string(a)~" !"~op 61 onAssertErrorMsg(fn, ln, msg.length ? msg : to!string(a)~" !"~op 62 } 62 }