View previous topic :: View next topic |
Author |
Message |
rubikitch
Joined: 07 Feb 2007 Posts: 4 Location: Japan
|
Posted: Wed Feb 07, 2007 9:25 am Post subject: dxmp: source code annotator |
|
|
dxmp: code annotation tool like Ruby's xmpfilter
= Sample session
Code: |
$ build dxmp
Files are up to date, no build required.
$ 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/
Last edited by rubikitch on Fri Feb 09, 2007 3:04 pm; edited 1 time in total |
|
Back to top |
|
|
brad Site Admin
Joined: 22 Feb 2004 Posts: 490 Location: Atlanta, GA USA
|
Posted: Thu Feb 08, 2007 12:59 pm Post subject: |
|
|
so, do you have code now, and are ready for the project? _________________ I really like the vest! |
|
Back to top |
|
|
rubikitch
Joined: 07 Feb 2007 Posts: 4 Location: Japan
|
|
Back to top |
|
|
brad Site Admin
Joined: 22 Feb 2004 Posts: 490 Location: Atlanta, GA USA
|
Posted: Thu Feb 08, 2007 3:36 pm Post subject: |
|
|
all set _________________ I really like the vest! |
|
Back to top |
|
|
rubikitch
Joined: 07 Feb 2007 Posts: 4 Location: Japan
|
|
Back to top |
|
|
|