/// <summary> /// Парсит конструкцию SWITCH. /// </summary> private static void ParseSwitch(TokenList body) { BaseGenerator generator = CodeManager.GetGenerator(parseMode); for (int index = 0; index < body.Count; index++) { TokenList nextTokens = body.GetRange(index); Token currentToken = body[index]; Token nextToken = body.Get(index + 1); if (currentToken.TypeIs(TokenType.NextLine)) { lineIndex++; continue; } // случай <expression>: if (currentToken.TypeIs(KeywordType.Case) && body[index + 2].TypeIs(TokenType.Colon)) { TokenList caseBody = GetCaseBody(nextTokens, out index, index); generator.AddCaseConstruction(nextToken); Parse(caseBody, out _); } // по_умолчанию: else if (currentToken.TypeIs(KeywordType.Default) && body[index + 1].TypeIs(TokenType.Colon)) { TokenList defaultBody = GetCaseBody(nextTokens, out index, index); generator.AddDefaultCaseConstruction(); Parse(defaultBody, out _); } // завершить; else if (currentToken.TypeIs(KeywordType.Break)) { generator.AddBreak(); } } }