Moved comment removal to Commander

This commit is contained in:
Lukasz Baldyga committed 2020-11-30 22:11:21 +00:00
1 parent 8c80ae322b
commit a1b3240d3a
2 files changed
+8 -10

No files matched your search

@@ -84,11 +84,17 @@ namespace Advanced_Software_Engineering {
int lineNumber = 0; int lineNumber = 0;
bool failed = false; bool failed = false;
foreach (string rawCommand in commands) { foreach (string rawCommand in commands) {
string fullCommand = rawCommand;
lineNumber++; lineNumber++;
if (rawCommand == "") continue; //Remove comments
if (fullCommand.Contains("@")) {
fullCommand = fullCommand.Substring(0, fullCommand.IndexOf("@"));
}
if (fullCommand == "") continue;
try { try {
AddCommand(VerbFactory.MakeVerb(drawer, rawCommand)); AddCommand(VerbFactory.MakeVerb(drawer, fullCommand));
Console.WriteLine(rawCommand); Console.WriteLine(rawCommand);
} catch (Exception e) { } catch (Exception e) {
Console.WriteLine("Error!"); Console.WriteLine("Error!");
@@ -24,14 +24,6 @@ namespace Advanced_Software_Engineering {
/// <param name="fullCommand">The command as a string</param> /// <param name="fullCommand">The command as a string</param>
/// <returns>A IVerb that maches the command</returns> /// <returns>A IVerb that maches the command</returns>
public static IVerb MakeVerb(Drawer drawer, string fullCommand) { public static IVerb MakeVerb(Drawer drawer, string fullCommand) {
//Remove comments
string tmp = "";
foreach(char character in fullCommand) {
if (character == "@"[0]) break;
tmp += character;
}
fullCommand = tmp;
ValueStorage rootValueStorage = drawer.GetValueStorage(); ValueStorage rootValueStorage = drawer.GetValueStorage();
List<VerbChunk> verbChunks = drawer.verbChunks; List<VerbChunk> verbChunks = drawer.verbChunks;