From 97fb3a04ca309197f4605857e0c9da63bcf16298 Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Mon, 30 Nov 2020 21:04:33 +0000 Subject: [PATCH] Multiline and nested ifs now possible --- .../Verbs/VerbFactory.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs index 2cc5a30..6d676d1 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/VerbFactory.cs @@ -84,7 +84,7 @@ namespace Advanced_Software_Engineering { } } - + //Parse flow verbs switch (command) { case "if": @@ -94,7 +94,7 @@ namespace Advanced_Software_Engineering { currentChunk = verbChunks[chunkDepth]; parsed = true; tmpVerb = new NoOp(); - } else if(commandParameters.Length >= 2) { + } else if (commandParameters.Length >= 2) { 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 @@ -252,6 +252,14 @@ namespace Advanced_Software_Engineering { } else throw new Exception(command + " has an incorrect number of parameters"); break; + //exit flow + case "end": + if (parameterLength == 0) { + if (currentChunk == null) throw new Exception("Cannot end at chunk level 0"); //Todo, describe better + verbChunks.Remove(currentChunk); + return currentChunk; + } else throw new Exception(command + " doesn't take parameters"); + default: throw new Exception("Unknown command or cannot parse"); }