#! /bin/sh
# file: QA_alltests.bat
echo "////////////////////////////////////////"
echo "////////////QA_alltests.bat////////////"
echo "////////////////////////////////////////"
qa="/usr/local/yacco2/qa/"
o2=/usr/local/yacco2/bin/o2
tmp=/tmp/o2
if [ ! -e "$tmp" ] 
then
  mkdir $tmp
fi
cd $tmp
prt_pdf=0
delete_files=1
#echo '\input eplain' > $tmp/eplain.txt
cont=n
ccresult=0

file_no=$((0))
file_pos=$((1))
cc_lex()
{
  echo "    =====Grammar=> $1 <===File==="
  sed -n -f '/usr/local/yacco2/qa/qa_echo.sedt' "$1" | sh
  file_name_only="`basename $2`"
  dir_only="`dirname $2`"
  #echo "%%%%%%%%%%%%%%%%target directory $dir_only"
  echo "	executing command line=>: $o2  $1"
  eval "$o2  $1"
  echo "------------------------------------------------"
  echo " "
  # once gened is enough for the various T gening
  sw1=
  sw2=
  sw3=
  sw4=
  if test $ccresult -eq 1; then
    echo -n "grammar in error: continue y or n: ";
    read cont;
    if test $cont -eq n; then
      echo "Error in grammar exiting";
      exit 1;
    fi
  fi 
if test $delete_files -eq 1; then
  for k in `ls * `;
  do
   #echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!Casing on $k"
   case $k in
    *.cpp|*.h) 
      eval "cp $k $dir_only/$k";
      #echo "-----Copying--------> $k to $dir_only/$k"
      eval "rm -f $k" 
;;
    *.fsc) 
      eval "cp $k $dir_only/$k";
      #echo "-------------> Deleting $k"
      eval "rm -f $k" ;;
    *.scn|*.idx|*.log|*.toc)
      #echo "-------------> Deleting $k"
      eval "rm -f $k" 
;;
    Err.w|T.w) # error and terminal documents to be cweave then pdftex printed by xpdf
      #echo "-------------> Deleting $k"
      #eval "rm -f $k" eof
;;
    *.w)
      #echo "-------------> Deleting $k"
      #eval "rm -f $k" 
;;
    *.tex)
      #echo "-------------> Deleting $k"
      eval "rm -f $k" 
;;
    *.mp)
      #echo "-------------> Deleting $k"
      eval "rm -f $k" 
;;
    *.tex1)
      #echo "-------------> Deleting $k"
      eval "rm -f $k" 
;;
    *.[1-9])
      #echo "-------------> Deleting Mpost diagrams $k"
      eval "rm -f $k" 
;;
     *.[1-9][0-9]*)
      #echo "-------------> Deleting Mpost diagrams $k"
      eval "rm -f $k"
 ;;
   esac
  done
fi
}

cc_lex "$qa"pathological.lex "$qa"pathological
cc_lex "$qa"TS_la1.lex   "$qa"TS_la1
cc_lex   "$qa"TS_la2.lex   "$qa"TS_la2
cc_lex   "$qa"TS_la2a.lex  "$qa" TS_la2a
cc_lex   "$qa"TS_la3.lex   "$qa"TS_la3
cc_lex   "$qa"TS_la4.lex   "$qa"TS_la4
cc_lex   "$qa"TS_la5.lex   "$qa"TS_la5
cc_lex   "$qa"TS_la6.lex   "$qa"TS_la6
cc_lex   "$qa"TS_la7.lex   "$qa"TS_la7
cc_lex   "$qa"TS_la8.lex   "$qa"TS_la8
cc_lex   "$qa"TS_la9.lex   "$qa"TS_la9
cc_lex   "$qa"TS_laa.lex   "$qa"TS_laa
cc_lex   "$qa"TS_lab.lex   "$qa"TS_lab
cc_lex   "$qa"TS_path1.lex   "$qa"TS_path1
cc_lex   "$qa"TS_path1a.lex   "$qa"TS_path1a
cc_lex   "$qa"TS_path2.lex   "$qa"TS_path2
cc_lex   "$qa"TS_path3.lex   "$qa"TS_path3
cc_lex   "$qa"TS_path4.lex   "$qa"TS_path4
cc_lex   "$qa"TS_path5.lex   "$qa"TS_path5
cc_lex   "$qa"TS_path6.lex   "$qa"TS_path6
cc_lex   "$qa"TS_path7.lex   "$qa"TS_path7
