Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 082c6f9925
Fetching contributors…

Cannot retrieve contributors at this time

executable file 85 lines (67 sloc) 2.097 kb
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#!/usr/bin/perl

use strict;

my $section = "2";
my $cur = "i-".$section;
my $prev = "i-".($section-1);

my $pwd = `pwd`;
my $base = "cs37/labs/";
my $curdir = $base.$cur;
my $prevdir = $base.$prev;
my $home = $ENV{"HOME"};
my $further = "Please ask for help if you are stuck.\n";


if ($pwd !~ m#^${home}/${curdir}$#) {
  die "This command can only be executed from your $curdir directory.\n".
    $further;
}

if (! -e "$home/$prevdir/interpreter.rkt") {
  die "Your $prevdir/interpreter.rkt file does not exist.\n".
    $further;
}

if (! -e "$home/$prevdir/i-tests.rkt") {
  die "Your $prevdir/i-tests.rkt file does not exist.\n".
    $further;
}

if (! -e "$home/$curdir/interpreter-p${section}.rkt") {
  die "Cannot find $curdir/interpreter-p${section}.rkt\n".
      $further;
}

if (! -e "$home/$curdir/i-tests-p${section}.rkt") {
  die "Cannot find $curdir/i-tests-p${section}.rkt\n".
      $further;
}

if ( -s "$home/$curdir/i-tests-p${section}.rkt" == 0) {
  die "It seems you have already run merge.\n".$further;
}

if ( -s "$home/$curdir/interpreter-p${section}.rkt" == 0) {
  die "It seems you have already run merge.\n".$further;
}

my $pi = "$home/$prevdir/interpreter.rkt";
my $ci = "$home/$curdir/interpreter-p${section}.rkt";
my $ni = "$home/$curdir/interpreter.rkt";
`cat $pi $ci >> $ni`;

if (! -e $ni) {
  die "Failed to create new interpreter.rkt file.\n".$further;
}

$pi = "$home/$prevdir/i-tests.rkt";
$ci = "$home/$curdir/i-tests-p${section}.rkt";
$ni = "$home/$curdir/i-tests.rkt";
`cat $pi $ci > $ni`;

if (! -e $ni) {
  die "Failed to create new i-tests.rkt file.\n".$further;
}

$ci = "$home/$curdir/interpreter-p${section}.rkt";
open(F, ">".$ci);
close($ci);
if (-s $ci != 0) {
  die "Failed to empty $curdir/interpreter-p${section}.rkt\n".
    $further;
}

$ci = "$home/$curdir/i-tests-p${section}.rkt";
open(F, ">".$ci);
close($ci);
if (-s $ci != 0) {
  die "Failed to empty $curdir/i-tests-p${section}.rkt\n".
    $further;
}

print "Successfully merged old files with new files!\n";
print "Load interpreter.rkt into Dr. Racket to begin Part ${section}\n\n";
Something went wrong with that request. Please try again.