checking in cup
[IRC.git] / Robust / cup / INSTALL
1 #!/bin/csh -f
2 #
3 # Cup install and test script
4 # Scott Hudson 8/31/95
5 #  
6 # Last revision 7/3/96 (for v0.10a)
7 # By Frank Flannery
8 #
9 # Last revision 11/16/96 (for v0.10b)
10 # By Daniel Wang
11 #
12 # Updated version number 7/24/99 for 0.10k
13 # By C. Scott Ananian
14 echo 
15 echo "================================"
16 echo "Installing and testing Cup v0.10k"
17 echo "================================"
18 echo
19
20 # check for this directory in CLASSPATH 
21 #
22 set cwd = `pwd`
23 set c_path = `printenv CLASSPATH`
24 if ($c_path !~ "*$cwd*") then
25   echo " "
26   echo "WARNING:"
27   echo "WARNING: The current directory does not appear in your CLASSPATH"
28   echo "WARNING: it will be added for this install/test only"
29   echo "WARNING:"
30   echo " "
31   setenv CLASSPATH $cwd':'$c_path
32   echo "CLASSPATH now set to " 
33   printenv CLASSPATH
34 endif
35   
36 # change to the demo directory
37 #
38 echo " "
39 echo "changing to simple_calc subdirectory..."
40 echo "cd java_cup/simple_calc"
41 cd java_cup/simple_calc 
42
43 # remove old copies of parser.java and sym.java
44 #
45 echo " "
46 echo "removing any old copies of parser.java and sym.java..."
47 echo "rm -f parser.java sym.java"
48 rm -f parser.java sym.java
49
50 # compile java_cup and run it against the demo program
51 #   the -cs (for "checksource") option here will force the 
52 #   java_cup and java_cup.runtime source to be compiled prior 
53 #   to running it.
54 #
55 echo " "
56 echo "compiling java_cup then generating demo program..."
57 echo "java -cs java_cup.Main < parser.cup"
58 java -cs java_cup.Main < parser.cup 
59
60 # make sure parser.java and sym.java now exist
61 #
62 if ( ! -e parser.java) then
63   echo " "
64   echo "ERROR: for some reason parser.java was not created"
65   echo "ERROR: install was not successful"
66   exit 1
67 endif
68 if ( ! -e sym.java) then
69   echo " "
70   echo "ERROR: for some reason sym.java was not created"
71   echo "ERROR: install was not successful"
72   exit 1
73 endif
74
75 # run the demo
76 #  again, the -cs option will cause compilation of all the parts 
77 #  of the demo program (including parser.java and sym.java that 
78 #  should have been generated in the previous step).
79 #
80 echo "removing old test results..."
81 echo "rm -f test_results"
82 rm -f test_results
83 echo " "
84 echo "executing the demo program..."
85 echo "echo '1*-2+2;' | java -cs java_cup.simple_calc.Main >& test_results"
86 echo '1*-2+2;' | java -cs java_cup.simple_calc.Main >& test_results
87
88 # compare with standard results 
89 #
90 set res = `tail -1 test_results`
91 if ("$res" !~ "= 0") then
92   echo "ERROR: test program produced the wrong results"
93   echo "ERROR: output was:"
94   cat test_results
95   echo "ERROR: install was not successful"
96   rm -f test_results
97   exit 2
98 endif
99   
100 # all is well
101 #
102 rm -f test_results
103 echo " "
104 echo "=============================="
105 echo "Install and test was successful"
106 echo "=============================="
107 exit 0