end of prac3 no bonus

main
simonkellet 1 year ago
parent 841a7c9af2
commit b1da248676
  1. 13
      Triangle.Compiler/.settings/org.eclipse.buildship.core.prefs
  2. 4
      Triangle.Compiler/src/main/java/triangle/StdEnvironment.java
  3. 3
      Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
  4. 4
      Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java
  5. BIN
      build/libs/Triangle-Tools.jar
  6. 21
      programs/run

@ -1,2 +1,13 @@
connection.project.dir=..
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(LOCAL_INSTALLATION(/usr/share/java/gradle))
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=/usr/lib/jvm/java-11-openjdk
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true

@ -34,7 +34,7 @@ public final class StdEnvironment {
public static ConstDeclaration falseDecl, trueDecl, maxintDecl;
public static UnaryOperatorDeclaration notDecl;
public static UnaryOperatorDeclaration notDecl, barDecl;
public static BinaryOperatorDeclaration andDecl, orDecl, addDecl, subtractDecl, multiplyDecl, divideDecl,
moduloDecl, equalDecl, unequalDecl, lessDecl, notlessDecl, greaterDecl, notgreaterDecl;
@ -43,4 +43,6 @@ public final class StdEnvironment {
public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl;
//public static Object barDecl;
}

@ -953,6 +953,9 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
StdEnvironment.booleanType);
StdEnvironment.notlessDecl = declareStdBinaryOp(">=", StdEnvironment.integerType, StdEnvironment.integerType,
StdEnvironment.booleanType);
//PRAC3 # Here we are adding the barDecl, Unary op. that takes 1 val and returns 1 val
StdEnvironment.barDecl = declareStdUnaryOp("|", StdEnvironment.integerType, StdEnvironment.integerType);
StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType);
StdEnvironment.chrDecl = declareStdFunc("chr",

@ -162,7 +162,9 @@ public class LayoutVisitor implements ActualParameterVisitor<Void, DrawingTree>,
@Override
public DrawingTree visitRepeatCommand(RepeatCommand ast, Void obj) {
return null;
var d1 = ast.E.visit(this);
var d2 = ast.C.visit(this);
return layoutBinary("RepeatCom.", d1, d2);
}
// Expressions

Binary file not shown.

@ -1,16 +1,17 @@
#!/bin/bash
# Term colours for output
# 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="" #.tri file
# Check if the input in arg 1 ($1) is empty
if [ -z "$1" ]
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
else
TRI=$1
@ -19,25 +20,23 @@ fi
#Remove the extension of the file
FILENAME=$(echo $TRI | cut -f 1 -d '.')
#TODO: implement tree command
printf "${GRN}[INFO] Compiling file: $FILENAME.tri to $FILENAME.tam ...${NC}\n"
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 empty
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
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
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 1 #exit with 1, failure
fi

Loading…
Cancel
Save