diff --git a/Triangle.Compiler/src/main/java/triangle/StdEnvironment.java b/Triangle.Compiler/src/main/java/triangle/StdEnvironment.java index 90507d0..cc8742e 100644 --- a/Triangle.Compiler/src/main/java/triangle/StdEnvironment.java +++ b/Triangle.Compiler/src/main/java/triangle/StdEnvironment.java @@ -42,5 +42,8 @@ public final class StdEnvironment { public static ProcDeclaration getDecl, putDecl, getintDecl, putintDecl, geteolDecl, puteolDecl; public static FuncDeclaration chrDecl, ordDecl, eolDecl, eofDecl; + + //keep the bar separate for practical 3 (week 3) work! + public static UnaryOperatorDeclaration barDecl; } diff --git a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java index 8b05b53..18e3c63 100644 --- a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java +++ b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java @@ -953,7 +953,11 @@ public final class Checker implements ActualParameterVisitor=", StdEnvironment.integerType, StdEnvironment.integerType, StdEnvironment.booleanType); + + //add the new bar operator! + StdEnvironment.barDecl = declareStdUnaryOp("|", StdEnvironment.integerType, StdEnvironment.integerType); + StdEnvironment.charDecl = declareStdType("Char", StdEnvironment.charType); StdEnvironment.chrDecl = declareStdFunc("chr", new SingleFormalParameterSequence( diff --git a/Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Parser.java b/Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Parser.java index 4892dcb..7b57985 100644 --- a/Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Parser.java +++ b/Triangle.Compiler/src/main/java/triangle/syntacticAnalyzer/Parser.java @@ -929,3 +929,4 @@ public class Parser { return fieldAST; } } + diff --git a/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java b/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java index d521635..59b1f38 100644 --- a/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java +++ b/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java @@ -162,7 +162,10 @@ public class LayoutVisitor implements ActualParameterVisitor, @Override 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 diff --git a/build/libs/Triangle-Tools.jar b/build/libs/Triangle-Tools.jar index 4c3d7f4..788193a 100644 Binary files a/build/libs/Triangle-Tools.jar and b/build/libs/Triangle-Tools.jar differ