From e534ccc99fef75a61d2d6ce3be6eb6ddab503cbb Mon Sep 17 00:00:00 2001
From: yonesurprise <yonesurprise@gmail.com>
Date: Sun, 4 Dec 2022 15:46:00 +0300
Subject: [PATCH] lab 2

---
 Module2/SimpleLangLexer/SimpleLexer.cs | 124 ++++++++++++++++++++++++-
 TestSimpleLexer/Tests.cs               |  10 +-
 2 files changed, 126 insertions(+), 8 deletions(-)

diff --git a/Module2/SimpleLangLexer/SimpleLexer.cs b/Module2/SimpleLangLexer/SimpleLexer.cs
index 7bd0af4..ff75d81 100644
--- a/Module2/SimpleLangLexer/SimpleLexer.cs
+++ b/Module2/SimpleLangLexer/SimpleLexer.cs
@@ -100,6 +100,14 @@ namespace SimpleLexer
             keywordsMap["begin"] = Tok.BEGIN;
             keywordsMap["end"] = Tok.END;
             keywordsMap["cycle"] = Tok.CYCLE;
+
+            //1
+            keywordsMap["div"] = Tok.DIV;
+            keywordsMap["mod"] = Tok.MOD;
+            keywordsMap["and"] = Tok.AND;
+            keywordsMap["or"] = Tok.OR;
+            keywordsMap["not"] = Tok.NOT;
+
         }
 
         public string FinishCurrentLine()
@@ -166,12 +174,122 @@ namespace SimpleLexer
             else if (currentCh == ':')
             {
                 NextCh();
-                if (currentCh != '=')
+                if (currentCh == '=')
+                {
+                    LexKind = Tok.ASSIGN;
+                    NextCh();
+                }
+                else
+                {
+                    LexKind = Tok.COLON;
+                }
+            }
+            else if (currentCh == ',')
+            {
+                NextCh();
+                LexKind = Tok.COMMA;
+            }
+            else if (currentCh == '+')
+            {
+                NextCh();
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.PLUSASSIGN;
+                }
+                else
+                {
+                    LexKind = Tok.PLUS;
+                }
+            }
+            else if (currentCh == '-')
+            {
+                NextCh();
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.MINUSASSIGN;
+                }
+                else
                 {
-                    LexError("= was expected");
+                    LexKind = Tok.MINUS;
                 }
+            }
+            else if (currentCh == '*')
+            {
                 NextCh();
-                LexKind = Tok.ASSIGN;
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.MULTASSIGN;
+                }
+                else
+                {
+                    LexKind = Tok.MULT;
+                }
+            }
+            else if (currentCh == '/')
+            {
+                NextCh();
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.DIVASSIGN;
+                }
+                else if (currentCh == '/')
+                {
+                    while (currentCh != '\0' && currentCh != '\n')
+                        NextCh();
+                    if (currentCh == '\0')
+                        LexKind = Tok.EOF;
+                    else
+                        NextLexem();
+                }
+                else
+                {
+                    LexKind = Tok.DIVISION;
+                }
+            }
+            else if (currentCh == '>')
+            {
+                NextCh();
+                LexKind = Tok.GT;
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.GEQ;
+                }
+            }
+            else if (currentCh == '<')
+            {
+                NextCh();
+                LexKind = Tok.LT;
+                if (currentCh == '=')
+                {
+                    NextCh();
+                    LexKind = Tok.LEQ;
+                }
+                if (currentCh == '>')
+                {
+                    NextCh();
+                    LexKind = Tok.NEQ;
+                }
+            }
+            else if (currentCh == '=')
+            {
+                NextCh();
+                LexKind = Tok.EQ;
+            }
+            else if (currentCh == '{')
+            {
+                while (currentCh != '}')
+                {
+                    if (currentCh == '\0')
+                        LexError("End-of-lexem found, '}' Expected");
+                    NextCh();
+                }
+                NextCh();
+                NextLexem();
             }
             else if (char.IsLetter(currentCh))
             {
diff --git a/TestSimpleLexer/Tests.cs b/TestSimpleLexer/Tests.cs
index 1416597..ea8d836 100644
--- a/TestSimpleLexer/Tests.cs
+++ b/TestSimpleLexer/Tests.cs
@@ -19,7 +19,7 @@ namespace TestSimpleLexer
     }
     
     [TestFixture]
-    [Ignore("This test is disabled")]
+    //[Ignore("This test is disabled")]
     public class TestSimpleLexer
     {
         public static List< KeyValuePair<Tok, string> > getLexerOutput(Lexer l)
@@ -56,7 +56,7 @@ namespace TestSimpleLexer
     }
     
     [TestFixture]
-    [Ignore("This test is disabled")]
+    //[Ignore("This test is disabled")]
     public class TestSimpleLexerOps
     {
         [Test]
@@ -126,7 +126,7 @@ namespace TestSimpleLexer
     }
     
     [TestFixture]
-    [Ignore("This test is disabled")]
+    //[Ignore("This test is disabled")]
     public class TestSimpleLexerAssigns
     {
         [Test]
@@ -218,7 +218,7 @@ namespace TestSimpleLexer
     }
     
     [TestFixture]
-    [Ignore("This test is disabled")]
+    //[Ignore("This test is disabled")]
     public class TestSimpleLexerLineCmt
     {
         [Test]
@@ -280,7 +280,7 @@ namespace TestSimpleLexer
     }
     
     [TestFixture]
-    [Ignore("This test is disabled")]
+    //[Ignore("This test is disabled")]
     public class TestSimpleLexerMultLineCmt
     {
         [Test]
-- 
GitLab