digitalmars.D.announce - dxmp 0.1.0 released
- rubikitch ruby-lang.org (144/144) Mar 10 2007 I just released dxmp, code annotator for D.
I just released dxmp, code annotator for D. It is D port of Ruby's xmpfilter. http://www.dsource.org/projects/dxmp/ $ build dxmp Files are up to date, no build required. $ cat simple.rb $ xmpfilter simple.rb $ cat simple.d // Example of D's dxmp int main(char[][] argv) { 1+1; // => "aa".length; // => return 0; } $ ./dxmp simple.d // Example of D's dxmp int main(char[][] argv) { cast(void)(1+1); // => 2 cast(void)("aa".length); // => 2 return 0; } $ cat dxmp_testcases.d private import std.stdio; private import std.cstream; int main(char[][] argv) { version(assert_error) assert(0); version(switch_error) switch_error(); version(array_warning) array_warning(); version(not_reachable) not_reachable(); version(undefined) undefined(); version(print) print(); version(annotate) annotate(); return 0; } version(switch_error) void switch_error() { int x = 1; switch(x) { case 0: writefln(0); break; /* no default */ } } version(array_warning) char array_warning() { static char[10] a; int length = 4; return a[length - 1]; } version(not_reachable) int not_reachable() { return 1; return 2; } version(undefined) void undefined() { x(); } version(print) void print() { writefln("print"); } version(annotate) void annotate() { cast(void)(1+1); // => 10+10; // => } $ rdmd -version=assert_error dxmp_testcases.d Error: AssertError Failure dxmp_testcases(4) $ rdmd -version=switch_error dxmp_testcases.d Error: Switch Default dxmp_testcases(17) $ rdmd -w -version=array_warning dxmp_testcases.d warning - Error: array 'length' hides other 'length' name in outer scope rdmd: Couldn't compile or execute dxmp_testcases.d. $ rdmd -w -version=not_reachable dxmp_testcases.d warning - dxmp_testcases.d(35): Error: statement is not reachable rdmd: Couldn't compile or execute dxmp_testcases.d. $ rdmd -version=undefined dxmp_testcases.d dxmp_testcases.d(40): Error: undefined identifier x dxmp_testcases.d(40): Error: function expected before (), not x of type int rdmd: Couldn't compile or execute dxmp_testcases.d. $ ./dxmp dxmp_testcases.d -version=annotate | grep -5 '// =>' writefln("print"); } version(annotate) void annotate() { cast(void)(1+1); // => 2 cast(void)(10+10); // => 20 } $ ./dxmp dxmp_testcases.d -version=assert_error | grep -5 '// !>' private import std.stdio; private import std.cstream; int main(char[][] argv) { version(assert_error) assert(0); // !> AssertError Failure version(switch_error) switch_error(); version(array_warning) array_warning(); version(not_reachable) not_reachable(); version(undefined) undefined(); version(print) print(); $ ./dxmp dxmp_testcases.d -version=switch_error | grep -5 '// !>' } version(switch_error) void switch_error() { int x = 1; switch(x) { // !> Switch Default case 0: writefln(0); break; /* no default */ } $ ./dxmp dxmp_testcases.d -w -version=array_warning | grep -5 '// ~>' version(annotate) void annotate() { } // ~> warning - Error: array 'length' hides other 'length' name in outer scope // ~> rdmd: Couldn't compile or execute dxmp_testcases.d. $ ./dxmp dxmp_testcases.d -version=print | grep -5 '// >>' version(annotate) void annotate() { } // >> print $ ./dxmp dxmp_testcases.d -w -version=not_reachable | grep -5 '// ~>' version(annotate) void annotate() { } // ~> warning - dxmp_testcases.d(35): Error: statement is not reachable // ~> rdmd: Couldn't compile or execute dxmp_testcases.d. $ ./dxmp dxmp_testcases.d -version=undefined | grep -5 '// ~>' version(annotate) void annotate() { } // ~> dxmp_testcases.d(40): Error: undefined identifier x // ~> dxmp_testcases.d(40): Error: function expected before (), not x of type int // ~> rdmd: Couldn't compile or execute dxmp_testcases.d. -- rubikitch http://www.rubyist.net/~rubikitch/
Mar 10 2007