Skip to content
Snippets Groups Projects
Commit b2aa4576 authored by unknown's avatar unknown
Browse files

first try

parent 360390d8
No related merge requests found
Pipeline #5118 passed with warnings with stages
in 7 minutes and 23 seconds
...@@ -68,13 +68,18 @@ namespace Lexer ...@@ -68,13 +68,18 @@ namespace Lexer
public override bool Parse() public override bool Parse()
{ {
NextCh(); NextCh();
int res = 0; //
int sign = 1; //
if (currentCh == '+' || currentCh == '-') if (currentCh == '+' || currentCh == '-')
{ {
if (currentCh == '-')
sign = -1;
NextCh(); NextCh();
} }
if (char.IsDigit(currentCh)) if (char.IsDigit(currentCh))
{ {
res = currentCh - '0';
NextCh(); NextCh();
} }
else else
...@@ -84,6 +89,7 @@ namespace Lexer ...@@ -84,6 +89,7 @@ namespace Lexer
while (char.IsDigit(currentCh)) while (char.IsDigit(currentCh))
{ {
res = res * 10 + currentCh - '0';
NextCh(); NextCh();
} }
...@@ -93,6 +99,8 @@ namespace Lexer ...@@ -93,6 +99,8 @@ namespace Lexer
Error(); Error();
} }
this.parseResult = res * sign;
return true; return true;
} }
...@@ -113,10 +121,40 @@ namespace Lexer ...@@ -113,10 +121,40 @@ namespace Lexer
builder = new StringBuilder(); builder = new StringBuilder();
} }
public override bool Parse() public override bool Parse()
{ {
throw new NotImplementedException(); NextCh();
}
if (currentCharValue != -1)
{
Error();
}
var builder1 = new StringBuilder();
if (char.IsLetter(currentCh) || currentCh == '_')
{
builder1.Append(currentCh);
NextCh();
}
else
Error();
while (char.IsDigit(currentCh) || char.IsLetter(currentCh) || currentCh == '_')
{
builder1.Append(currentCh);
NextCh();
}
if (currentCharValue != -1)
{
Error();
}
parseResult = builder1.ToString();
return true;
}
} }
......
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