Fixed bad command continued parsing (Closes #1)

This commit is contained in:
Brychan Dempsey 2021-03-15 13:46:54 +13:00
parent bd644fdef3
commit 482ecc6468

View File

@ -77,7 +77,8 @@ namespace Assignment_1
printwordcount,
set,
reverse,
h
h,
writeout
}
public void StartParsing(Stream source, bool dynamicInput = false)
{
@ -97,6 +98,7 @@ namespace Assignment_1
// parse the statement or list of statements;
// This is done by reading the next word
SkipWhitespace(source);
long initPos = source.Position;
long position = FindNextWord(source, out string word);
object statementType;
if (Enum.TryParse(typeof(statements), word, out statementType))
@ -138,9 +140,20 @@ namespace Assignment_1
Console.WriteLine("\t{0}", ((statements)item).ToString());
}
break;
case statements.writeout:
// Writes the full command history to the stream.
Console.WriteLine("Writing input commands to {0}...");
break;
}
}
else Console.WriteLine("Failed parsing statement");
else
{
// Statement parse failed,
// Ensure stream gets trimmed back to the correct position
Console.WriteLine("Failed parsing statement");
source.Position = initPos;
source.SetLength(initPos);
}
}
}