55 lines
1004 B
Plaintext
55 lines
1004 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
INFILE=${2}
|
||
|
|
||
|
usage() {
|
||
|
printf "${0} - compiler for HELL programming language\n"
|
||
|
printf "usage: ${0} INFILE GCCOPTS\n"
|
||
|
printf "\n"
|
||
|
printf "Note: Since hellc is a frontend for GCC, any GCC option can be used.\n"
|
||
|
printf "\n"
|
||
|
printf "Hellc is free software.\n"
|
||
|
printf "See the GNU GPL version 3 for details.\n"
|
||
|
}
|
||
|
|
||
|
usage_small() {
|
||
|
printf "usage: ${0} INFILE GCCOPTS\n"
|
||
|
}
|
||
|
|
||
|
case ${1} in
|
||
|
-h|--help)
|
||
|
usage "$@"
|
||
|
exit 0
|
||
|
;;
|
||
|
-c|--compile)
|
||
|
if [[ -z "${INFILE}" ]]; then
|
||
|
printf "${0}: no input file\n"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
printf "running HELL preprocessor for ${INFILE}\n"
|
||
|
cat ${INFILE} | hellp > ${INFILE}.new
|
||
|
if [ "$?" != 0 ]; then
|
||
|
printf "${0}: error: HELL preprocessor failed to run\n"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
printf "compiling ${INFILE}\n"
|
||
|
gcc ${INFILE}.new -o ${INFILE}
|
||
|
if [ "$?" != 0 ]; then
|
||
|
printf "${0}: error: C compiler failed to run\n"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
printf "finished compiling\n"
|
||
|
exit 0
|
||
|
;;
|
||
|
-*|--*)
|
||
|
usage_small "$@"
|
||
|
exit 0
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
usage_small "$@"
|
||
|
exit 1
|