|
|
@ -1,16 +1,17 @@ |
|
|
|
#!/bin/bash |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
# Term colours for output |
|
|
|
# Term. colours for output |
|
|
|
RED='\033[0;31m' # Red |
|
|
|
RED='\033[0;31m' # Red |
|
|
|
GRN='\033[0;32m' # Green |
|
|
|
GRN='\033[0;32m' # Green |
|
|
|
|
|
|
|
YLLW='\033[0;33m' # Yellow |
|
|
|
NC='\033[0m' # No Color |
|
|
|
NC='\033[0m' # No Color |
|
|
|
|
|
|
|
|
|
|
|
TRI="" |
|
|
|
TRI="" #.tri file |
|
|
|
|
|
|
|
|
|
|
|
# Check if the input in arg 1 ($1) is empty |
|
|
|
# Check if the input in arg 1 ($1) is empty |
|
|
|
if [ -z "$1" ] |
|
|
|
if [ -z "$1" ] |
|
|
|
then # if empty... |
|
|
|
then # if empty... |
|
|
|
printf "${RED}Usage: $0 *.tri file (optional: $0 *.tri tree)${NC}" |
|
|
|
printf "${YLLW}Usage: $0 *.tri file (optional: $0 *.tri tree)${NC}" |
|
|
|
exit 1 # Exit with code 1, failure |
|
|
|
exit 1 # Exit with code 1, failure |
|
|
|
else |
|
|
|
else |
|
|
|
TRI=$1 |
|
|
|
TRI=$1 |
|
|
@ -19,25 +20,23 @@ fi |
|
|
|
#Remove the extension of the file |
|
|
|
#Remove the extension of the file |
|
|
|
FILENAME=$(echo $TRI | cut -f 1 -d '.') |
|
|
|
FILENAME=$(echo $TRI | cut -f 1 -d '.') |
|
|
|
|
|
|
|
|
|
|
|
#TODO: implement tree command |
|
|
|
printf "${YLLW}[INFO] Compiling file: $FILENAME.tri to $FILENAME.tam ...${NC}\n" |
|
|
|
printf "${GRN}[INFO] Compiling file: $FILENAME.tri to $FILENAME.tam ...${NC}\n" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Compile to tam |
|
|
|
# Compile to tam |
|
|
|
if java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam &> /dev/null #quiet |
|
|
|
if java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam &> /dev/null #quiet |
|
|
|
then if [ -z "$2" ] |
|
|
|
then if [ -z "$2" ] |
|
|
|
then #if empty |
|
|
|
then #if second arg empty (really im not checking if you put tree) |
|
|
|
printf "${GRN}[INFO] Running file: $FILENAME.tam ...${NC}\n" |
|
|
|
printf "${GRN}[INFO] Running file: $FILENAME.tam ...${NC}\n" |
|
|
|
java -cp ../build/libs/Triangle-Tools.jar triangle.abstractMachine.Interpreter $FILENAME.tam |
|
|
|
java -cp ../build/libs/Triangle-Tools.jar triangle.abstractMachine.Interpreter $FILENAME.tam |
|
|
|
exit 0 |
|
|
|
exit 0 |
|
|
|
else |
|
|
|
else #youve put tree, so lets see it! |
|
|
|
printf "${GRN}[INFO] Running file: $FILENAME.tam ... and displaying AST${NC}\n" |
|
|
|
printf "${GRN}[INFO] Running file: $FILENAME.tam ... and displaying AST${NC}\n" |
|
|
|
java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri tree -o=$FILENAME.tam &> /dev/null #quiet |
|
|
|
java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri tree -o=$FILENAME.tam &> /dev/null #quiet |
|
|
|
exit 0 |
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
else #error msg |
|
|
|
else |
|
|
|
|
|
|
|
printf "${RED}[ERROR] Could not complie $FILENAME.tri ...${NC}" |
|
|
|
printf "${RED}[ERROR] Could not complie $FILENAME.tri ...${NC}" |
|
|
|
err=$(java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam) |
|
|
|
err=$(java -cp ../build/libs/Triangle-Tools.jar triangle.Compiler $FILENAME.tri -o=$FILENAME.tam) |
|
|
|
printf "${RED}\n$err\n${NC}" |
|
|
|
printf "${RED}\n$err\n${NC}" |
|
|
|
exit 1 |
|
|
|
exit 1 #exit with 1, failure |
|
|
|
fi |
|
|
|
fi |
|
|
|