diff --git a/Triangle.Compiler/.project b/Triangle.Compiler/.project
index dca5b8c..1dea2e3 100644
--- a/Triangle.Compiler/.project
+++ b/Triangle.Compiler/.project
@@ -20,4 +20,11 @@
org.eclipse.jdt.core.javanature
org.eclipse.buildship.core.gradleprojectnature
+
+
+ programs
+ 2
+ /home/simon/Documents/Uni/CS/CSCU9A5-2/Ass1/src/a5-triangle-tools/programs
+
+
diff --git a/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/commands/LoopWhile.java b/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/commands/LoopWhile.java
new file mode 100644
index 0000000..a594907
--- /dev/null
+++ b/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/commands/LoopWhile.java
@@ -0,0 +1,41 @@
+/*
+ * @(#)WhileCommand.java
+ *
+ * Revisions and updates (c) 2022-2023 Sandy Brownlee. alexander.brownlee@stir.ac.uk
+ *
+ * Original release:
+ *
+ * Copyright (C) 1999, 2003 D.A. Watt and D.F. Brown
+ * Dept. of Computing Science, University of Glasgow, Glasgow G12 8QQ Scotland
+ * and School of Computer and Math Sciences, The Robert Gordon University,
+ * St. Andrew Street, Aberdeen AB25 1HG, Scotland.
+ * All rights reserved.
+ *
+ * This software is provided free for educational use only. It may
+ * not be used for commercial purposes without the prior written permission
+ * of the authors.
+ */
+
+package triangle.abstractSyntaxTrees.commands;
+
+import triangle.abstractSyntaxTrees.expressions.Expression;
+import triangle.abstractSyntaxTrees.visitors.CommandVisitor;
+import triangle.syntacticAnalyzer.SourcePosition;
+
+public class LoopWhile extends Command {
+
+ public LoopWhile(Expression eAST,Command c1AST, Command c2AST, SourcePosition position) {
+ super(position);
+ E = eAST;
+ C1 = c1AST;
+ C2 = c2AST;
+ }
+
+ public TResult visit(CommandVisitor v, TArg arg) {
+ return v.visitLoopWhile(this, arg);
+ }
+
+ public Expression E;
+ public final Command C1;
+ public final Command C2;
+}
diff --git a/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/visitors/CommandVisitor.java b/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/visitors/CommandVisitor.java
index 336c97d..6a74a76 100644
--- a/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/visitors/CommandVisitor.java
+++ b/Triangle.Compiler/src/main/java/triangle/abstractSyntaxTrees/visitors/CommandVisitor.java
@@ -5,6 +5,7 @@ import triangle.abstractSyntaxTrees.commands.CallCommand;
import triangle.abstractSyntaxTrees.commands.EmptyCommand;
import triangle.abstractSyntaxTrees.commands.IfCommand;
import triangle.abstractSyntaxTrees.commands.LetCommand;
+import triangle.abstractSyntaxTrees.commands.LoopWhile;
import triangle.abstractSyntaxTrees.commands.SequentialCommand;
import triangle.abstractSyntaxTrees.commands.WhileCommand;
@@ -24,4 +25,6 @@ public interface CommandVisitor {
TResult visitWhileCommand(WhileCommand ast, TArg arg);
+ TResult visitLoopWhile(LoopWhile loopWhile, TArg arg);
+
}
diff --git a/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java b/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
index c883070..7d1fd6e 100644
--- a/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
+++ b/Triangle.Compiler/src/main/java/triangle/codeGenerator/Encoder.java
@@ -42,6 +42,7 @@ import triangle.abstractSyntaxTrees.commands.CallCommand;
import triangle.abstractSyntaxTrees.commands.EmptyCommand;
import triangle.abstractSyntaxTrees.commands.IfCommand;
import triangle.abstractSyntaxTrees.commands.LetCommand;
+import triangle.abstractSyntaxTrees.commands.LoopWhile;
import triangle.abstractSyntaxTrees.commands.SequentialCommand;
import triangle.abstractSyntaxTrees.commands.WhileCommand;
import triangle.abstractSyntaxTrees.declarations.BinaryOperatorDeclaration;
@@ -793,4 +794,10 @@ public final class Encoder implements ActualParameterVisitor,
var baseObject = (AddressableEntity) V.visit(this, frame);
baseObject.encodeFetchAddress(emitter, frame, V);
}
+
+ @Override
+ public Void visitLoopWhile(LoopWhile loopWhile, Frame arg) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
index d06813e..0fbbde0 100644
--- a/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
+++ b/Triangle.Compiler/src/main/java/triangle/contextualAnalyzer/Checker.java
@@ -38,6 +38,7 @@ import triangle.abstractSyntaxTrees.commands.CallCommand;
import triangle.abstractSyntaxTrees.commands.EmptyCommand;
import triangle.abstractSyntaxTrees.commands.IfCommand;
import triangle.abstractSyntaxTrees.commands.LetCommand;
+import triangle.abstractSyntaxTrees.commands.LoopWhile;
import triangle.abstractSyntaxTrees.commands.SequentialCommand;
import triangle.abstractSyntaxTrees.commands.WhileCommand;
import triangle.abstractSyntaxTrees.declarations.BinaryOperatorDeclaration;
@@ -981,4 +982,10 @@ public final class Checker implements ActualParameterVisitor", "", "", "", "array",
- "begin", "const", "do", "else", "end", "func", "if", "in", "let", "of", "proc", "record", "then", "type",
+ "begin", "const", "do", "else", "end", "func", "if", "in", "let", "loop", "of", "proc", "record", "then", "type",
"var", "while", ".", ":", ";", ",", ":=", "~", "(", ")", "[", "]", "{", "}", "", "" };
private final static int firstReservedWord = Token.ARRAY, lastReservedWord = Token.WHILE;
diff --git a/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java b/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java
index b5ffec0..00a5e30 100644
--- a/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java
+++ b/Triangle.Compiler/src/main/java/triangle/treeDrawer/LayoutVisitor.java
@@ -37,6 +37,7 @@ import triangle.abstractSyntaxTrees.commands.CallCommand;
import triangle.abstractSyntaxTrees.commands.EmptyCommand;
import triangle.abstractSyntaxTrees.commands.IfCommand;
import triangle.abstractSyntaxTrees.commands.LetCommand;
+import triangle.abstractSyntaxTrees.commands.LoopWhile;
import triangle.abstractSyntaxTrees.commands.SequentialCommand;
import triangle.abstractSyntaxTrees.commands.WhileCommand;
import triangle.abstractSyntaxTrees.declarations.BinaryOperatorDeclaration;
@@ -681,4 +682,10 @@ public class LayoutVisitor implements ActualParameterVisitor,
return r;
}
+ @Override
+ public DrawingTree visitLoopWhile(LoopWhile loopWhile, Void arg) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
\ No newline at end of file
diff --git a/build/libs/Triangle-Tools.jar b/build/libs/Triangle-Tools.jar
index 80f2a9c..8644910 100644
Binary files a/build/libs/Triangle-Tools.jar and b/build/libs/Triangle-Tools.jar differ
diff --git a/every.tri b/every.tri
new file mode 100644
index 0000000..1d7f501
Binary files /dev/null and b/every.tri differ
diff --git a/loopwhile.tam b/loopwhile.tam
new file mode 100644
index 0000000..7091eac
Binary files /dev/null and b/loopwhile.tam differ
diff --git a/programs/checkstats.tri b/programs/checkstats.tri
index 1cf7cfe..3ebfe70 100644
--- a/programs/checkstats.tri
+++ b/programs/checkstats.tri
@@ -2,17 +2,11 @@ let
var a : Integer;
var b : Integer;
var c : Integer;
-
var x : Char;
var y : Char
in
{
- a := 1;
- b := 2;
- a**;
-
+ a := 1; b := 2; a**;
b := 100;
-
- x := 'A';
- y := 'Z';
+ x := 'A'; y := 'Z';
}
diff --git a/programs/loopwhile.tri b/programs/loopwhile.tri
new file mode 100644
index 0000000..3f6f2fc
--- /dev/null
+++ b/programs/loopwhile.tri
@@ -0,0 +1,16 @@
+! print out ababababa
+
+let
+ var a : Integer
+in
+begin
+ a := 0;
+ loop
+ begin
+ put('a');
+ a := a + 1;
+ end
+ while a < 5 do
+ put('b');
+
+end