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

@ -42,5 +42,8 @@ public final class StdEnvironment {
public static ProcDeclaration getDecl, putDecl, getintDecl, putintDecl, geteolDecl, puteolDecl; public static ProcDeclaration getDecl, putDecl, getintDecl, putintDecl, geteolDecl, puteolDecl;
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;
} }

@ -953,7 +953,11 @@ public final class Checker implements ActualParameterVisitor<FormalParameter, Vo
StdEnvironment.booleanType); StdEnvironment.booleanType);
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.