#!/bin/bash

case "$1" in
    ("")
        echo "
usage: 'build prog' to build the program, 'build clean' to cleanup
"
        exit 1
    ;;
    (prog)
        cd parser
        bisonc++ grammar || exit 1
        cd ../scanner
        flexc++ lexer || exit 1
        cd ..

        g++ --std=c++11 -Wall -ocalc *.cc */*.cc -lbobcat || exit 1
        echo "
ready; run the program as './calc'
"
    ;;
    (clean)
        rm -f calc 
        cd parser
        rm -f parse.cc parserbase.h 
        cd ../scanner
        rm -f lex.cc scannerbase.h
        echo "
done
"   
        ;;
esac
    
exit 1



