Skip to content
Snippets Groups Projects
Commit e534ccc9 authored by yonesurprise's avatar yonesurprise
Browse files

lab 2

parent 94f4aca8
Branches master
No related merge requests found
Pipeline #6042 passed with warnings with stages
in 6 minutes and 38 seconds
......@@ -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))
{
......
......@@ -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]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment