package psychorigid; use Filter::Simple; use diagnostics; sub ctype { my @ctypes = split /;/,shift; my $code; my $argnum=0; # # Few tests added, we should probably add A LOT more for a real modul +e. # my %CODE = ( 'byte'=>' warn "arg !! ($_[!!]) IS NOT a byte" if $_[!!]!~/^-?\d{1,3 +}$/ || ($_[!!]>127) || ($_[!!]<-128);', 'short'=>' warn "arg !! ($_[!!]) IS NOT a short" if $_[!!]!~/^-?\d{1 +,5}$/ || ($_[!!]>32767) || ($_[!!]<-32768);', 'int'=>' warn "arg !! ($_[!!]) IS NOT an int" if $_[!!]!~/^-?\d{1,10 +}$/ || ($_[!!]>2147483647) || ($_[!!]<-2147483648);', 'char'=>' warn "arg !! ($_[!!]) IS NOT a char" if $_[!!]!~/^\w$/;', ); foreach my $ctype (@ctypes) { my $val=$CODE{$ctype}; $val=~s/!!/$argnum/g; $argnum++; $code.=$val."\n"; } return $code; } sub check { my $func_decl = shift; my $check_code = ctype(shift); return "$func_decl {\n$check_code" } FILTER { s/(sub\s+.+?)\s*{\s*#\s*!([^!]*)!/check($1,$2)/e; # # Uncomment the following line to see the changes applied by the filt +er # #print "\n$_\n"; }; 1;
#!/usr/bin/perl # # The following line can be commented and the code # will still be valid. # use psychorigid; # Add additional tests like some psychorigid languag +e ;-) sub toto { # !char;int! print "ok dans toto\n"; } toto('s','12245666666');
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 1: psychorigid.pm or how to make Perl better ?
by tilly (Archbishop) on Oct 22, 2001 at 02:00 UTC | |
Re: psychorigid.pm or how to make Perl better ?
by traveler (Parson) on Oct 22, 2001 at 00:57 UTC | |
by TheDamian (Vicar) on Oct 22, 2001 at 01:24 UTC | |
by traveler (Parson) on Oct 22, 2001 at 01:57 UTC | |
by TheDamian (Vicar) on Oct 22, 2001 at 07:20 UTC | |
by arhuman (Vicar) on Oct 22, 2001 at 01:22 UTC | |
Re: psychorigid.pm or how to make Perl better ?
by iakobski (Pilgrim) on Oct 22, 2001 at 17:37 UTC |