Fixed bad command continued parsing (Closes #1)
This commit is contained in:
parent
bd644fdef3
commit
482ecc6468
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user