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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#!/bin/csh -f
#
# Cup install and test script
# Scott Hudson 8/31/95
#
# Last revision 7/3/96 (for v0.10a)
# By Frank Flannery
#
# Last revision 11/16/96 (for v0.10b)
# By Daniel Wang
#
# Updated version number 7/24/99 for 0.10k
# By C. Scott Ananian
echo
echo "================================"
echo "Installing and testing Cup v0.10k"
echo "================================"
echo
# check for this directory in CLASSPATH
#
set cwd = `pwd`
set c_path = `printenv CLASSPATH`
if ($c_path !~ "*$cwd*") then
echo " "
echo "WARNING:"
echo "WARNING: The current directory does not appear in your CLASSPATH"
echo "WARNING: it will be added for this install/test only"
echo "WARNING:"
echo " "
setenv CLASSPATH $cwd':'$c_path
echo "CLASSPATH now set to "
printenv CLASSPATH
endif
# change to the demo directory
#
echo " "
echo "changing to simple_calc subdirectory..."
echo "cd java_cup/simple_calc"
cd java_cup/simple_calc
# remove old copies of parser.java and sym.java
#
echo " "
echo "removing any old copies of parser.java and sym.java..."
echo "rm -f parser.java sym.java"
rm -f parser.java sym.java
# compile java_cup and run it against the demo program
# the -cs (for "checksource") option here will force the
# java_cup and java_cup.runtime source to be compiled prior
# to running it.
#
echo " "
echo "compiling java_cup then generating demo program..."
echo "java -cs java_cup.Main < parser.cup"
java -cs java_cup.Main < parser.cup
# make sure parser.java and sym.java now exist
#
if ( ! -e parser.java) then
echo " "
echo "ERROR: for some reason parser.java was not created"
echo "ERROR: install was not successful"
exit 1
endif
if ( ! -e sym.java) then
echo " "
echo "ERROR: for some reason sym.java was not created"
echo "ERROR: install was not successful"
exit 1
endif
# run the demo
# again, the -cs option will cause compilation of all the parts
# of the demo program (including parser.java and sym.java that
# should have been generated in the previous step).
#
echo "removing old test results..."
echo "rm -f test_results"
rm -f test_results
echo " "
echo "executing the demo program..."
echo "echo '1*-2+2;' | java -cs java_cup.simple_calc.Main >& test_results"
echo '1*-2+2;' | java -cs java_cup.simple_calc.Main >& test_results
# compare with standard results
#
set res = `tail -1 test_results`
if ("$res" !~ "= 0") then
echo "ERROR: test program produced the wrong results"
echo "ERROR: output was:"
cat test_results
echo "ERROR: install was not successful"
rm -f test_results
exit 2
endif
# all is well
#
rm -f test_results
echo " "
echo "=============================="
echo "Install and test was successful"
echo "=============================="
exit 0
|