Private
Public Access
Added single line while loops
This commit is contained in:
1 parent
40754aae69
commit
72b5db624f
2 files changed
+12
No files matched your search
@@ -13,6 +13,12 @@ namespace Advanced_Software_Engineering.Verbs.Flow {
|
|||||||
valueStorage.IncreaseStack();
|
valueStorage.IncreaseStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WhileChunk(ValueStorage valueStorage, IValue conditional, IVerb oneLineVerb) : base(new List<IVerb> { oneLineVerb }) {
|
||||||
|
this.conditional = conditional;
|
||||||
|
this.valueStorage = valueStorage;
|
||||||
|
valueStorage.IncreaseStack();
|
||||||
|
}
|
||||||
|
|
||||||
public new void ExecuteVerb() {
|
public new void ExecuteVerb() {
|
||||||
valueStorage.IncreaseStack();
|
valueStorage.IncreaseStack();
|
||||||
while (conditional.ToBool()) base.ExecuteVerb();
|
while (conditional.ToBool()) base.ExecuteVerb();
|
||||||
|
|||||||
@@ -104,6 +104,12 @@ namespace Advanced_Software_Engineering {
|
|||||||
currentChunk = verbChunks[chunkDepth];
|
currentChunk = verbChunks[chunkDepth];
|
||||||
parsed = true;
|
parsed = true;
|
||||||
tmpVerb = new NoOp();
|
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");
|
} else throw new Exception(command + " has an incorrect number of parameters");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user