# mktab.sh, 17 Feb 05
#
# Extract data from various files (generated by ngram)
# needed for C construct frequency tables

source ../config.files

#GEN_DATA=1

if [ $GEN_DATA == 1 ]; then
   for.sh
fi

awk -f forempty.awk < $ALLFOR_LINES > $GLOB_TAB_DIR/for_omit_expr

if [ $GEN_DATA == 1 ]; then
   cntrlexpr.sh
fi

awk -v KEY_TOK="IF" -f $PPISWCNTRL < $ALLCNTRL_LINES | $MKTWOCOL > $GLOB_TAB_DIR/if_cntrl
awk -v KEY_TOK="WHILE" -f $PPISWCNTRL < $ALLCNTRL_LINES | $MKTWOCOL > $GLOB_TAB_DIR/while_cntrl
awk -v KEY_TOK="SWITCH" -f $PPISWCNTRL < $ALLCNTRL_LINES > $GLOB_TAB_DIR/switch_cntrl
awk -v KEY_TOK="FOR" -f $PPISWCNTRL < $ALLCNTRL_LINES > $GLOB_TAB_DIR/for_header_cnt

num_toks=`awk -f releqcnt.awk < $C_CNT_FILE`
awk -v KEY_TOK="IF" -v OP_CNT="$num_toks" -f rellogops.awk < $ALLCNTRL_LINES | $MKTWOCOL > $GLOB_TAB_DIR/if_releqlog_op

awk -f iswcntrl.awk -v CMPD_HDR="IF" < $LOC_TAB_DIR/all_prog.cntrl.t | $SORTLASTCOL | $MKTWOCOL > $GLOB_TAB_DIR/if_cntrl
awk -f iswcntrl.awk -v CMPD_HDR="SWITCH" < $LOC_TAB_DIR/all_prog.cntrl.t | $SORTLASTCOL > $GLOB_TAB_DIR/switch_cntrl
awk -f iswcntrl.awk -v CMPD_HDR="WHILE" < $LOC_TAB_DIR/all_prog.cntrl.t | $SORTLASTCOL | $MKTWOCOL > $GLOB_TAB_DIR/while_cntrl

awk -f fcntrl.awk < $LOC_TAB_DIR/all_prog.cntrl.t | $MKTWOCOL > $GLOB_TAB_DIR/for_cntrl

if [ $GEN_DATA == 1 ]; then
   gzcat *$EXPRST_SUFF | awk -f exprstmt.awk > $LOC_TAB_DIR/exprstmt.t
fi

awk -f mkexprst.awk < $LOC_TAB_DIR/exprstmt.t | $MKTWOCOL > $GLOB_TAB_DIR/exprstmt

#rm $TEMP_FILE
