some changes + on macos now

main
Simon Kellet 1 year ago
parent c505b9cb2c
commit 69a24132d3
  1. 2
      Triangle.Compiler/.project
  2. 4
      Triangle.Compiler/src/main/java/triangle/optimiser/ConstantFolder.java
  3. BIN
      booleanfold.tam
  4. BIN
      build/libs/Triangle-Tools.jar
  5. 0
      gradlew
  6. 35
      programs/booleans-to-fold.tri
  7. 42
      programs/run

@ -24,7 +24,7 @@
<link> <link>
<name>programs</name> <name>programs</name>
<type>2</type> <type>2</type>
<location>/home/simon/Documents/Uni/CS/CSCU9A5-2/Ass1/src/a5-triangle-tools/programs</location> <location>/Users/simon/Library/CloudStorage/GoogleDrive-fearrising404@gmail.com/My Drive/Uni/CS/CSCU9A5-2/Ass1/src/a5-triangle-tools/programs</location>
</link> </link>
</linkedResources> </linkedResources>
</projectDescription> </projectDescription>

@ -600,8 +600,12 @@ public class ConstantFolder implements ActualParameterVisitor<Void, AbstractSynt
ie.type = StdEnvironment.integerType; ie.type = StdEnvironment.integerType;
return ie; return ie;
} else if (foldedValue instanceof Boolean) { } else if (foldedValue instanceof Boolean) {
//Task 7?
System.out.println("Boolean Expr. ");
/* currently not handled! */ /* currently not handled! */
} }
} else {
//?
} }
// any unhandled situation (i.e., not foldable) is ignored // any unhandled situation (i.e., not foldable) is ignored

Binary file not shown.

Binary file not shown.

@ -0,0 +1,35 @@
let
var b: Boolean
in
begin
b := 1 < 3;
if b
then put('t')
else put('f');
puteol();
b := 1 > 3;
if b
then put('t')
else put('f');
puteol();
b := 2 >= 1;
if b
then put('t')
else put('f');
puteol();
b := 2 < 1;
if b
then put('t')
else put('f');
end

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