diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/WhileChunk.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/WhileChunk.cs index 2835c01..117ce42 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/WhileChunk.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Flow/WhileChunk.cs @@ -13,6 +13,12 @@ namespace Advanced_Software_Engineering.Verbs.Flow { valueStorage.IncreaseStack(); } + public WhileChunk(ValueStorage valueStorage, IValue conditional, IVerb oneLineVerb) : base(new List { oneLineVerb }) { + this.conditional = conditional; + this.valueStorage = valueStorage; + valueStorage.IncreaseStack(); + } + public new void ExecuteVerb() { valueStorage.IncreaseStack(); while (conditional.ToBool()) base.ExecuteVerb(); diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs index 9fd9c38..c1ea690 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs @@ -104,6 +104,12 @@ namespace Advanced_Software_Engineering { currentChunk = verbChunks[chunkDepth]; parsed = true; tmpVerb = new NoOp(); + } else if (commandParameters.Length >= 2) { //single line if + string commandAfterIf = fullCommand.Substring(fullCommand.IndexOf(",") + 1); // find the first , + IValue conditional = ValueFactory.CreateValue(rootValueStorage, commandParameters[0]); //make the conditional + IVerb AfterIf = MakeVerb(drawer, commandAfterIf); //make the following command + tmpVerb = new WhileChunk(rootValueStorage, conditional, AfterIf); //Create the chunk + parsed = true; } else throw new Exception(command + " has an incorrect number of parameters"); break;