diff --git a/Module6/SimpleLex.lex b/Module6/SimpleLex.lex
index ce5014b7d48efeca968d2d2d4b1c97d3c3da51f4..4b3b5fb68c311ceb80ef8688a76256248a4c2c35 100644
--- a/Module6/SimpleLex.lex
+++ b/Module6/SimpleLex.lex
@@ -51,16 +51,16 @@ ID {Alpha}{AlphaDigit}*
 
 %%
 
-public override void yyerror(string format, params object[] args) // обработка синтаксических ошибок
+public override void yyerror(string format, params object[] args) // пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ
 {
   var ww = args.Skip(1).Cast<string>().ToArray();
-  string errorMsg = string.Format("({0},{1}): Встречено {2}, а ожидалось {3}", yyline, yycol, args[0], string.Join(" или ", ww));
+  string errorMsg = string.Format("({0},{1}): пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ {2}, пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ {3}", yyline, yycol, args[0], string.Join(" пїЅпїЅпїЅ ", ww));
   throw new SyntaxException(errorMsg);
 }
 
 public void LexError()
 {
-  string errorMsg = string.Format("({0},{1}): Неизвестный символ {2}", yyline, yycol, yytext);
+  string errorMsg = string.Format("({0},{1}): пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ {2}", yyline, yycol, yytext);
   throw new LexException(errorMsg);
 }
 
@@ -74,7 +74,7 @@ class ScannerHelper
     keywords.Add("begin",(int)Tokens.BEGIN);
     keywords.Add("end",(int)Tokens.END);
     keywords.Add("cycle",(int)Tokens.CYCLE);
-	keywords.Add("do",(int)Tokens.DO);
+	  keywords.Add("do",(int)Tokens.DO);
     keywords.Add("repeat",(int)Tokens.REPEAT);
     keywords.Add("until",(int)Tokens.UNTIL);
     keywords.Add("for",(int)Tokens.FOR);
diff --git a/Module8/ProgramTree.cs b/Module8/ProgramTree.cs
index 500e94046a9d2b86cf850b1525f5933157af86bc..4dff6b7505a93c28731af5762d3b3ac5706affbe 100644
--- a/Module8/ProgramTree.cs
+++ b/Module8/ProgramTree.cs
@@ -145,10 +145,11 @@ namespace ProgramTree
 
     public class IfNode : StatementNode
     {
-        public ExprNode expr;
-        public StatementNode ifTrue, ifFalse;
+        public ExprNode expr { get; set; }
+        public StatementNode ifTrue { get; set; }
+        public StatementNode ifFalse { get; set; }
 
-        public IfNode(ExprNode expr, StatementNode ifTrue, StatementNode ifFalse = null)
+    public IfNode(ExprNode expr, StatementNode ifTrue, StatementNode ifFalse = null)
         {
             this.expr = expr;
             this.ifTrue = ifTrue;
@@ -160,4 +161,56 @@ namespace ProgramTree
             v.VisitIfNode(this);
         }
     }
+
+    public class WhileNode : StatementNode
+    {
+        public ExprNode expr { get; set; }
+        public StatementNode stat { get; set; }
+
+        public WhileNode(ExprNode expr, StatementNode stat)
+        {
+            this.expr = expr;
+            this.stat = stat;
+           
+        }
+
+        public override void Visit(Visitor v)
+        {
+            v.VisitWhileNode(this);
+        }
+    }
+
+
+    public class RepeatNode : StatementNode
+    {
+        public ExprNode expr { get; set; }
+        public List<StatementNode> stats = new List<StatementNode>();
+
+        public RepeatNode(BlockNode block , ExprNode expr)
+        {
+            this.expr = expr;
+            stats.AddRange(block.StList);
+        }
+
+        public RepeatNode(StatementNode stat)
+        {
+            stats.Add(stat);
+        }
+
+        public void Add(StatementNode stat)
+        {
+            stats.Add(stat);
+        }
+
+        public void AddExpr(ExprNode expr)
+        {
+            this.expr = expr;
+        }
+
+        public override void Visit(Visitor v)
+        {
+            v.VisitRepeatNode(this);
+        }
+    }
+
 }
\ No newline at end of file
diff --git a/Module8/SimpleLex.cs b/Module8/SimpleLex.cs
index 124489e2d753e8ffee406427501b40410d8779db..99e3cf8093856a92632a7cb992a2d2806314bad7 100644
--- a/Module8/SimpleLex.cs
+++ b/Module8/SimpleLex.cs
@@ -1,14 +1,10 @@
 //
 //  This CSharp output file generated by Gardens Point LEX
-//  Gardens Point LEX (GPLEX) is Copyright (c) John Gough, QUT 2006-2014.
-//  Output produced by GPLEX is the property of the user.
-//  See accompanying file GPLEXcopyright.rtf.
-//
-//  GPLEX Version:  1.2.2
-//  Machine:  MAINHOMEPC2
-//  DateTime: 30.09.2018 18:23:21
-//  UserName: someone
-//  GPLEX input file <SimpleLex.lex - 30.09.2018 18:22:46>
+//  Version:  1.1.3.301
+//  Machine:  LAPTOP-DB9EH0OL
+//  DateTime: 17.10.2022 0:19:13
+//  UserName: Anton
+//  GPLEX input file <SimpleLex.lex>
 //  GPLEX frame file <embedded resource>
 //
 //  Option settings: unicode, parser, minimize
@@ -17,8 +13,8 @@
 //
 
 //
-// Revised backup code
-// Version 1.2.1 of 24-June-2013
+// Experimental embedded frame
+// Version 1.1.3 of 18-April-2010
 //
 //
 #define BACKUP
@@ -127,8 +123,8 @@ namespace SimpleScanner
         
         enum Result {accept, noMatch, contextFound};
 
-        const int maxAccept = 17;
-        const int initial = 18;
+        const int maxAccept = 18;
+        const int initial = 19;
         const int eofNum = 0;
         const int goStart = -1;
         const int INITIAL = 0;
@@ -165,24 +161,24 @@ namespace SimpleScanner
         }
     };
 
-    static int[] startState = new int[] {18, 0};
+    static int[] startState = new int[] {19, 0};
 
 #region CompressedCharacterMap
     //
-    // There are 15 equivalence classes
+    // There are 16 equivalence classes
     // There are 2 character sequence regions
     // There are 1 tables, 123 entries
     // There are 1 runs, 0 singletons
     // Decision tree depth is 1
     //
     static sbyte[] mapC0 = new sbyte[123] {
-/*     '\0' */ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 0, 14, 14, 0, 14, 14, 
-/*   '\x10' */ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 
-/*   '\x20' */ 0, 14, 14, 14, 14, 14, 14, 14, 11, 12, 9, 8, 13, 7, 2, 10, 
-/*      '0' */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 14, 5, 14, 14, 
-/*      '@' */ 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
-/*      'P' */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 14, 14, 14, 14, 3, 
-/*      '`' */ 14, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
+/*     '\0' */ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 15, 15, 0, 15, 15, 
+/*   '\x10' */ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
+/*   '\x20' */ 0, 15, 15, 15, 15, 14, 15, 15, 11, 12, 9, 8, 13, 7, 2, 10, 
+/*      '0' */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 15, 5, 15, 15, 
+/*      '@' */ 15, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
+/*      'P' */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 15, 15, 15, 15, 3, 
+/*      '`' */ 15, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
 /*      'p' */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
 
     static sbyte MapC(int code)
@@ -190,20 +186,20 @@ namespace SimpleScanner
       if (code < 123) // '\0' <= code <= 'z'
         return mapC0[code - 0];
       else // '{' <= code <= '\U0010FFFF'
-        return (sbyte)14;
+        return (sbyte)15;
     }
 #endregion
 
-    static Table[] NxS = new Table[20] {
+    static Table[] NxS = new Table[21] {
 /* NxS[   0] */ new Table(0, 0, 0, null),
-/* NxS[   1] */ new Table(1, 2, -1, new sbyte[] {1, 19}),
+/* NxS[   1] */ new Table(1, 2, -1, new sbyte[] {1, 20}),
 /* NxS[   2] */ new Table(0, 0, -1, null),
 /* NxS[   3] */ new Table(1, 3, -1, new sbyte[] {3, -1, 3}),
-/* NxS[   4] */ new Table(5, 1, -1, new sbyte[] {16}),
+/* NxS[   4] */ new Table(5, 1, -1, new sbyte[] {17}),
 /* NxS[   5] */ new Table(0, 0, -1, null),
-/* NxS[   6] */ new Table(5, 1, -1, new sbyte[] {15}),
-/* NxS[   7] */ new Table(5, 1, -1, new sbyte[] {14}),
-/* NxS[   8] */ new Table(5, 1, -1, new sbyte[] {13}),
+/* NxS[   6] */ new Table(5, 1, -1, new sbyte[] {16}),
+/* NxS[   7] */ new Table(5, 1, -1, new sbyte[] {15}),
+/* NxS[   8] */ new Table(5, 1, -1, new sbyte[] {14}),
 /* NxS[   9] */ new Table(0, 0, -1, null),
 /* NxS[  10] */ new Table(0, 0, -1, null),
 /* NxS[  11] */ new Table(0, 0, -1, null),
@@ -212,10 +208,11 @@ namespace SimpleScanner
 /* NxS[  14] */ new Table(0, 0, -1, null),
 /* NxS[  15] */ new Table(0, 0, -1, null),
 /* NxS[  16] */ new Table(0, 0, -1, null),
-/* NxS[  17] */ new Table(1, 1, -1, new sbyte[] {17}),
-/* NxS[  18] */ new Table(1, 14, -1, new sbyte[] {1, 2, 3, 4, 2, 5, 
-          6, 7, 8, 9, 10, 11, 12, 2}),
-/* NxS[  19] */ new Table(1, 1, -1, new sbyte[] {17}),
+/* NxS[  17] */ new Table(0, 0, -1, null),
+/* NxS[  18] */ new Table(1, 1, -1, new sbyte[] {18}),
+/* NxS[  19] */ new Table(1, 15, -1, new sbyte[] {1, 2, 3, 4, 2, 5, 
+          6, 7, 8, 9, 10, 11, 12, 13, 2}),
+/* NxS[  20] */ new Table(1, 1, -1, new sbyte[] {18}),
     };
 
 int NextState() {
@@ -225,7 +222,7 @@ int NextState() {
         unchecked {
             int rslt;
             int idx = MapC(code) - NxS[state].min;
-            if (idx < 0) idx += 15;
+            if (idx < 0) idx += 16;
             if ((uint)idx >= (uint)NxS[state].rng) rslt = NxS[state].dflt;
             else rslt = NxS[state].nxt[idx];
             return rslt;
@@ -305,7 +302,8 @@ int NextState() {
 
         public Scanner(Stream file, string codepage) {
             SetSource(file, CodePageHandling.GetCodePage(codepage));
-        }   
+        }
+        
 #endif // !NOFILES
 
      public Scanner() { }
@@ -333,7 +331,7 @@ int NextState() {
                     if (next < 0xDC00 || next > 0xDFFF)
                         code = ScanBuff.UnicodeReplacementChar;
                     else
-                        code = (0x10000 + ((code & 0x3FF) << 10) + (next & 0x3FF));
+                        code = (0x10000 + (code & 0x3FF << 10) + (next & 0x3FF));
                 }
 #endif
                 cCol++;
@@ -386,7 +384,9 @@ int NextState() {
             GetCode();
         }
 
+#if !NOFILES        
         // ================ LineBuffer Initialization ===================
+
         /// <summary>
         /// Create and initialize a LineBuff buffer object for this scanner
         /// </summary>
@@ -400,7 +400,6 @@ int NextState() {
             GetCode();
         }
 
-#if !NOFILES        
         // =============== StreamBuffer Initialization ==================
 
         /// <summary>
@@ -502,12 +501,6 @@ int NextState() {
             }
         }
 
-        /// <summary>
-        /// Discards all but the first "n" codepoints in the recognized pattern.
-        /// Resets the buffer position so that only n codepoints have been consumed;
-        /// yytext is also re-evaluated. 
-        /// </summary>
-        /// <param name="n">The number of codepoints to consume</param>
         [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
         void yyless(int n)
         {
@@ -527,10 +520,6 @@ int NextState() {
         //  but it does not seem possible to re-establish
         //  the correct column counts except by going forward.
         //
-        /// <summary>
-        /// Removes the last "n" code points from the pattern.
-        /// </summary>
-        /// <param name="n">The number to remove</param>
         [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
         void _yytrunc(int n) { yyless(yyleng - n); }
         
@@ -543,23 +532,18 @@ int NextState() {
         // can't use (tokEPos - tokPos) because of the
         // possibility of surrogate pairs in the token.
         //
-        /// <summary>
-        /// The length of the pattern in codepoints (not the same as 
-        /// string-length if the pattern contains any surrogate pairs).
-        /// </summary>
         [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
         [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "yyleng")]
         [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "yyleng")]
         public int yyleng
         {
             get {
+#if BYTEMODE
+                return tokEPos - tokPos;
+#else   
                 if (tokELin == tokLin)
                     return tokECol - tokCol;
-                else
-#if BYTEMODE
-                    return tokEPos - tokPos;
-#else
-                {
+                else {
                     int ch;
                     int count = 0;
                     int save = buffer.Pos;
@@ -568,7 +552,7 @@ int NextState() {
                         ch = buffer.Read();
                         if (!char.IsHighSurrogate((char)ch)) count++;
                     } while (buffer.Pos < tokEPos && ch != ScanBuff.EndOfFile);
-                    buffer.Pos = save;
+                    buffer.Pos = save; 
                     return count;
                 }
 #endif // BYTEMODE
@@ -593,56 +577,65 @@ int NextState() {
 
         // ============== The main tokenizer code =================
 
-        int Scan() {
+        int Scan()
+        {
             try {
-                for (; ; ) {
-                    int next;              // next state to enter
+                for (; ; )
+                {
+                    int next;              // next state to enter                   
+#if BACKUP
+                    Result rslt = Result.noMatch;
+#endif // BACKUP
 #if LEFTANCHORS
-                    for (;;) {
+                    for (;;)
+                    {
                         // Discard characters that do not start any pattern.
                         // Must check the left anchor condition after *every* GetCode!
                         state = ((cCol == 0) ? anchorState[currentScOrd] : currentStart);
-                        if ((next = NextState()) != goStart) break; // LOOP EXIT HERE...
+                        if ((next = NextState()) != goStart) 
+                            break; // LOOP EXIT HERE...
                         GetCode();
                     }
                     
 #else // !LEFTANCHORS
                     state = currentStart;
-                    while ((next = NextState()) == goStart) {
+                    while ((next = NextState()) == goStart)
                         // At this point, the current character has no
                         // transition from the current state.  We discard 
                         // the "no-match" char.   In traditional LEX such 
                         // characters are echoed to the console.
                         GetCode();
-                    }
 #endif // LEFTANCHORS                    
                     // At last, a valid transition ...    
                     MarkToken();
                     state = next;
-                    GetCode();                    
+                    GetCode();
+                    
+                    while ((next = NextState()) > eofNum) // Exit for goStart AND for eofNum
 #if BACKUP
-                    bool contextSaved = false;
-                    while ((next = NextState()) > eofNum) { // Exit for goStart AND for eofNum
-                        if (state <= maxAccept && next > maxAccept) { // need to prepare backup data
-                            // Store data for the *latest* accept state that was found.
-                            SaveStateAndPos( ref ctx );
-                            contextSaved = true;
+                        if (state <= maxAccept && next > maxAccept) // need to prepare backup data
+                        {
+                            // ctx is an object. The fields may be 
+                            // mutated by the call to Recurse2.
+                            // On return the data in ctx is the
+                            // *latest* accept state that was found.
+                            
+                            rslt = Recurse2(ref ctx, next);
+                            if (rslt == Result.noMatch) 
+                                RestoreStateAndPos(ref ctx);
+                            break;
                         }
-                        state = next;
-                        GetCode();
-                    }
-                    if (state > maxAccept && contextSaved)
-                        RestoreStateAndPos( ref ctx );
-#else  // BACKUP
-                    while ((next = NextState()) > eofNum) { // Exit for goStart AND for eofNum
-                         state = next;
-                         GetCode();
-                    }
+                        else
 #endif // BACKUP
-                    if (state <= maxAccept) {
+                        {
+                            state = next;
+                            GetCode();
+                        }
+                    if (state <= maxAccept) 
+                    {
                         MarkEnd();
 #region ActionSwitch
-#pragma warning disable 162, 1522
+#pragma warning disable 162
     switch (state)
     {
         case eofNum:
@@ -688,25 +681,28 @@ return (int)Tokens.RPAREN;
 return (int)Tokens.COLUMN;
             break;
         case 13:
-return (int)Tokens.ASSIGNMULT;
+return (int)Tokens.MOD;
             break;
         case 14:
-return (int)Tokens.ASSIGNPLUS;
+return (int)Tokens.ASSIGNMULT;
             break;
         case 15:
-return (int)Tokens.ASSIGNMINUS;
+return (int)Tokens.ASSIGNPLUS;
             break;
         case 16:
-return (int)Tokens.ASSIGN;
+return (int)Tokens.ASSIGNMINUS;
             break;
         case 17:
+return (int)Tokens.ASSIGN;
+            break;
+        case 18:
 yylval.dVal = double.Parse(yytext); 
   return (int)Tokens.RNUM;
             break;
         default:
             break;
     }
-#pragma warning restore 162, 1522
+#pragma warning restore 162
 #endregion
                     }
                 }
@@ -719,7 +715,29 @@ yylloc = new LexLocation(tokLin, tokCol, tokELin, tokECol);
         }
 
 #if BACKUP
-        void SaveStateAndPos(ref Context ctx) {
+        Result Recurse2(ref Context ctx, int next)
+        {
+            // Assert: at entry "state" is an accept state AND
+            //         NextState(state, code) != goStart AND
+            //         NextState(state, code) is not an accept state.
+            //
+            SaveStateAndPos(ref ctx);
+            state = next;
+            GetCode();
+
+            while ((next = NextState()) > eofNum)
+            {
+                if (state <= maxAccept && next > maxAccept) // need to update backup data
+                    SaveStateAndPos(ref ctx);
+                state = next;
+                if (state == eofNum) return Result.accept;
+                GetCode(); 
+            }
+            return (state <= maxAccept ? Result.accept : Result.noMatch);
+        }
+
+        void SaveStateAndPos(ref Context ctx)
+        {
             ctx.bPos  = buffer.Pos;
             ctx.rPos  = readPos;
             ctx.cCol  = cCol;
@@ -728,7 +746,8 @@ yylloc = new LexLocation(tokLin, tokCol, tokELin, tokECol);
             ctx.cChr  = code;
         }
 
-        void RestoreStateAndPos(ref Context ctx) {
+        void RestoreStateAndPos(ref Context ctx)
+        {
             buffer.Pos = ctx.bPos;
             readPos = ctx.rPos;
             cCol  = ctx.cCol;
@@ -736,7 +755,8 @@ yylloc = new LexLocation(tokLin, tokCol, tokELin, tokECol);
             state = ctx.state;
             code  = ctx.cChr;
         }
-#endif  // BACKUP
+
+#endif // BACKUP
 
         // ============= End of the tokenizer code ================
 
@@ -768,16 +788,16 @@ yylloc = new LexLocation(tokLin, tokCol, tokELin, tokECol);
         
 #region UserCodeSection
 
-public override void yyerror(string format, params object[] args) // îáðàáîòêà ñèíòàêñè÷åñêèõ îøèáîê
+public override void yyerror(string format, params object[] args) // обработка синтаксических ошибок
 {
   var ww = args.Skip(1).Cast<string>().ToArray();
-  string errorMsg = string.Format("({0},{1}): Âñòðå÷åíî {2}, à îæèäàëîñü {3}", yyline, yycol, args[0], string.Join(" èëè ", ww));
+  string errorMsg = string.Format("({0},{1}): Встречено {2}, а ожидалось {3}", yyline, yycol, args[0], string.Join(" или ", ww));
   throw new SyntaxException(errorMsg);
 }
 
 public void LexError()
 {
-  string errorMsg = string.Format("({0},{1}): Íåèçâåñòíûé ñèìâîë {2}", yyline, yycol, yytext);
+  string errorMsg = string.Format("({0},{1}): Неизвестный символ {2}", yyline, yycol, yytext);
   throw new LexException(errorMsg);
 }
 
@@ -793,6 +813,13 @@ class ScannerHelper
     keywords.Add("cycle",(int)Tokens.CYCLE);
     keywords.Add("write",(int)Tokens.WRITE);
     keywords.Add("var",(int)Tokens.VAR);
+    keywords.Add("do",(int)Tokens.DO);
+    keywords.Add("until",(int)Tokens.UNTIL);
+    keywords.Add("while",(int)Tokens.WHILE);
+    keywords.Add("repeat",(int)Tokens.REPEAT);
+    keywords.Add("if",(int)Tokens.IF);
+    keywords.Add("then",(int)Tokens.THEN);
+    keywords.Add("else",(int)Tokens.ELSE);
   }
   public static int GetIDToken(string s)
   {
@@ -853,7 +880,6 @@ class ScannerHelper
             return new LineBuffer(source);
         }
 
-#if (!NOFILES)
         public static ScanBuff GetBuffer(Stream source)
         {
             return new BuildBuffer(source);
@@ -864,8 +890,7 @@ class ScannerHelper
         {
             return new BuildBuffer(source, fallbackCodePage);
         }
-#endif // !BYTEMODE
-#endif // !NOFILES
+#endif
     }
 
     #region Buffer classes
@@ -988,7 +1013,7 @@ class ScannerHelper
             {
                 ix = lstart = 0;
             }
-            while (ix < numLines)
+            for (; ; )
             {
                 int len = line[ix].Length + 1;
                 if (pos < lstart + len) break;
@@ -1046,8 +1071,7 @@ class ScannerHelper
             {
                 cPos = value;
                 findIndex(cPos, out cLine, out curLineStart);
-                // cLine should be the *next* line after curLine.
-                curLine = (cLine < numLines ? line[cLine++] : "");
+                curLine = line[cLine];
                 curLineEnd = curLineStart + curLine.Length;
             }
         }
@@ -1055,7 +1079,7 @@ class ScannerHelper
         public override string ToString() { return "LineBuffer"; }
     }
 
-#if (!NOFILES)
+
     // ==============================================================
     // =====     class BuildBuff : for unicode text files    ========
     // ==============================================================
@@ -1296,13 +1320,12 @@ class ScannerHelper
         }
 #endif // !BYTEMODE
     }
-#endif // !NOFILES
     #endregion Buffer classes
 
     // ==============================================================
     // ============      class CodePageHandling         =============
     // ==============================================================
-#if (!NOFILES)
+
     public static class CodePageHandling
     {
         public static int GetCodePage(string option)
@@ -1513,7 +1536,6 @@ class ScannerHelper
     
 #endif // !BYTEMODE
 #endregion
-#endif // !NOFILES
 
 // End of code copied from embedded resource
 
diff --git a/Module8/SimpleLex.lex b/Module8/SimpleLex.lex
index 00dfa1249dd0572b3061e40d49d86058b4e1baee..6bed56ad5f946affe27c1ffba28357ed91c29243 100644
--- a/Module8/SimpleLex.lex
+++ b/Module8/SimpleLex.lex
@@ -42,6 +42,7 @@ ID {Alpha}{AlphaDigit}*
 "(" { return (int)Tokens.LPAREN; }
 ")" { return (int)Tokens.RPAREN; }
 "," { return (int)Tokens.COLUMN; }
+"%" { return (int)Tokens.MOD; }
 
 [^ \r\n] {
 	LexError();
@@ -78,6 +79,13 @@ class ScannerHelper
     keywords.Add("cycle",(int)Tokens.CYCLE);
     keywords.Add("write",(int)Tokens.WRITE);
     keywords.Add("var",(int)Tokens.VAR);
+    keywords.Add("do",(int)Tokens.DO);
+    keywords.Add("until",(int)Tokens.UNTIL);
+    keywords.Add("while",(int)Tokens.WHILE);
+    keywords.Add("repeat",(int)Tokens.REPEAT);
+    keywords.Add("if",(int)Tokens.IF);
+    keywords.Add("then",(int)Tokens.THEN);
+    keywords.Add("else",(int)Tokens.ELSE);
   }
   public static int GetIDToken(string s)
   {
diff --git a/Module8/SimpleYacc.cs b/Module8/SimpleYacc.cs
index 41990d1991abc1e5c84a48ae96c6d9f5381c4264..2259b9078ad9883e7e8ccfbe2f00881680a85c15 100644
--- a/Module8/SimpleYacc.cs
+++ b/Module8/SimpleYacc.cs
@@ -1,18 +1,17 @@
 // This code was generated by the Gardens Point Parser Generator
-// Copyright (c) Wayne Kelly, John Gough, QUT 2005-2014
+// Copyright (c) Wayne Kelly, QUT 2005-2010
 // (see accompanying GPPGcopyright.rtf)
 
-// GPPG version 1.5.2
-// Machine:  MAINHOMEPC2
-// DateTime: 30.09.2018 18:23:23
-// UserName: someone
-// Input file <SimpleYacc.y - 30.09.2018 18:22:38>
+// GPPG version 1.3.6
+// Machine:  LAPTOP-DB9EH0OL
+// DateTime: 17.10.2022 0:19:13
+// UserName: Anton
+// Input file <SimpleYacc.y>
 
 // options: no-lines gplex
 
 using System;
 using System.Collections.Generic;
-using System.CodeDom.Compiler;
 using System.Globalization;
 using System.Text;
 using QUT.Gppg;
@@ -21,10 +20,12 @@ using ProgramTree;
 
 namespace SimpleParser
 {
-public enum Tokens {error=2,EOF=3,BEGIN=4,END=5,CYCLE=6,
-    ASSIGN=7,ASSIGNPLUS=8,ASSIGNMINUS=9,ASSIGNMULT=10,SEMICOLON=11,WRITE=12,
-    VAR=13,PLUS=14,MINUS=15,MULT=16,DIV=17,LPAREN=18,
-    RPAREN=19,COLUMN=20,INUM=21,RNUM=22,ID=23};
+public enum Tokens {
+    error=1,EOF=2,BEGIN=3,END=4,CYCLE=5,ASSIGN=6,
+    ASSIGNPLUS=7,ASSIGNMINUS=8,ASSIGNMULT=9,SEMICOLON=10,WRITE=11,VAR=12,
+    PLUS=13,MINUS=14,MULT=15,DIV=16,LPAREN=17,RPAREN=18,
+    COLUMN=19,MOD=20,WHILE=21,DO=22,UNTIL=23,IF=24,
+    THEN=25,ELSE=26,REPEAT=27,INUM=28,RNUM=29,ID=30};
 
 public struct ValueType
 { 
@@ -37,124 +38,137 @@ public struct ValueType
 			public BlockNode blVal;
        }
 // Abstract base class for GPLEX scanners
-[GeneratedCodeAttribute( "Gardens Point Parser Generator", "1.5.2")]
 public abstract class ScanBase : AbstractScanner<ValueType,LexLocation> {
   private LexLocation __yylloc = new LexLocation();
   public override LexLocation yylloc { get { return __yylloc; } set { __yylloc = value; } }
   protected virtual bool yywrap() { return true; }
 }
 
-// Utility class for encapsulating token information
-[GeneratedCodeAttribute( "Gardens Point Parser Generator", "1.5.2")]
-public class ScanObj {
-  public int token;
-  public ValueType yylval;
-  public LexLocation yylloc;
-  public ScanObj( int t, ValueType val, LexLocation loc ) {
-    this.token = t; this.yylval = val; this.yylloc = loc;
-  }
-}
-
-[GeneratedCodeAttribute( "Gardens Point Parser Generator", "1.5.2")]
 public class Parser: ShiftReduceParser<ValueType, LexLocation>
 {
-  // Verbatim content from SimpleYacc.y - 30.09.2018 18:22:38
-// Ýòè îáúÿâëåíèÿ äîáàâëÿþòñÿ â êëàññ GPPGParser, ïðåäñòàâëÿþùèé ñîáîé ïàðñåð, ãåíåðèðóåìûé ñèñòåìîé gppg
-    public BlockNode root; // Êîðíåâîé óçåë ñèíòàêñè÷åñêîãî äåðåâà 
+  // Verbatim content from SimpleYacc.y
+// Эти объявления добавляются в класс GPPGParser, представляющий собой парсер, генерируемый системой gppg
+    public BlockNode root; // Корневой узел синтаксического дерева 
     public Parser(AbstractScanner<ValueType, LexLocation> scanner) : base(scanner) { }
 	private bool InDefSect = false;
-  // End verbatim content from SimpleYacc.y - 30.09.2018 18:22:38
+  // End verbatim content from SimpleYacc.y
 
 #pragma warning disable 649
-  private static Dictionary<int, string> aliases;
+  private static Dictionary<int, string> aliasses;
 #pragma warning restore 649
-  private static Rule[] rules = new Rule[30];
-  private static State[] states = new State[48];
+  private static Rule[] rules = new Rule[38];
+  private static State[] states = new State[67];
   private static string[] nonTerms = new string[] {
       "progr", "expr", "ident", "T", "F", "statement", "assign", "block", "cycle", 
-      "write", "empty", "var", "varlist", "stlist", "$accept", "Anon@1", };
+      "write", "empty", "var", "varlist", "if", "while", "repeat", "stlist", 
+      "$accept", "Anon@1", };
 
   static Parser() {
-    states[0] = new State(new int[]{4,4},new int[]{-1,1,-8,3});
-    states[1] = new State(new int[]{3,2});
+    states[0] = new State(new int[]{3,4},new int[]{-1,1,-8,3});
+    states[1] = new State(new int[]{2,2});
     states[2] = new State(-1);
     states[3] = new State(-2);
-    states[4] = new State(new int[]{23,18,4,4,6,31,12,35,13,40,5,-11,11,-11},new int[]{-14,5,-6,47,-7,9,-3,10,-8,29,-9,30,-10,34,-12,39,-11,46});
-    states[5] = new State(new int[]{5,6,11,7});
-    states[6] = new State(-23);
-    states[7] = new State(new int[]{23,18,4,4,6,31,12,35,13,40,5,-11,11,-11},new int[]{-6,8,-7,9,-3,10,-8,29,-9,30,-10,34,-12,39,-11,46});
+    states[4] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14},new int[]{-17,5,-6,59,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[5] = new State(new int[]{4,6,10,7});
+    states[6] = new State(-27);
+    states[7] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14,23,-14},new int[]{-6,8,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
     states[8] = new State(-4);
     states[9] = new State(-5);
-    states[10] = new State(new int[]{7,11});
-    states[11] = new State(new int[]{23,18,21,19,18,20},new int[]{-2,12,-4,28,-5,27,-3,17});
-    states[12] = new State(new int[]{14,13,15,23,5,-13,11,-13});
-    states[13] = new State(new int[]{23,18,21,19,18,20},new int[]{-4,14,-5,27,-3,17});
-    states[14] = new State(new int[]{16,15,17,25,14,-14,15,-14,5,-14,11,-14,19,-14,23,-14,4,-14,6,-14,12,-14,13,-14});
-    states[15] = new State(new int[]{23,18,21,19,18,20},new int[]{-5,16,-3,17});
-    states[16] = new State(-17);
-    states[17] = new State(-20);
-    states[18] = new State(-12);
-    states[19] = new State(-21);
-    states[20] = new State(new int[]{23,18,21,19,18,20},new int[]{-2,21,-4,28,-5,27,-3,17});
-    states[21] = new State(new int[]{19,22,14,13,15,23});
-    states[22] = new State(-22);
-    states[23] = new State(new int[]{23,18,21,19,18,20},new int[]{-4,24,-5,27,-3,17});
-    states[24] = new State(new int[]{16,15,17,25,14,-15,15,-15,5,-15,11,-15,19,-15,23,-15,4,-15,6,-15,12,-15,13,-15});
-    states[25] = new State(new int[]{23,18,21,19,18,20},new int[]{-5,26,-3,17});
-    states[26] = new State(-18);
-    states[27] = new State(-19);
-    states[28] = new State(new int[]{16,15,17,25,14,-16,15,-16,5,-16,11,-16,19,-16,23,-16,4,-16,6,-16,12,-16,13,-16});
-    states[29] = new State(-6);
-    states[30] = new State(-7);
-    states[31] = new State(new int[]{23,18,21,19,18,20},new int[]{-2,32,-4,28,-5,27,-3,17});
-    states[32] = new State(new int[]{14,13,15,23,23,18,4,4,6,31,12,35,13,40,5,-11,11,-11},new int[]{-6,33,-7,9,-3,10,-8,29,-9,30,-10,34,-12,39,-11,46});
-    states[33] = new State(-24);
-    states[34] = new State(-8);
-    states[35] = new State(new int[]{18,36});
-    states[36] = new State(new int[]{23,18,21,19,18,20},new int[]{-2,37,-4,28,-5,27,-3,17});
-    states[37] = new State(new int[]{19,38,14,13,15,23});
-    states[38] = new State(-25);
-    states[39] = new State(-9);
-    states[40] = new State(-26,new int[]{-16,41});
-    states[41] = new State(new int[]{23,18},new int[]{-13,42,-3,45});
-    states[42] = new State(new int[]{20,43,5,-27,11,-27});
-    states[43] = new State(new int[]{23,18},new int[]{-3,44});
-    states[44] = new State(-29);
-    states[45] = new State(-28);
-    states[46] = new State(-10);
-    states[47] = new State(-3);
-
-    for (int sNo = 0; sNo < states.Length; sNo++) states[sNo].number = sNo;
+    states[10] = new State(new int[]{6,11});
+    states[11] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,12,-4,30,-5,29,-3,17});
+    states[12] = new State(new int[]{13,13,14,23,4,-16,10,-16,23,-16,26,-16});
+    states[13] = new State(new int[]{30,18,28,19,17,20},new int[]{-4,14,-5,29,-3,17});
+    states[14] = new State(new int[]{15,15,16,25,20,27,13,-17,14,-17,4,-17,10,-17,23,-17,26,-17,18,-17,30,-17,3,-17,5,-17,11,-17,12,-17,21,-17,27,-17,24,-17,22,-17,25,-17});
+    states[15] = new State(new int[]{30,18,28,19,17,20},new int[]{-5,16,-3,17});
+    states[16] = new State(-20);
+    states[17] = new State(-24);
+    states[18] = new State(-15);
+    states[19] = new State(-25);
+    states[20] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,21,-4,30,-5,29,-3,17});
+    states[21] = new State(new int[]{18,22,13,13,14,23});
+    states[22] = new State(-26);
+    states[23] = new State(new int[]{30,18,28,19,17,20},new int[]{-4,24,-5,29,-3,17});
+    states[24] = new State(new int[]{15,15,16,25,20,27,13,-18,14,-18,4,-18,10,-18,23,-18,26,-18,18,-18,30,-18,3,-18,5,-18,11,-18,12,-18,21,-18,27,-18,24,-18,22,-18,25,-18});
+    states[25] = new State(new int[]{30,18,28,19,17,20},new int[]{-5,26,-3,17});
+    states[26] = new State(-21);
+    states[27] = new State(new int[]{30,18,28,19,17,20},new int[]{-5,28,-3,17});
+    states[28] = new State(-22);
+    states[29] = new State(-23);
+    states[30] = new State(new int[]{15,15,16,25,20,27,13,-19,14,-19,4,-19,10,-19,23,-19,26,-19,18,-19,30,-19,3,-19,5,-19,11,-19,12,-19,21,-19,27,-19,24,-19,22,-19,25,-19});
+    states[31] = new State(-6);
+    states[32] = new State(-7);
+    states[33] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,34,-4,30,-5,29,-3,17});
+    states[34] = new State(new int[]{13,13,14,23,30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14,23,-14,26,-14},new int[]{-6,35,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[35] = new State(-28);
+    states[36] = new State(-8);
+    states[37] = new State(new int[]{17,38});
+    states[38] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,39,-4,30,-5,29,-3,17});
+    states[39] = new State(new int[]{18,40,13,13,14,23});
+    states[40] = new State(-29);
+    states[41] = new State(-9);
+    states[42] = new State(-30,new int[]{-19,43});
+    states[43] = new State(new int[]{30,18},new int[]{-13,44,-3,47});
+    states[44] = new State(new int[]{19,45,4,-31,10,-31,23,-31,26,-31});
+    states[45] = new State(new int[]{30,18},new int[]{-3,46});
+    states[46] = new State(-33);
+    states[47] = new State(-32);
+    states[48] = new State(-10);
+    states[49] = new State(-11);
+    states[50] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,51,-4,30,-5,29,-3,17});
+    states[51] = new State(new int[]{22,52,13,13,14,23});
+    states[52] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14,23,-14,26,-14},new int[]{-6,53,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[53] = new State(-34);
+    states[54] = new State(-12);
+    states[55] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,23,-14,10,-14},new int[]{-17,56,-6,59,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[56] = new State(new int[]{23,57,10,7});
+    states[57] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,58,-4,30,-5,29,-3,17});
+    states[58] = new State(new int[]{13,13,14,23,4,-37,10,-37,23,-37,26,-37});
+    states[59] = new State(-3);
+    states[60] = new State(-13);
+    states[61] = new State(new int[]{30,18,28,19,17,20},new int[]{-2,62,-4,30,-5,29,-3,17});
+    states[62] = new State(new int[]{25,63,13,13,14,23});
+    states[63] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14,23,-14,26,-14},new int[]{-6,64,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[64] = new State(new int[]{26,65,4,-36,10,-36,23,-36});
+    states[65] = new State(new int[]{30,18,3,4,5,33,11,37,12,42,21,50,27,55,24,61,4,-14,10,-14,23,-14,26,-14},new int[]{-6,66,-7,9,-3,10,-8,31,-9,32,-10,36,-12,41,-11,48,-15,49,-16,54,-14,60});
+    states[66] = new State(-35);
 
-    rules[1] = new Rule(-15, new int[]{-1,3});
+    rules[1] = new Rule(-18, new int[]{-1,2});
     rules[2] = new Rule(-1, new int[]{-8});
-    rules[3] = new Rule(-14, new int[]{-6});
-    rules[4] = new Rule(-14, new int[]{-14,11,-6});
+    rules[3] = new Rule(-17, new int[]{-6});
+    rules[4] = new Rule(-17, new int[]{-17,10,-6});
     rules[5] = new Rule(-6, new int[]{-7});
     rules[6] = new Rule(-6, new int[]{-8});
     rules[7] = new Rule(-6, new int[]{-9});
     rules[8] = new Rule(-6, new int[]{-10});
     rules[9] = new Rule(-6, new int[]{-12});
     rules[10] = new Rule(-6, new int[]{-11});
-    rules[11] = new Rule(-11, new int[]{});
-    rules[12] = new Rule(-3, new int[]{23});
-    rules[13] = new Rule(-7, new int[]{-3,7,-2});
-    rules[14] = new Rule(-2, new int[]{-2,14,-4});
-    rules[15] = new Rule(-2, new int[]{-2,15,-4});
-    rules[16] = new Rule(-2, new int[]{-4});
-    rules[17] = new Rule(-4, new int[]{-4,16,-5});
-    rules[18] = new Rule(-4, new int[]{-4,17,-5});
-    rules[19] = new Rule(-4, new int[]{-5});
-    rules[20] = new Rule(-5, new int[]{-3});
-    rules[21] = new Rule(-5, new int[]{21});
-    rules[22] = new Rule(-5, new int[]{18,-2,19});
-    rules[23] = new Rule(-8, new int[]{4,-14,5});
-    rules[24] = new Rule(-9, new int[]{6,-2,-6});
-    rules[25] = new Rule(-10, new int[]{12,18,-2,19});
-    rules[26] = new Rule(-16, new int[]{});
-    rules[27] = new Rule(-12, new int[]{13,-16,-13});
-    rules[28] = new Rule(-13, new int[]{-3});
-    rules[29] = new Rule(-13, new int[]{-13,20,-3});
+    rules[11] = new Rule(-6, new int[]{-15});
+    rules[12] = new Rule(-6, new int[]{-16});
+    rules[13] = new Rule(-6, new int[]{-14});
+    rules[14] = new Rule(-11, new int[]{});
+    rules[15] = new Rule(-3, new int[]{30});
+    rules[16] = new Rule(-7, new int[]{-3,6,-2});
+    rules[17] = new Rule(-2, new int[]{-2,13,-4});
+    rules[18] = new Rule(-2, new int[]{-2,14,-4});
+    rules[19] = new Rule(-2, new int[]{-4});
+    rules[20] = new Rule(-4, new int[]{-4,15,-5});
+    rules[21] = new Rule(-4, new int[]{-4,16,-5});
+    rules[22] = new Rule(-4, new int[]{-4,20,-5});
+    rules[23] = new Rule(-4, new int[]{-5});
+    rules[24] = new Rule(-5, new int[]{-3});
+    rules[25] = new Rule(-5, new int[]{28});
+    rules[26] = new Rule(-5, new int[]{17,-2,18});
+    rules[27] = new Rule(-8, new int[]{3,-17,4});
+    rules[28] = new Rule(-9, new int[]{5,-2,-6});
+    rules[29] = new Rule(-10, new int[]{11,17,-2,18});
+    rules[30] = new Rule(-19, new int[]{});
+    rules[31] = new Rule(-12, new int[]{12,-19,-13});
+    rules[32] = new Rule(-13, new int[]{-3});
+    rules[33] = new Rule(-13, new int[]{-13,19,-3});
+    rules[34] = new Rule(-15, new int[]{21,-2,22,-6});
+    rules[35] = new Rule(-14, new int[]{24,-2,25,-6,26,-6});
+    rules[36] = new Rule(-14, new int[]{24,-2,25,-6});
+    rules[37] = new Rule(-16, new int[]{27,-17,23,-2});
   }
 
   protected override void Initialize() {
@@ -166,7 +180,6 @@ public class Parser: ShiftReduceParser<ValueType, LexLocation>
 
   protected override void DoAction(int action)
   {
-#pragma warning disable 162, 1522
     switch (action)
     {
       case 2: // progr -> block
@@ -201,90 +214,114 @@ public class Parser: ShiftReduceParser<ValueType, LexLocation>
       case 10: // statement -> empty
 { CurrentSemanticValue.stVal = ValueStack[ValueStack.Depth-1].stVal; }
         break;
-      case 11: // empty -> /* empty */
+      case 11: // statement -> while
+{ CurrentSemanticValue.stVal = ValueStack[ValueStack.Depth-1].stVal; }
+        break;
+      case 12: // statement -> repeat
+{ CurrentSemanticValue.stVal = ValueStack[ValueStack.Depth-1].stVal; }
+        break;
+      case 13: // statement -> if
+{ CurrentSemanticValue.stVal = ValueStack[ValueStack.Depth-1].stVal; }
+        break;
+      case 14: // empty -> /* empty */
 { CurrentSemanticValue.stVal = new EmptyNode(); }
         break;
-      case 12: // ident -> ID
+      case 15: // ident -> ID
 {
 			if (!InDefSect)
 				if (!SymbolTable.vars.ContainsKey(ValueStack[ValueStack.Depth-1].sVal))
-					throw new Exception("("+LocationStack[LocationStack.Depth-1].StartLine+","+LocationStack[LocationStack.Depth-1].StartColumn+"): Ïåðåìåííàÿ "+ValueStack[ValueStack.Depth-1].sVal+" íå îïèñàíà");
+					throw new Exception("("+LocationStack[LocationStack.Depth-1].StartLine+","+LocationStack[LocationStack.Depth-1].StartColumn+"): Переменная "+ValueStack[ValueStack.Depth-1].sVal+" не описана");
 			CurrentSemanticValue.eVal = new IdNode(ValueStack[ValueStack.Depth-1].sVal); 
 		}
         break;
-      case 13: // assign -> ident, ASSIGN, expr
+      case 16: // assign -> ident, ASSIGN, expr
 { CurrentSemanticValue.stVal = new AssignNode(ValueStack[ValueStack.Depth-3].eVal as IdNode, ValueStack[ValueStack.Depth-1].eVal); }
         break;
-      case 14: // expr -> expr, PLUS, T
+      case 17: // expr -> expr, PLUS, T
 { CurrentSemanticValue.eVal = new BinOpNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].eVal,'+'); }
         break;
-      case 15: // expr -> expr, MINUS, T
+      case 18: // expr -> expr, MINUS, T
 { CurrentSemanticValue.eVal = new BinOpNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].eVal,'-'); }
         break;
-      case 16: // expr -> T
+      case 19: // expr -> T
 { CurrentSemanticValue.eVal = ValueStack[ValueStack.Depth-1].eVal; }
         break;
-      case 17: // T -> T, MULT, F
+      case 20: // T -> T, MULT, F
 { CurrentSemanticValue.eVal = new BinOpNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].eVal,'*'); }
         break;
-      case 18: // T -> T, DIV, F
+      case 21: // T -> T, DIV, F
 { CurrentSemanticValue.eVal = new BinOpNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].eVal,'/'); }
         break;
-      case 19: // T -> F
+      case 22: // T -> T, MOD, F
+{ CurrentSemanticValue.eVal = new BinOpNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].eVal,'%'); }
+        break;
+      case 23: // T -> F
 { CurrentSemanticValue.eVal = ValueStack[ValueStack.Depth-1].eVal; }
         break;
-      case 20: // F -> ident
+      case 24: // F -> ident
 { CurrentSemanticValue.eVal = ValueStack[ValueStack.Depth-1].eVal as IdNode; }
         break;
-      case 21: // F -> INUM
+      case 25: // F -> INUM
 { CurrentSemanticValue.eVal = new IntNumNode(ValueStack[ValueStack.Depth-1].iVal); }
         break;
-      case 22: // F -> LPAREN, expr, RPAREN
+      case 26: // F -> LPAREN, expr, RPAREN
 { CurrentSemanticValue.eVal = ValueStack[ValueStack.Depth-2].eVal; }
         break;
-      case 23: // block -> BEGIN, stlist, END
+      case 27: // block -> BEGIN, stlist, END
 { CurrentSemanticValue.blVal = ValueStack[ValueStack.Depth-2].blVal; }
         break;
-      case 24: // cycle -> CYCLE, expr, statement
+      case 28: // cycle -> CYCLE, expr, statement
 { CurrentSemanticValue.stVal = new CycleNode(ValueStack[ValueStack.Depth-2].eVal,ValueStack[ValueStack.Depth-1].stVal); }
         break;
-      case 25: // write -> WRITE, LPAREN, expr, RPAREN
+      case 29: // write -> WRITE, LPAREN, expr, RPAREN
 { CurrentSemanticValue.stVal = new WriteNode(ValueStack[ValueStack.Depth-2].eVal); }
         break;
-      case 26: // Anon@1 -> /* empty */
+      case 30: // Anon@1 -> /* empty */
 { InDefSect = true; }
         break;
-      case 27: // var -> VAR, Anon@1, varlist
+      case 31: // var -> VAR, Anon@1, varlist
 { 
 			foreach (var v in (ValueStack[ValueStack.Depth-1].stVal as VarDefNode).vars)
 				SymbolTable.NewVarDef(v.Name, type.tint);
 			InDefSect = false;	
 		}
         break;
-      case 28: // varlist -> ident
+      case 32: // varlist -> ident
 { 
 			CurrentSemanticValue.stVal = new VarDefNode(ValueStack[ValueStack.Depth-1].eVal as IdNode); 
 		}
         break;
-      case 29: // varlist -> varlist, COLUMN, ident
+      case 33: // varlist -> varlist, COLUMN, ident
 { 
 			(ValueStack[ValueStack.Depth-3].stVal as VarDefNode).Add(ValueStack[ValueStack.Depth-1].eVal as IdNode);
 			CurrentSemanticValue.stVal = ValueStack[ValueStack.Depth-3].stVal;
 		}
         break;
+      case 34: // while -> WHILE, expr, DO, statement
+{ CurrentSemanticValue.stVal = new WhileNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].stVal); }
+        break;
+      case 35: // if -> IF, expr, THEN, statement, ELSE, statement
+{ CurrentSemanticValue.stVal = new IfNode(ValueStack[ValueStack.Depth-5].eVal,ValueStack[ValueStack.Depth-3].stVal,ValueStack[ValueStack.Depth-1].stVal); }
+        break;
+      case 36: // if -> IF, expr, THEN, statement
+{ CurrentSemanticValue.stVal = new IfNode(ValueStack[ValueStack.Depth-3].eVal,ValueStack[ValueStack.Depth-1].stVal); }
+        break;
+      case 37: // repeat -> REPEAT, stlist, UNTIL, expr
+{ CurrentSemanticValue.stVal = new RepeatNode(ValueStack[ValueStack.Depth-3].blVal,ValueStack[ValueStack.Depth-1].eVal); }
+        break;
     }
-#pragma warning restore 162, 1522
   }
 
   protected override string TerminalToString(int terminal)
   {
-    if (aliases != null && aliases.ContainsKey(terminal))
-        return aliases[terminal];
+    if (aliasses != null && aliasses.ContainsKey(terminal))
+        return aliasses[terminal];
     else if (((Tokens)terminal).ToString() != terminal.ToString(CultureInfo.InvariantCulture))
         return ((Tokens)terminal).ToString();
     else
         return CharToString((char)terminal);
   }
 
+
 }
 }
diff --git a/Module8/SimpleYacc.lst b/Module8/SimpleYacc.lst
deleted file mode 100644
index 2de6038dc15cafc28cab3190511bf29097e83980..0000000000000000000000000000000000000000
--- a/Module8/SimpleYacc.lst
+++ /dev/null
@@ -1,139 +0,0 @@
-
-// ==========================================================================
-//  GPPG error listing for yacc source file <SimpleYacc.y>
-// ==========================================================================
-//  Version:  1.3.6
-//  Machine:  SSM
-//  DateTime: 19.08.2014 13:28:35
-//  UserName: Станислав
-// ==========================================================================
-
-
-%{
-// Ýòè îáúÿâëåíèÿ äîáàâëÿþòñÿ â êëàññ GPPGParser, ïðåäñòàâëÿþùèé ñîáîé ïàðñåð, ãåíåðèðóåìûé ñèñòåìîé gppg
-    public BlockNode root; // Êîðíåâîé óçåë ñèíòàêñè÷åñêîãî äåðåâà 
-    public Parser(AbstractScanner<ValueType, LexLocation> scanner) : base(scanner) { }
-	private bool InDefSect = false;
-%}
-
-%output = SimpleYacc.cs
-
-%union { 
-			public double dVal; 
-			public int iVal; 
-			public string sVal; 
-			public Node nVal;
-			public ExprNode eVal;
-			public StatementNode stVal;
-			public BlockNode blVal;
-       }
-
-%using System.IO;
-%using ProgramTree;
-
-%namespace SimpleParser
-
-%start progr
-
-%token BEGIN END CYCLE ASSIGN ASSIGNPLUS ASSIGNMINUS ASSIGNMULT SEMICOLON WRITE VAR PLUS MINUS MULT DIV LPAREN RPAREN COLUMN
-%token <iVal> INUM 
-%token <dVal> RNUM 
-%token <sVal> ID
-
-%type <nVal> varlist 
-%type <eVal> expr ident T F 
-%type <stVal> statement assign block cycle write empty var  
-%type <blVal> stlist block
-
-%%
-// Error: NonTerminal symbol "st" has no productions
-// Warning: Terminating st fixes the following size-2 NonTerminal set
-   // {cycle, st}
-// Error: There are 2 non-terminating NonTerminal Symbols
-   //  {cycle, st}
-// ------------------------------------------------------------------
-
-progr   : block { root = $1; }
-		;
-
-stlist	: statement 
-			{ 
-				$$ = new BlockNode($1); 
-			}
-		| stlist SEMICOLON statement 
-			{ 
-				$1.Add($3); 
-				$$ = $1; 
-			}
-		;
-
-statement: assign { $$ = $1; }
-		| block   { $$ = $1; }
-		| cycle   { $$ = $1; }
-		| write   { $$ = $1; }
-		| var     { $$ = $1; }
-		| empty   { $$ = $1; }
-		;
-
-empty	: { $$ = new EmptyNode(); }
-		;
-	
-ident 	: ID 
-		{
-			if (!InDefSect)
-				if (!SymbolTable.vars.ContainsKey($1))
-					throw new Exception("("+@1.StartLine+","+@1.StartColumn+"): Ïåðåìåííàÿ "+$1+" íå îïèñàíà");
-			$$ = new IdNode($1); 
-		}	
-	;
-	
-assign 	: ident ASSIGN expr { $$ = new AssignNode($1 as IdNode, $3); }
-		;
-
-expr	: expr PLUS T { $$ = new BinOpNode($1,$3,'+'); }
-		| expr MINUS T { $$ = new BinOpNode($1,$3,'-'); }
-		| T { $$ = $1; }
-		;
-		
-T 		: T MULT F { $$ = new BinOpNode($1,$3,'*'); }
-		| T DIV F { $$ = new BinOpNode($1,$3,'/'); }
-		| F { $$ = $1; }
-		;
-		
-F 		: ident  { $$ = $1 as IdNode; }
-		| INUM { $$ = new IntNumNode($1); }
-		| LPAREN expr RPAREN { $$ = $2; }
-		;
-
-block	: BEGIN stlist END { $$ = $2; }
-		;
-
-cycle	: CYCLE expr st { $$ = new CycleNode($2,$3); }
-		;
-		
-write	: WRITE LPAREN expr RPAREN { $$ = new WriteNode($3); }
-		;
-		
-var		: VAR { InDefSect = true; } varlist 
-		{ 
-			foreach (var v in ($3 as VarDefNode).vars)
-				SymbolTable.NewVarDef(v.Name, type.tint);
-			InDefSect = false;	
-		}
-		;
-
-varlist	: ident 
-		{ 
-			$$ = new VarDefNode($1 as IdNode); 
-		}
-		| varlist COLUMN ident 
-		{ 
-			($1 as VarDefNode).Add($3 as IdNode);
-			$$ = $1;
-		}
-		;
-	
-%%
-
-// ==========================================================================
-
diff --git a/Module8/SimpleYacc.y b/Module8/SimpleYacc.y
index 20087e00b11254a052c1bfcd87f137d81203b253..780a7663682b327c1dbed78b3e167f51abd83be7 100644
--- a/Module8/SimpleYacc.y
+++ b/Module8/SimpleYacc.y
@@ -24,13 +24,13 @@
 
 %start progr
 
-%token BEGIN END CYCLE ASSIGN ASSIGNPLUS ASSIGNMINUS ASSIGNMULT SEMICOLON WRITE VAR PLUS MINUS MULT DIV LPAREN RPAREN COLUMN
+%token BEGIN END CYCLE ASSIGN ASSIGNPLUS ASSIGNMINUS ASSIGNMULT SEMICOLON WRITE VAR PLUS MINUS MULT DIV LPAREN RPAREN COLUMN MOD WHILE DO UNTIL IF THEN ELSE REPEAT
 %token <iVal> INUM 
 %token <dVal> RNUM 
 %token <sVal> ID
 
 %type <eVal> expr ident T F 
-%type <stVal> statement assign block cycle write empty var varlist 
+%type <stVal> statement assign block cycle write empty var varlist if while repeat
 %type <blVal> stlist block
 
 %%
@@ -55,6 +55,9 @@ statement: assign { $$ = $1; }
 		| write   { $$ = $1; }
 		| var     { $$ = $1; }
 		| empty   { $$ = $1; }
+		| while   { $$ = $1; }
+		| repeat   { $$ = $1; }
+		| if   { $$ = $1; }
 		;
 
 empty	: { $$ = new EmptyNode(); }
@@ -79,6 +82,7 @@ expr	: expr PLUS T { $$ = new BinOpNode($1,$3,'+'); }
 		
 T 		: T MULT F { $$ = new BinOpNode($1,$3,'*'); }
 		| T DIV F { $$ = new BinOpNode($1,$3,'/'); }
+		| T MOD F { $$ = new BinOpNode($1,$3,'%'); }
 		| F { $$ = $1; }
 		;
 		
@@ -115,5 +119,16 @@ varlist	: ident
 		}
 		;
 	
+while   : WHILE expr DO statement { $$ = new WhileNode($2,$4); }
+        ;
+
+
+if      : IF expr THEN statement ELSE statement { $$ = new IfNode($2,$4,$6); }
+        | IF expr THEN statement { $$ = new IfNode($2,$4); }
+		;
+
+repeat  : REPEAT stlist UNTIL expr { $$ = new RepeatNode($2,$4); }
+        ;
+
 %%
 
diff --git a/Module8/Visitors/AutoVisitor.cs b/Module8/Visitors/AutoVisitor.cs
index 5d508770fc5449f20e1d15859b78725d4e64af48..06fa0a6801688c221997ce097e0531738ab4417c 100644
--- a/Module8/Visitors/AutoVisitor.cs
+++ b/Module8/Visitors/AutoVisitor.cs
@@ -50,5 +50,17 @@ namespace SimpleLang.Visitors
                 cond.ifFalse.Visit(this);
             }
         }
+
+        public override void VisitRepeatNode(RepeatNode cond)
+        {
+            cond.expr.Visit(this);
+            foreach (var v in  cond.stats)
+                v.Visit(this);
+        }
+        public override void VisitWhileNode(WhileNode cond)
+        {
+            cond.expr.Visit(this);
+            cond.stat.Visit(this);
+        }
     }
 }
diff --git a/Module8/Visitors/GenCodeVisitors/GenCodeCreator.cs b/Module8/Visitors/GenCodeVisitors/GenCodeCreator.cs
index 735377141f792ac74276b9d1768276ab7fd905ac..b6c460a9f07ce97860504bdd5f4edd556e001f9c 100644
--- a/Module8/Visitors/GenCodeVisitors/GenCodeCreator.cs
+++ b/Module8/Visitors/GenCodeVisitors/GenCodeCreator.cs
@@ -37,7 +37,7 @@ namespace SimpleLang.Visitors
         }
 
         public void Emit(OpCode op, LocalBuilder lb)
-        {
+        {  
             gen.Emit(op, lb);
             if (write_commands)
                 commands.Add(op.ToString() + " var" + lb.LocalIndex);
diff --git a/Module8/Visitors/GenCodeVisitors/GenCodeVisitor.cs b/Module8/Visitors/GenCodeVisitors/GenCodeVisitor.cs
index 88891ad31e66280ab20cdf988e42cb6e1390af22..eb6e153eca3a77d663a5a552547f5cae69f852bb 100644
--- a/Module8/Visitors/GenCodeVisitors/GenCodeVisitor.cs
+++ b/Module8/Visitors/GenCodeVisitors/GenCodeVisitor.cs
@@ -44,6 +44,9 @@ namespace SimpleLang.Visitors
                 case '/':
                     genc.Emit(OpCodes.Div);
                     break;
+                case '%':
+                    genc.Emit(OpCodes.Rem);
+                    break;
             }
         }
         public override void VisitAssignNode(AssignNode a) 
@@ -59,7 +62,7 @@ namespace SimpleLang.Visitors
 
             Label startLoop = genc.DefineLabel();
             Label endLoop = genc.DefineLabel();
-            
+         
             genc.MarkLabel(startLoop);
 
             genc.Emit(OpCodes.Ldloc, i); 
@@ -77,6 +80,73 @@ namespace SimpleLang.Visitors
 
             genc.MarkLabel(endLoop);
         }
+
+        public override void VisitIfNode(IfNode cond)
+        {
+          
+            Label truepart = genc.DefineLabel();
+            Label falsepart = genc.DefineLabel();
+            Label end = genc.DefineLabel();
+
+            cond.expr.Visit(this);
+            genc.Emit(OpCodes.Ldc_I4_0);
+            genc.Emit(OpCodes.Beq, falsepart); // if i>0 then goto endLoop
+            cond.ifTrue.Visit(this);
+            genc.Emit(OpCodes.Br, end);
+
+            genc.MarkLabel(falsepart);
+            if (cond.ifFalse != null)
+            cond.ifFalse.Visit(this);
+
+            genc.MarkLabel(end);
+        }
+
+
+        public override void VisitWhileNode(WhileNode cond)
+        {
+           
+            Label startLoop = genc.DefineLabel();
+            Label endLoop = genc.DefineLabel();
+
+
+            genc.MarkLabel(startLoop);
+
+            cond.expr.Visit(this);
+            genc.Emit(OpCodes.Ldc_I4_0);
+            genc.Emit(OpCodes.Ble, endLoop); // if i<=0 then goto endLoop
+
+            cond.stat.Visit(this);
+
+            genc.Emit(OpCodes.Br, startLoop);
+
+            genc.MarkLabel(endLoop);
+
+            
+        }
+
+
+        public override void VisitRepeatNode(RepeatNode cond) 
+        {
+            Label startLoop = genc.DefineLabel();
+            Label endLoop = genc.DefineLabel();
+
+
+            genc.MarkLabel(startLoop);
+            foreach(var st in cond.stats){
+                st.Visit(this);
+            }
+
+            cond.expr.Visit(this);
+            genc.Emit(OpCodes.Ldc_I4_0);
+            genc.Emit(OpCodes.Ble, endLoop); // if i<=0 then goto endLoop
+
+           
+
+            genc.Emit(OpCodes.Br, startLoop);
+
+            genc.MarkLabel(endLoop);
+        }
+
         public override void VisitBlockNode(BlockNode bl) 
         {
             foreach (var st in bl.StList)
diff --git a/Module8/Visitors/Visitor.cs b/Module8/Visitors/Visitor.cs
index 5fc65fcae1f33553c60fe2590eba8e3f086a85ca..e197d7c5305e7582fe4f69c120a30d10b75799b2 100644
--- a/Module8/Visitors/Visitor.cs
+++ b/Module8/Visitors/Visitor.cs
@@ -18,5 +18,8 @@ namespace SimpleLang.Visitors
         public virtual void VisitVarDefNode(VarDefNode w) { }
         public virtual void VisitEmptyNode(EmptyNode w) { }
         public virtual void VisitIfNode(IfNode cond) { }
+        public virtual void VisitWhileNode(WhileNode cond) { }
+        public virtual void VisitRepeatNode(RepeatNode cond) { }
+
     }
 }
diff --git a/TestCodeGenerator/Tests.cs b/TestCodeGenerator/Tests.cs
index c8f33a03382f00a4a89fa590b3f75048a1b46a72..76e99588fbdb38feef5ab5eb471c3c88a057b8f3 100644
--- a/TestCodeGenerator/Tests.cs
+++ b/TestCodeGenerator/Tests.cs
@@ -72,14 +72,14 @@ namespace TestCodeGenerator
         [Test]
         public void TestIntDivMod()
         {
-            Assert.AreEqual("48", TestHelper.GenerateNRun(@"begin var a; a := (232 / 5) + (232 % 5); write(a) end"));
+             Assert.AreEqual("48", TestHelper.GenerateNRun(@"begin var a; a := (232 / 5) + (232 % 5); write(a) end"));
+            
         }
         
         [Test]
         public void TestIf()
         {
-            Assert.AreEqual("3", TestHelper.GenerateNRun(@"begin var a1; a1 := 0; if a1 then write(2) else write(3) end"));
-            
+            Assert.AreEqual("3", TestHelper.GenerateNRun(@"begin var a1; a1 := 0; if a1 then write(2) else write(3) end"));            
             Assert.AreEqual("3", TestHelper.GenerateNRun(@"begin var x,y; x := 1; y := x-1; if x then if y then write(2) else write(3) end"));
         }