end of practical3 (no bonus)

java11
simonkellet 2 years ago
parent 4341d02572
commit e1268aae42
  1. 3
      Triangle.Compiler/src/main/java/triangle/StdEnvironment.java
  2. 4
      Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
  3. 1
      Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Parser.java
  4. 5
      Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java
  5. BIN
      build/libs/Triangle-Tools.jar

@ -43,4 +43,7 @@ public final class StdEnvironment {
public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl; public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl;
//keep the bar separate for practical 3 (week 3) work!
public static UnaryOperatorDeclaration barDecl;
} }

@ -954,6 +954,10 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
StdEnvironment.notlessDecl = declareStdBinaryOp(">=", StdEnvironment.integerType, StdEnvironment.integerType, StdEnvironment.notlessDecl = declareStdBinaryOp(">=", StdEnvironment.integerType, StdEnvironment.integerType,
StdEnvironment.booleanType); StdEnvironment.booleanType);
//add the new bar operator!
StdEnvironment.barDecl = declareStdUnaryOp("|", StdEnvironment.integerType, StdEnvironment.integerType);
StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType); StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType);
StdEnvironment.chrDecl = declareStdFunc("chr", StdEnvironment.chrDecl = declareStdFunc("chr",
new SingleFormalParameterSequence( new SingleFormalParameterSequence(

@ -929,3 +929,4 @@ public class Parser {
return fieldAST; return fieldAST;
} }
} }

@ -162,7 +162,10 @@ public class LayoutVisitor implements ActualParameterVisitor<Void, DrawingTree>,
@Override @Override
public DrawingTree visitRepeatCommand(RepeatCommand ast, Void obj) { public DrawingTree visitRepeatCommand(RepeatCommand ast, Void obj) {
return null; //very similar to the while cmd, just reverse!
var d1 = ast.C.visit(this);
var d2 = ast.E.visit(this);
return layoutBinary("Repeat.Com.", d1, d2);
} }
// Expressions // Expressions

Binary file not shown.