forked from hype/HYPE_Processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
j2p.pl
executable file
·52 lines (39 loc) · 1.1 KB
/
j2p.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl -w
# Note: This perl script is specifically made only for this project.
# Since this script relies on certain conventions, this cannot be used as a
# generic java to pde converter!
#
# Also, to Perl people everywhere, sorry for this mess -- james.
use File::Basename;
print 'cleaning pde/ directory... ';
unlink <pde/*.pde>;
print "done.\n";
my $minfilename = 'HYPE.pde';
my $mintxt;
foreach $file (<java/src/hype/*/*{,/*}.java>) {
print 'converting `' . basename($file) . '` to pde... ';
my $outname = 'pde/' . basename($file,'.java') . '.pde';
open (INFILE, $file) or die;
open (OUTFILE, ">$outname");
while (<INFILE>) {
next if ($_ =~ /^\s*(@|import|package)/);
$_ =~ s/\/\/.*$//;
$_ =~ s/^public/public static/;
next if ($_ =~ /^\s*$/);
print OUTFILE $_;
$_ =~ s/\n/ /;
$mintxt .= $_;
}
close (INFILE);
close (OUTFILE);
print "done.\n";
}
print "writing to $minfilename... ";
open (MINFILE, ">$minfilename");
$mintxt =~ s/\/\*.*?\*\// /g;
$mintxt =~ s/\s+/ /g;
$mintxt =~ s/\s+$//g;
$mintxt =~ s/^\s+//g;
print MINFILE $mintxt;
close (MINFILE);
print "done.\n";