From c3c2076d9ef0934b98b3d9103727888a9c8259a6 Mon Sep 17 00:00:00 2001 From: Sandy Brownlee Date: Fri, 9 Sep 2022 16:33:13 +0100 Subject: [PATCH] repeat until --- .../triangle/syntacticAnalyser/TestScanner.java | 6 ++++++ programs/pounddemo.tri | 15 --------------- programs/repeatuntil.tri | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 15 deletions(-) delete mode 100644 programs/pounddemo.tri create mode 100644 programs/repeatuntil.tri diff --git a/Triangle.Compiler/src/test/java/triangle/syntacticAnalyser/TestScanner.java b/Triangle.Compiler/src/test/java/triangle/syntacticAnalyser/TestScanner.java index e46ed5d..2959676 100644 --- a/Triangle.Compiler/src/test/java/triangle/syntacticAnalyser/TestScanner.java +++ b/Triangle.Compiler/src/test/java/triangle/syntacticAnalyser/TestScanner.java @@ -37,6 +37,12 @@ public class TestScanner { compileExpectFailure("/pounddemo.tri"); } + + @Test + public void testRepeatUntil() { + compileExpectFailure("/repeatuntil.tri"); + } + private void compileExpectSuccess(String filename) { diff --git a/programs/pounddemo.tri b/programs/pounddemo.tri deleted file mode 100644 index 67b42ae..0000000 --- a/programs/pounddemo.tri +++ /dev/null @@ -1,15 +0,0 @@ -! this won't work until after some work in the practicals -let - var a : Integer; - var b : Integer - -in - begin - a := 1; - b := 2; - - putint(a) - putint(b) - putint(£a) - putint(£b) - end \ No newline at end of file diff --git a/programs/repeatuntil.tri b/programs/repeatuntil.tri new file mode 100644 index 0000000..316493f --- /dev/null +++ b/programs/repeatuntil.tri @@ -0,0 +1,14 @@ +! this won't work until after some lab work + +let + var a : Integer +in +begin + a := 0; + repeat + begin + put('a'); + a := a + 1; + end + until a < 5 +end