rall 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/csh -f
  2. # $1 - schema name, $2 - scope
  3. if !($?rig) set rig='~/rigal/rigsc.446/bin'
  4. # ensure MP2 binaries have been built
  5. if !(-x MP2-parser) $rig/rc MP2-parser -c
  6. if !(-x MP2-generator) $rig/rc MP2-generator -c
  7. # cleanup rc/ic
  8. rm *.rsc >& /dev/null
  9. # parse into tree
  10. ./MP2-parser "$1" tree "$2" > temp.txt
  11. if !(-f tree) then
  12. echo "ERROR: Unable to parse into syntax tree file (see 'temp.txt' for details)"
  13. exit 1
  14. endif
  15. # generate C++ code
  16. ./MP2-generator tree > temp2.txt
  17. if !(-f "$1.cpp") then
  18. echo "ERROR: Unable to generate '$1.cpp' C++ source code file (see 'temp2.txt' or 'RIGSC/bin/v tree' for details)"
  19. rm .cpp >& /dev/null # weird bug in MP2-generator
  20. exit 2
  21. endif
  22. # compile C++
  23. echo "C++ compiler: g++ $1.cpp -o $1 -Ofast"
  24. time g++ "$1.cpp" -o $1 -Ofast
  25. if !(-x "$1") then
  26. echo "ERROR: Unable to compile binary file"
  27. exit 3
  28. endif
  29. # run C++
  30. echo "$1 run: ./$1 > $1.txt"
  31. time ./$1 > "$1.txt"
  32. echo "Completed $1 for scope $2"
  33. # cleanup
  34. rm temp.txt temp2.txt $1 tree >& /dev/null