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
|
#!/usr/bin/perl
use strict;
use warnings;
unless (@ARGV and $ARGV[0] =~ /^\s*--yes\s*/i) {
print <<'HERE';
In order to recompile the Yapp.yp grammar, you need to install
the Parse::Yapp module and then run this script with the
--yes
parameter *from this directory*.
HERE
exit(1);
}
opendir(DH, '.') or die $!;
if (not grep {/^Yapp\.yp$/} readdir DH) {
print "The program needs to be run from the Math::Symbolic\n"
."distribution root directory.\n";
exit(1);
}
close DH;
system('yapp -n -m Math::Symbolic::Parser::Yapp -o lib/Math/Symbolic/Parser/Yapp.pm Yapp.yp');
open my $fh, '+<', 'lib/Math/Symbolic/Parser/Yapp.pm' or die $!;
local $/ = undef;
my $code = <$fh>;
seek $fh, 0, 0;
truncate $fh, 0;
print $fh <<HERE;
package Math::Symbolic::Parser::Yapp::Driver;
use strict;
our \$VERSION = '1.05';
HERE
print $fh $code;
close $fh;
print "Compilation successful.\n";
|