Fixed up some more lines
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed
Some checks failed
continuous-integration/appveyor/branch AppVeyor build failed
This commit is contained in:
parent
17d4a3672b
commit
f3bf997652
@ -236,12 +236,12 @@ namespace Assignment_1
|
|||||||
source.Position = initPos;
|
source.Position = initPos;
|
||||||
source.SetLength(initPos);
|
source.SetLength(initPos);
|
||||||
break;
|
break;
|
||||||
case Statements.writeout:
|
/*case Statements.writeout:
|
||||||
// Writes the full command history to the stream.
|
// Writes the full command history to the stream.
|
||||||
Console.WriteLine("Writing input commands to {0}...");
|
Console.WriteLine("Writing input commands to {0}...");
|
||||||
source.Position = initPos;
|
source.Position = initPos;
|
||||||
source.SetLength(initPos);
|
source.SetLength(initPos);
|
||||||
break;
|
break;*/
|
||||||
}
|
}
|
||||||
// Do a check semicolons etc
|
// Do a check semicolons etc
|
||||||
if (IsNextEoS(source))
|
if (IsNextEoS(source))
|
||||||
@ -260,7 +260,7 @@ namespace Assignment_1
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (source.Position != lastLinePos - 1)
|
else if (source.Position != lastLinePos)// - 1)
|
||||||
{
|
{
|
||||||
// In the case that we expect some more data, we must keep tabs of our current line, and keep accumulating data until we're finished
|
// In the case that we expect some more data, we must keep tabs of our current line, and keep accumulating data until we're finished
|
||||||
lastLinePos = source.Position;
|
lastLinePos = source.Position;
|
||||||
@ -416,7 +416,6 @@ namespace Assignment_1
|
|||||||
{
|
{
|
||||||
consoleOutput.Append(string.Format(entryFormat, j >= keyLines.Count ? "" : keyLines[j], j >= valueLines.Count ? "" : valueLines[j], j == 0 ? Convert.ToString((byte)Symbols[eligibleKeys[i]].Item2, 2).PadLeft(8, '0'): ""));
|
consoleOutput.Append(string.Format(entryFormat, j >= keyLines.Count ? "" : keyLines[j], j >= valueLines.Count ? "" : valueLines[j], j == 0 ? Convert.ToString((byte)Symbols[eligibleKeys[i]].Item2, 2).PadLeft(8, '0'): ""));
|
||||||
}
|
}
|
||||||
//consoleOutput.Append(string.Format(entryFormat, eligibleKeys[i], Symbols[eligibleKeys[i]].Item1.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t"), Convert.ToString((byte)Symbols[eligibleKeys[i]].Item2, 2).PadLeft(8, '0')));
|
|
||||||
if (i + 1 < eligibleKeys.Count)
|
if (i + 1 < eligibleKeys.Count)
|
||||||
{
|
{
|
||||||
consoleOutput.Append(string.Format("├" + new string('─', keyWidth) + "┼" + new string('─', valueWidth) + "┼" + new string('─', flagWidth) + "┤\n"));
|
consoleOutput.Append(string.Format("├" + new string('─', keyWidth) + "┼" + new string('─', valueWidth) + "┼" + new string('─', flagWidth) + "┤\n"));
|
||||||
@ -463,7 +462,7 @@ namespace Assignment_1
|
|||||||
}
|
}
|
||||||
Action Print(Stream source, int mode = 0)
|
Action Print(Stream source, int mode = 0)
|
||||||
{
|
{
|
||||||
StringBuilder outputString = new StringBuilder();
|
StringBuilder outputString = new();
|
||||||
string expression = ValidateValue(source);
|
string expression = ValidateValue(source);
|
||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
{
|
{
|
||||||
@ -500,7 +499,7 @@ namespace Assignment_1
|
|||||||
string key = ValidateKey(source, true);
|
string key = ValidateKey(source, true);
|
||||||
string ToReverse = Symbols[key].Item1;
|
string ToReverse = Symbols[key].Item1;
|
||||||
string[] words = ToReverse.Split(' ');
|
string[] words = ToReverse.Split(' ');
|
||||||
StringBuilder reversed = new StringBuilder();
|
StringBuilder reversed = new();
|
||||||
for (int i = words.Length - 1; i >= 0; i--)
|
for (int i = words.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
reversed.Append(words[i]);
|
reversed.Append(words[i]);
|
||||||
@ -526,6 +525,7 @@ namespace Assignment_1
|
|||||||
string errorMSG = new string(' ', (caratPos - lineStart) >= 0 ? (int)(caratPos - lineStart) : 0) + "^ " + errorMessage;
|
string errorMSG = new string(' ', (caratPos - lineStart) >= 0 ? (int)(caratPos - lineStart) : 0) + "^ " + errorMessage;
|
||||||
Console.WriteLine(fullLine);
|
Console.WriteLine(fullLine);
|
||||||
Console.WriteLine(errorMSG);
|
Console.WriteLine(errorMSG);
|
||||||
|
source.Position = lineStart;
|
||||||
source.SetLength(source.Position);
|
source.SetLength(source.Position);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -614,7 +614,7 @@ namespace Assignment_1
|
|||||||
|
|
||||||
if (!Symbols.ContainsKey(keyValue))
|
if (!Symbols.ContainsKey(keyValue))
|
||||||
{
|
{
|
||||||
throw new ParserException("Could not find key: " + keyValue, 0);
|
throw new ParserException("Could not find key: " + keyValue, 0, s.Position);
|
||||||
}
|
}
|
||||||
returnedValue = Symbols[keyValue].Item1;
|
returnedValue = Symbols[keyValue].Item1;
|
||||||
return t;
|
return t;
|
||||||
@ -654,7 +654,6 @@ namespace Assignment_1
|
|||||||
// Is a literal. Now we must parse until we find the end of the literal
|
// Is a literal. Now we must parse until we find the end of the literal
|
||||||
// Remove the first char, if it is a literal definition.
|
// Remove the first char, if it is a literal definition.
|
||||||
if (PeekChar(s) == '\"') ReadChar(s);
|
if (PeekChar(s) == '\"') ReadChar(s);
|
||||||
string resultLiteral;
|
|
||||||
long resultPosition = FindNextOccurance(s, (c, s) =>
|
long resultPosition = FindNextOccurance(s, (c, s) =>
|
||||||
{
|
{
|
||||||
if (c == '\"')
|
if (c == '\"')
|
||||||
@ -671,14 +670,14 @@ namespace Assignment_1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, out resultLiteral);
|
}, out string resultLiteral);
|
||||||
if (resultPosition > -1)
|
if (resultPosition > -1)
|
||||||
{
|
{
|
||||||
returnedLiteral = resultLiteral;
|
returnedLiteral = resultLiteral;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ParserException("Could not parse the literal");
|
throw new ParserException("Could not parse the literal", 0, s.Position);
|
||||||
}
|
}
|
||||||
s.Position = pos;
|
s.Position = pos;
|
||||||
return resultPosition;
|
return resultPosition;
|
||||||
@ -918,15 +917,8 @@ namespace Assignment_1
|
|||||||
public long LinePosition = -1;
|
public long LinePosition = -1;
|
||||||
public ParserException(string message, int importance, long linePos) : base(message)
|
public ParserException(string message, int importance, long linePos) : base(message)
|
||||||
{
|
{
|
||||||
|
Importance = importance;
|
||||||
}
|
LinePosition = linePos;
|
||||||
public ParserException(string message, int importance) : base(message)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
public ParserException(string message) : base(message)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user