Instruction AnalyseWhile(Tokenizer.Token[] tokens, int index, out int tokenCount) { InstructionWhile instructionWhile = new InstructionWhile(); int tc; tokenCount = 0; Tokenizer.Token[] tokensTest = GetTokensBetweenParentheses(tokens, index + 1); instructionWhile.TestInstruction = AnalyseInstruction(tokensTest, 0, out tc); tokenCount += 3 + tokensTest.Length; Tokenizer.Token[] tokensBloc = GetTokensInsideBloc(tokens, index + tokenCount); int indexBloc = 0; while (indexBloc < tokensBloc.Length) { Instruction instruction = AnalyseInstruction(tokensBloc, indexBloc, out tc); instructionWhile.BlocInstruction.Add(instruction); indexBloc += tc; } tokenCount += 2 + tokensBloc.Length; return(instructionWhile); }
InstructionResult ExecuteInstructionWhile(Instruction instruction) { InstructionWhile instructionWhile = instruction as InstructionWhile; while (ExecuteInstruction(instructionWhile.TestInstruction).Value.BoolValue) { foreach (Instruction blocInstruction in instructionWhile.BlocInstruction) { var result = ExecuteInstruction(blocInstruction); if (result != null) { if (result.Return) { return(result); } else if (result.Break) { return(new InstructionResult() { Return = false }); } } } } return(new InstructionResult() { Return = false }); }